<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$level=$_SESSION['level'];
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}

include("opendb.php");
?>
<? //<input type=button value='Find Duplicate A/C Head' onClick=window.open('getdupcust.php')> ?>
<br>&nbsp;
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script>
function valid()
{ 
     var gstno=document.getElementById("gst").value;
     var sdr=document.getElementById("gstsel").value;
    if(sdr=='N')
    {
       return true;
    }
    else
    {
        if(gstno.length<15||gstno.length==''||gstno.length>15)
        {
        alert("Enter 15 Digit GST Number...!!!");
        document.getElementById("gst").value='';
        document.getElementById("gst").focus();
        return false;
        } 
    }
    
 subOK="false";
 x=confirm("Do you want to save?");
 if(x)
  subOK="true";
   if(subOK=="true")
     return true;
   else
     return false;
} 



function chkey(abc)
{

 yy=abc.value
 if(yy.length>0)
 { 
///alert('Name exeeds the limit');
document.getElementById("acname").value=yy;
//   return;
 }

 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }
 if(yy.indexOf('"')>-1) 
  {
    alert("\" is not allowed");
    abc.value='';
  }

if(yy.indexOf("&")>-1) 
  {
    alert("& is not allowed");
    abc.value='';
  }
  

}
</script>

<center>
<form method='post' name=f1 action='svcustomer_serv.php' onSubmit="return valid()">
<table cellspacing=1 cellpadding=2 bgcolor='aliceblue' width=40%>
<tr height=21><td colspan=2 align=center bgcolor='steelblue'><FONT COLOR=IVORY><B>CUSTOMER MASTER</td></tr>
<TR><TD>Creation Date </TD><TD>dd  <input type=text name=d readonly size=2 value='<?print date("d",time())?>'>
mm  <input type=text name=m size=2 value='<?print date("m",time())?>'>
yy  <input type=text name=y size=4 value='<?print date("Y",time())?>'>
</td></tr>
<tr><td>Customer Name</td><td><input type=text name='cname' size=40 id=cname  autocomplete='off' onKeyDown=chkey(this);></td></tr>

<tr><td>Corporate </td><td><select name='corp'><option>-</option>
<?
$re=mysqli_query($db,"select * from corp_master where branch='$brcode'  order by corpname");
while($row=mysqli_fetch_row($re))
{
 print "<option>$row[1]</option>";
}
?>
</select>
</td></tr>

<tr bgColor='c1d7bb'><td><font color=red>Display Name<br><font color=blue>(A/c Head) 
</td><td><input type=text name='acname' id=acname readonly size=40 autocomplete='off' ></td></tr>

<tr><td colspan=2 align=center bgcolor='lightsteelblue'>PERMANANT</td></tr>
<tr><td>Address</td><td><input type=text name='addr1' size=40></td></tr>
<tr><td>District</td><td><input type=text name='dist1' size=40></td></tr>
<tr><td>State</td><td>
    <select name='state1' id=state1><option>Select State</option>
<option>Kerala</option><option>Tamil Nadu</option><option>Karnataka</option><option>Andhra Pradesh</option>
<option>Arunachal Pradesh</option><option>Assam</option><option>Bihar</option><option>Chandigarh</option><option>Chhattisgarh</option>
<option>Dadra and Nagar Haveli</option><option>Daman and Diu</option><option>Delhi</option><option>Goa</option>
<option>Gujarat</option><option>Haryana</option><option>Himachal Pradesh</option><option>Jammu and Kashmir</option>
<option>Jharkhand</option><option>Madhya Pradesh</option><option>Maharashtra</option><option>Manipur</option>
<option>Meghalaya</option><option>Mizoram</option><option>Nagaland</option><option>Orissa</option>
<option>Puducherry</option><option>Punjab</option><option>Rajasthan</option><option>Sikkim</option><option>Telangana</option>
<option>Tripura</option><option>Uttar Pradesh</option><option>Uttarakhand</option><option>West Bengal</option>
    </select>
</td></tr>
<tr><td>pin</td><td><input type=text name='pin1' size=6></td></tr>
<tr><td>Phone</td><td><input type=text name='phone1' size=40></td></tr>

<tr><td colspan=2 align=center bgcolor='lightsteelblue'>PRESENT</td></tr>
<tr><td>Address</td><td><input type=text name='addr2' size=40></td></tr>
<tr><td>District</td><td><input type=text name='dist2' size=40></td></tr>
<tr><td>State</td><td>
<select name='state2'><option>Select State</option>
<option>Kerala</option><option>Tamil Nadu</option><option>Karnataka</option><option>Andhra Pradesh</option>
<option>Arunachal Pradesh</option><option>Assam</option><option>Bihar</option><option>Chandigarh</option><option>Chhattisgarh</option>
<option>Dadra and Nagar Haveli</option><option>Daman and Diu</option><option>Delhi</option><option>Goa</option>
<option>Gujarat</option><option>Haryana</option><option>Himachal Pradesh</option><option>Jammu and Kashmir</option>
<option>Jharkhand</option><option>Madhya Pradesh</option><option>Maharashtra</option><option>Manipur</option>
<option>Meghalaya</option><option>Mizoram</option><option>Nagaland</option><option>Orissa</option>
<option>Puducherry</option><option>Punjab</option><option>Rajasthan</option><option>Sikkim</option><option>Telangana</option>
<option>Tripura</option><option>Uttar Pradesh</option><option>Uttarakhand</option><option>West Bengal</option>
    </select>
</td></tr>
<tr><td>pin</td><td><input type=text name='pin2' size=6></td></tr>
<tr><td>Phone</td><td><input type=text name='phone2' size=40></td></tr>

<tr><td colspan=2 align=center bgcolor='lightsteelblue'>OTHER</td></tr>
<tr><td>Mobile</td><td><input type=text name='mob' size=40></td></tr>
<tr><td>FR Name</td><td><input type=text name='relation' size=40></td>
<tr><td>
</td><td><input type=text name='father' size=40></td></tr>

<tr><td>Date of Birth</td>
<td>
dd  <input type=text value='00' name='d1' size=2>
mm  <input type=text value='00' name='m1' size=2>
yy  <input type=text value='00-00-0000' name='y1' size=4>
</td></tr>

<tr><td>Email_id </td><td><input type=text name='email' size=40></td></tr>
<tr><td>TCS Applicable</td><td><select id='tcsapply' name='tcsapply'><option value='NO'>NO</option><option value='YES'>YES</option></select></td>
</tr>
<tr><td>Manufacturer</td><td>
<?$brres=mysqli_query($db,"select acname,code from customer order by acname");
//print "<select name='companycode'><option>N/A</option>";
/*$brr=mysqli_query($db,"select distinct comp_name,companycode from companymaster order by comp_name");

while($brr_r=mysqli_fetch_array($brr))
    {
        print "\n<option value='$brr_r[1]'>$brr_r[0]</option>";
    }
print "</select>";*/
?>
</td></tr>
<tr><td>GST Registred</td><td><select id='gstsel' name='gstsel' onchange='gstreg()'><option value='Y'>YES</option><option value='N'>NO</option></select></td>
<tr bgColor='c1d7bb' id='gsttr'><td>GST No </td><td><input type=text name='gst' id='gst' size=40 onchange='gstnochk()'></td></tr>







<tr><td colspan=2 align=center bgcolor='lightsteelblue'>
<input type=submit value='Save' name='sv'> <input type=button value='Cancel'>
</td></tr>
</table>
</form>
<table cellspacing=1 cellpadding=3 bgcolor='lightsteelblue' class=report>
<th>No. <th>Name <th>A/C Name<th>Address <th>Dist <th>State <th> Pin <th>Phone <th>Mobile <th>Cramt<th>Crdays<th>GST No<th>Del
<?
if($brcode=='UNI001' || $brcode=='PSNBAN' || $brcode=='DALCLT'  )
    $re=mysqli_query($db,"select * from customer where brcode = '$brcode' order by acname")or die(mysqli_error($db));
else
    $re=mysqli_query($db,"select * from customer  order by acname")or die(mysqli_error($db));
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "\n<form method='post' action='editcust_serv.php'>\n<input type=hidden name='code' value='$row[1]'><input type=hidden name='acname' value='$row[5]'>";
 print "\n<tr bgcolor=aliceblue><td>".$i++."</td><td>$row[cname]</td><td>$row[acname]</td><td>$row[addr1]</td><td>$row[dist1]</td><td>$row[state1]</td><td>$row[pin1]</td><td>$row[phone1]</td>";
 print "<td>$row[mob]</td><td>$row[cramt]</td><td>$row[crdays]</td><td>$row[gst]</td><td>\n<input type=submit value='Edit' name='edit'></td></tr></form>";
}
?>
</table>

<script>

function gstnochk(){
    var gstno=document.getElementById("gst").value;
    if(gstno.length<15||gstno.length==''||gstno.length>15)
    {
        alert("Enter 15 Digit GST Number...!!!");
        document.getElementById("gst").value='';
        document.getElementById("gst").focus();
    }
 }//function closed.
 
function gstreg(){
var sdr=document.getElementById("gstsel").value;
 if(sdr=='N')
 {
   document.getElementById("gsttr").style.visibility = "hidden";
   document.getElementById("gst").value="NOT REGISTERD";
 }
 else
 {
   document.getElementById("gsttr").style.visibility = "visible";
   document.getElementById("gst").value='';
 }
 }//function closed.
</script>
