<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($edit)
{
 if(strlen($custname)<=0||strlen($ofno)<=0)
  {
     print "<script> alert('In sufficient entry'); history.back(1);  </script>";
     return;
  }

 $sql="update cust_master set custname='$custname',addr1='$addr1',addr2='$addr2',city='$city', dist='$dist', stat='$stat', pin='$pin',phone1='$phone1',phone2='$phone2',email='$email', web='$web',acname='$acname',corporate='$corp',ofno='$ofno',cst='$cst',tin='$tin',kgst='$kgst', op='$op' where code='$code' and branch='$brcode'";
 mysqli_query($db,$sql)or die(mysqli_error());
//mysqli_query($db,"update ledger set op='$op' where led='$acname' and brcode='$brcode'")or die('ledger err:'.mysqli_error());
print "<font color=green>Data has been changed</font>";
 return;
}
$result=mysqli_query($db,"select * from cust_master where code='$code'");
$row=mysqli_fetch_array($result);
?>



<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
th{background-color:green;color:white}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>

<CENTER>
<BR>
<FORM ACTION='<?print $PHP_SELF?>' METHO='POST'>
<input type=hidden name='code' value='<?print $code?>'>
<input type=hidden name=acname value='<?print $row[acname]?>'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr  bgColor='c1d7bb'><td align=center>
<table>
<tr bgColor='c1d7bb'><td colspan=2 align=center><STRONG>CUSTOMER MASTER</TD></TR>
<tr bgColor='c1d7bb'><td>Order Form No.<br><font color=blue></td><td><input type=text name='ofno' size=10 value='<?print $row[15]?>' > Date: <?print $row[16]?></td></tr>

<tr bgColor='c1d7bb'><td>Customer Name </td><td><input type=text name='custname' size=40 value='<?print $row[1]?>'> </td></tr>
<tr bgColor='c1d7bb'><td>Display Name<br><font color=blue>(A/c Head) </td><td>
<input type=text readonly name='acname' size=30 value='<?print $row[13]?>' style={color:gray}>
<?if($level>=3){?>
<input type=button value='Edit' onClick=fn('<?print $row[0]?>');>
<?
}
?>
</td></tr>

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


<tr bgColor='c1d7bb'><td>Address1 </td><td><input type=text name='addr1' size=40 value='<?print $row[2]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Address2 </td><td><input type=text name='addr2' size=40 value='<?print $row[3]?>'></td></tr>
<tr bgColor='c1d7bb'><td>City </td><td><input type=text name='city' size=40 value='<?print $row[4]?>'></td></tr>
<tr bgColor='c1d7bb'><td>District </td><td>
<select name='dist'>
<option><?print $row[5]?></option>
<?
$re=mysqli_query($db,"select * from dist_master where brcode='$brcode' order by dist");
while($ro=mysqli_fetch_row($re))
{
 print "<option>$ro[1]</option>";
}
?>
 </select>
</td></tr>
<tr bgColor='c1d7bb'><td>State </td><td><input type=text name='stat' size=40 value='<?print $row[6]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Pin No </td><td><input type=text name='pin' size=40 value='<?print $row[7]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Phone1 </td><td><input type=text name='phone1' size=40 value='<?print $row[8]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Phone2 </td><td><input type=text name='phone2' size=40 value='<?print $row[9]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Email_id </td><td><input type=text name='email' size=40 value='<?print $row[10]?>'></td></tr>
<tr bgColor='c1d7bb'><td>Web</td><td><input type=text name='web' size=40 value='<?print $row[11]?>'></td></tr>
<tr bgColor='c1d7bb'><td colspan=2>TIN <input type=text name='tin' size=10 value='<?print $row[21]?>'>
CST <input type=text name='cst' size=10 value='<?print $row[22]?>'>
KGST <input type=text name='kgst' size=10 value='<?print $row[23]?>'></td></tr>
<!--
<tr bgColor='c1d7bb'><td><font color=blue>Opening Balance</td> 
  <td><input type=text name='op' size=10 value='<?print $row[24]?>'></td></tr>
-->
<TR bgColor='c1d7bb'><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME = 'edit' VALUE='  UPDATE  '> <input type=button value='  CANCEL  ' onClick=document.location='cust-mast.php'> </TD></TR>

</table>
</td></tr>
</table>
</FORM>
<script>
function fn(x)
{
 if(confirm('Do you want to edit ledger name ?'))
 {
   document.location='editcustled.php?code='+x;
 }
}
</script>
