<?
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");
$acres=mysqli_query($db,"select * from trcmast where tcrno='$trcno' and brcode='$brcode'");
 if(mysqli_num_rows($acres)>0)
 {
  print "<script> alert('Duplicate TCR Number'); history.back(1); </script>";
  return;
 }
 $sql="create table tcrmast (tcrno varchar(100),tcrdesc varchar(250),vehclass varchar(250),rendate date, location varchar(250),insuco varchar(250), policyno varchar(100),insudt date,brcode varchar(100),user varchar(100), ondate date)";
 mysqli_query($db,$sql);
$sql="insert into tcrmast values('$tcrno','$tcrdesc' ,'$vehclass','$rendate' , '$location' ,'$insuco', '$policyno' ,'$insudt','$brcode' ,'$user', '$ondate')";
mysqli_query($db,$sql) or die(mysqli_error($db));
}
?>
<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=60%>
<tr><td bgcolor='e4ecc4'><center><h3>TCR MASTER</h3></TD></TR>
<TR><TD>
<table cellspacing=1 cellpadding=2>
<tr><td>TCR No. </td><td><input type=text name='tcrno' size=40></td></tr>
<tr><td>Description </td><td><textarea name='tcrdesc' cols=39></textarea></td></tr>
<tr><td>Class of vehicle </td><td><input type=text name='vehclass' size=40></td></tr>
<tr><td>Renew Date</td><td>dd<input type=text name='pd' size=2> 
mm <input type=text name='pm' size=2> yy
<input type=text name='py' size=4> </td></tr>
<tr><td>Branch</td><td><select name='location'> 
<?
$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=60%>
<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> </td></tr>

<tr><td>Policy Number</td><td colspan=3><input type=text name='policyno'  size=30> </td></tr>

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

