<? 
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
include("../test.php");
?>

<style>
select,input,body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>
<center>
<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()">
<table cellspacing=1 cellpadding=1 bgcolor=black>
<tr><td align=center bgcolor='GRAY'><FONT COLOR='IVORY'><B>CHANGE 8A - 8B</TD></TR>
<TR><td align=center bgcolor='ivory'>
  <table>
   <tr><td>Enter Invoice NO.</td><td><input type=text name='inv' value='<?print $inv?>' ></td>
       <td><input type=submit name='sea' value='Search'></td>
   </tr>
  </table>
</td></tr>
</table>
</form>
<br>
<?      
if($sea)
{
 $re=mysqli_query($db,"select engno,chasis,da,config,tp,invdate from veh_invoice where invno='$inv' and brcode='$brcode' and type='-'")or die(mysqli_error());
if(mysqli_num_rows($re)>0)
{
 print "\n<table border=1><th>Inv Date <th>DA<th>Config<th>Type <th>Edit";
 while($row=mysqli_fetch_array($re))
 {
   print "\n<form action='$PHP_SELF' name='f1' onSubmit='return valid()'><tr><td><input type=hidden name='invno' value='$inv'>".datetohtml($row[invdate])."</td><td><input type=text name='da' value='$row[da]'></td><td>$row[config]</td>";
   print "<td><select name='tp'><option>$row[tp]</option><option>8A</option><option>8B</option> </td>";
 print "<td><input type='submit' value='Update' name='upd'></td></tr></form>";
 }
}
print "</table>";
?>
 <script>
 function valid()
 {
  if(document.f1.tp.value.length<=0)
    {
      alert('Invalid Type');
      return false;
   }
  else
     return true;
 }
</script>
<?
}
//**********************************************
if($upd)
{
 $sql="update veh_invoice set tp='$tp' where invno='$invno' and da='$da' and brcode='$brcode' and type='-'";
 mysqli_query($db,$sql)or die(mysqli_error());
 print "<b>Data has been changed</b>";
}
?>
