<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Invalid Login'); parent.document.location='ind.php' </script>";
 return;
}
include("../opendb.php");
include("../test.php");
if($save)
{
 $rendate=$py.'-'.$pm.'-'.$pd;
 $insudt=$inyt.'-'.$inmt.'-'.$indt;
 $ondate=date("Y-m-d");
if($pswd=='edit')
{
$sql="update tcrmast set tcrdesc='$tcrdesc' ,vehclass='$vehclass',rendate='$rendate' , location='$location' ,insuco='$insuco', policyno='$policyno' ,insudt='$insudt' where tcrno='$tcrno' and brcode='$brcode'";
mysqli_query($db,$sql) or die(mysqli_error());
print "<script> opener.document.location='tcrmastrepo.php'; window.close()</script>";
}
else
{
 print "<font color='red'>Invalid  Password</font>";
}
}
$re=mysqli_query($db,"select * from tcrmast where tcrno='$tcrno'");
$row=mysqli_fetch_array($re);
?>
<style>
body,td{font-family:arial narrow;font-size:14}
th{background-color:silver}
</style>
<center>
<form action='<?print $PHP_SELF?>' method='post' name='f1'>
<table border=1  width=40%>
<tr><td bgcolor='e4ecc4'><center><h3>EDIT TCR MASTER</h3></TD></TR>
<TR><TD>
<table cellspacing=1 cellpadding=2>
<tr bgcolor='yellow'><td>Password</td><td><input type=password name='pswd' size=40></td></tr>

<tr><td>TCR No. </td><td><input type=text name='tcrno' size=40 readonly value='<?print $row[0]?>'></td></tr>
<tr><td>Description </td><td><textarea name='tcrdesc' cols=39><?print $row[tcrdesc]?></textarea></td></tr>
<tr><td>Class of vehicle </td><td><input type=text name='vehclass' size=40 value='<?print $row[vehclass]?>'></td></tr>
<?
$dd=explode('-',$row[rendate]);
?>
<tr><td>Renew Date</td><td>dd<input type=text name='pd' size=2 value='<?print $dd[2]?>'> 
mm <input type=text name='pm' size=2 value='<?print $dd[1]?>'> yy
<input type=text name='py' size=4 value='<?print $dd[0]?>'> </td></tr>
<tr><td>Branch</td><td><select name='location'>
<option><?print $row[location]?></option> 
<?
$locre=mysqli_query($db,"select brname from br_master where brcode='$brcode' order by brname");
while($locrow=mysqli_fetch_array($locre))
{
 print "<option>$locrow[brname]</option>";
}
?>
</select>
</td></tr>
</table>
</td></tr
</table>

<table border=1  width=40%>
<tr><td bgcolor='e4ecc4'><center>INSURANCE DETAILS</TD></TR>
<TR><TD>
<table cellspacing=1 cellpadding=2>
<tr><td>Insurance Company</td><td colspan=3><input type=text name='insuco'  size=30  value='<?print $row[insuco]?>'> </td></tr>

<tr><td>Policy Number</td><td colspan=3><input type=text name='policyno'  size=30  value='<?print $row[policyno]?>'> </td></tr>
<?
$dd=explode('-',$row[insudt]);
?>

<tr><td>Due Date</td><td colspan=3>dd<input type=text name='indt' size=2 value='<?print $dd[2]?>'> 
mm <input type=text name='inmt' size=2 value='<?print $dd[1]?>'> yy
<input type=text name='inyt' size=4 value='<?print $dd[0]?>'> </td></tr>
</table>
<tr><td bgcolor='e4ecc4' colspan=3><center><input type=submit value='Save' name='save'></TD></TR>
</TABLE>
</form>

