<?
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");
$code=$_REQUEST['code'];
$sql="select * from customer where code='$code' and brcode='$brcode'";
$re=mysqli_query($db,$sql)or die(mysqli_error($db));
$row=mysqli_fetch_array($re);
$dt1=explode('-',$row[crdate]);
$dt2=explode('-',$row[dob]);

?>
<link rel="stylesheet" href="style.css" type="text/css" />
<center>
<form action='updcustomer.php' onSubmit="return valid()" method='post'>
<input type=hidden name='code' value='<?print $code?>'>
<table cellspacing=1 cellpadding=2 bgcolor='aliceblue'>
<tr height=21><td colspan=2 align=center bgcolor='steelblue'><FONT COLOR=IVORY><B>EDIT CUSTOMER DETAILS</td></tr>
<TR><TD>Creation Date </TD><TD><?print  $dt1[2].'-'.$dt1[1].'-'.$dt1[0]?></td></tr>
<tr><td>Customer Name</td><td><input type=text name='cname' size=40 value='<?print $row[cname]?>'></td></tr>

<tr><td>Corporate </td><td><select name='corp'><option><?print $row[corp]?></option>
<?
$re=mysqli_query($db,"select * from corp_master where branch='$brcode'  order by corpname");
while($row1=mysqli_fetch_row($re))
{
 print "<option>$row1[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' readonly size=40  value='<?print $row[acname]?>' style="background-color:ivory"></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 value='<?print $row[addr1]?>'></td></tr>
<tr><td>District</td><td><input type=text name='dist1' size=40 value='<?print $row[dist1]?>'></td></tr>
<tr><td>State</td><td><input type=text name='state1' size=40 value='<?print $row[state1]?>'></td></tr>
<tr><td>pin</td><td><input type=text name='pin1' size=6 value='<?print $row[pin1]?>'></td></tr>
<tr><td>Phone</td><td><input type=text name='phone1' size=40 value='<?print $row[phone1]?>'></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 value='<?print $row[addr2]?>'></td></tr>
<tr><td>District</td><td><input type=text name='dist2' size=40 value='<?print $row[dist2]?>'></td></tr>
<tr><td>State</td><td><input type=text name='state2' size=40 value='<?print $row[state2]?>'></td></tr>
<tr><td>pin</td><td><input type=text name='pin2' size=6 value='<?print $row[pin2]?>'></td></tr>
<tr><td>Phone</td><td><input type=text name='phone2' size=40 value='<?print $row[phone2]?>'></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 value='<?print $row[mob]?>'></td></tr>

<tr><td>
<select name='relation'>
<option><?print $row[relation]?></option>
<option>S/o</option>
<option>D/o</option>
<option>W/o</option>
</select>

 </td><td><input type=text name='father' size=40 value='<?print $row[father]?>'></td></tr>

<tr><td>Date of Birth</td>
<td>
 dd  <input type=text name='d1' size=2 value='<?print $dt2[2]?>'>
mm  <input type=text name='m1' size=2 value='<?print $dt2[1]?>'>
yy  <input type=text name='y1' size=4 value='<?print $dt2[0]?>'>
</td></tr>

<tr><td>Email_id </td><td><input type=text name='email' size=40 value='<?print $row[email]?>'></td></tr>
<tr><td>Web</td><td><input type=text name='web' size=40 value='<?print $row[web]?>'></td></tr>

<tr><td colspan=2>TIN <input type=text name='tin' size=10 value='<?print $row[tin]?>'>
CST <input type=text name='cst' size=10 value='<?print $row[cst]?>'>
KGST <input type=text name='kgst' size=10 value='<?print $row[kgst]?>'></td></tr>

<?if($level>=4)
{
?>
<tr><td colspan=2>Credit Amt <input type=text name='cramt' size=10 value='<?print $row[cramt]?>'>
Credit Days <input type=text name='crdays' size=10 value='<?print $row[crdays]?>'></td></tr>
<?
}
?>
<?if($level<=3)
{
?>
<tr><td colspan=2>Credit Amt <input type=text readonly name='cramt' size=10 value='<?print $row[cramt]?>'>
Credit Days <input type=text readonly name='crdays' size=10 value='<?print $row[crdays]?>'></td></tr>
<?
}
?>
<tr><td colspan=2 align=center bgcolor='lightsteelblue'>
<input type=submit value='Save' name='upd'> 
<input type=button value='Cancel' onClick=history.go(-1)>
</td></tr>
</table>
</form>
