<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($edit)
{
 $sql="update veh_master set mcode='$mcode', config='$config', gvw='$gvw', wbase='$wbase', tyrefr='$tyrefr', tyrerr='$tyrerr',cat='$cat',clas='$clas',mnam='$mnam',hpower='$hpower',fuel='$fuel',cyl='$cyl',capa='$capa',uweight='$uweight',axlefr='$axlefr',axlerr='$axlerr',axleoth='$axleoth',axletan='$axletan',cbody='$cbody',tbody='$tbody',sconfig='$sconfig',active='$active' where code='$code' and brcode='$brcode'";
mysqli_query($db,$sql) or die(mysqli_error());
include("vehmaster.php");
 return;
}

$result=mysqli_query($db,"select * from veh_master where code='$code' and brcode='$brcode'");
$row=mysqli_fetch_array($result);
?>
<script>
function valid()
{
  submitOK="true";

 if(document.f1.mcode.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Model Code');
 }

 if(document.f1.config.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Configuration');
 }

if(document.f1.sconfig.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Configuration');
 }

  if(submitOK=="true")
   return true;
  else
   return false;
}
</script>

<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>
<CENTER>
<BR>
<FORM name='f1' ACTION='<?print $PHP_SELF?>' METHOD='POST' onSubmit="return valid()">
<input type=hidden name='code' value='<?print $code?>'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr><td align=center>
<table>
<tr><td colspan=2 align=center>EDIT VEHICLE MASTER</TD></TR>
<tr><td>Model Code </td><td>
  <input type=text name='mcode' size=40  value='<?print $row[mcode]?>' onKeyDown=chkey(this);></td></tr>
<tr><td>Configuration </td><td>
  <input type=text name='config' size=40 value='<?print $row[config]?>'></td></tr>
<tr><td><font color='red'>Sale Cert Configuration </td><td><input type=text name='sconfig' size=40 value='<?print $row[sconfig]?>' onKeyDown=chkey(this) ></td></tr>

<tr><td>G V W </td><td>
  <input type=text name='gvw' size=40 value='<?print $row[gvw]?>'></td></tr>
<tr><td>W Base </td><td>
  <input type=text name='wbase' size=40 value='<?print $row[wbase]?>'></td></tr>
<tr><td>Tyre FR </td><td>
  <input type=text name='tyrefr' size=40 value='<?print $row[tyrefr]?>'></td></tr>
<tr><td>Tyre RR </td><td><input type=text name='tyrerr' size=40 value='<?print $row[tyrerr]?>'></td></tr>
<tr><td>Category </td><td>
	<input type=text name='cat' size=40 value='<?print $row[cat]?>'></td></tr>

<tr><td>Class </td><td><input type=text name='clas' size=40 value='<?print $row[clas]?>'></td></tr>
<tr><td>Makers Name </td><td><input type=text name='mnam' size=40 value='<?print $row[mnam]?>'></td></tr>
<tr><td>Horse Power </td><td><input type=text name='hpower' size=40 value='<?print $row[hpower]?>'></td></tr>
<tr><td>Fuel Used </td><td><input type=text name='fuel' size=40 value='<?print $row[fuel]?>'></td></tr>
<tr><td>No.of Cylinders </td><td><input type=text name='cyl' size=40 value='<?print $row[cyl]?>'></td></tr>
<tr><td>Seating Capacity </td><td><input type=text name='capa' size=40 value='<?print $row[capa]?>'></td></tr>
<tr><td>Unladen Weight </td><td><input type=text name='uweight' size=40 value='<?print $row[uweight]?>'></td></tr>
<tr><td>Front axle </td><td><input type=text name='axlefr' size=40 value='<?print $row[axlefr]?>'></td></tr>
<tr><td>Rear axle </td><td><input type=text name='axlerr' size=40 value='<?print $row[axlerr]?>'></td></tr>
<tr><td>Any othe axle </td><td><input type=text name='axleoth' size=40 value='<?print $row[axleoth]?>'></td></tr>
<tr><td>Tandem axle</td><td><input type=text name='axletan' size=40 value='<?print $row[axletan]?>'></td></tr>
<tr><td>Colour of Body </td><td><input type=text name='cbody' size=40 value='<?print $row[cbody]?>'></td></tr>
<tr><td>Type of Body </td><td><input type=text name='tbody' size=40 value='<?print $row[tbody]?>'></td></tr>
<tr><td>Active </td><td><input type=text name='active' size=1 value='<?print $row[active]?>'></td></tr>

<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME='edit' VALUE='  SAVE  '></TD></TR>

</table>
</td></tr>
</table>
</FORM>
<SCRIPT>
function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
}
</script>
