<?
session_start();
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="style.css" type="text/css" />
<script>
function valid()
{ 
 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>35)
 { 
   alert('Name exeeds the limit');
   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 action='svcustomer.php' onSubmit="return valid()">
<table cellspacing=1 cellpadding=2 bgcolor='aliceblue'>
<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 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 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' size=40 onKeyDown=chkey(this);></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><input type=text name='state1' size=40 value='Kerala'></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><input type=text name='state2' size=40 value='Kerala'></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>
<select name='relation'>
<option>S/o</option>
<option>D/o</option>
<option>W/o</option>
</select>

 </td><td><input type=text name='father' size=40></td></tr>

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

<tr><td>Email_id </td><td><input type=text name='email' size=40></td></tr>
<tr><td>Web</td><td><input type=text name='web' size=40></td></tr>

<tr><td colspan=2>TIN <input type=text name='tin' size=10>
CST <input type=text name='cst' size=10>
KGST <input type=text name='kgst' size=10></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'>
<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>Del
<?
$re=mysqli_query($db,"select * from customer where brcode='$brcode' order by acname")or die(mysqli_error());
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "\n<form action='editcust.php'>\n<input type=hidden name='code' value='$row[1]'>";
 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>\n<input type=submit value='Edit' name='edit'></td></tr></form>";
}
?>
</table>

<table cellspacing=1 cellpadding=3 bgcolor='lightsteelblue'>
<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>Branch
<?
$re1=mysqli_query($db,"select * from customer where brcode!='$brcode' order by brcode,acname")or die(mysqli_error());
$i=1;
while($row1=mysqli_fetch_array($re1))
{
 print "\n<form action='editcust.php'>\n<input type=hidden name='code' value='$row1[1]'>";
 print "\n<tr bgcolor=aliceblue><td>".$i++."</td><td>$row1[cname]</td><td>$row1[acname]</td><td>$row1[addr1]</td><td>$row1[dist1]</td><td>$row1[state1]</td><td>$row1[pin1]</td><td>$row1[phone1]</td>";
 print "<td>$row1[mob]</td><td>$row1[cramt]</td><td>$row1[crdays]</td><td>$row1[brcode]</td></tr></form>";
}
?>
</table>


