
<?php
	if($_SESSION['p']==1) {
		    $_SESSION['registration_no'] = $_GET['reg_no_text'];
	}
	$table_name = $_SESSION['db_prefix']."_vehicle";
	$query = "SELECT registration_no FROM $table_name WHERE registration_no = '". $_SESSION['reg_no']."' " ;
	$result = mySQL_query($query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($result);
	if ($num!=0)
	{ 
	$_SESSION['error']=1;
	$_SESSION['p']=1;
	
	?>
<script language="javascript" type="text/javascript">
        <!--
		needToConfirm = false;
	 window.location="vehicleWizbase.php?s=0&p=1";
        -->
     </script>
<?php	
       }
    else{
$_SESSION['error']=0;	
require_once('../include/tc_calendar.php');
    $table_name = $_SESSION['db_prefix']."_list_vehicle_make";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_vehicle_model";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
		
	$table_name = $_SESSION['db_prefix']."_list_fuel";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId4 = array ();
	$arrName4 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$m = 0;
	while ($m < $position_num) {
		$arrId4[$m] = mysql_result($position_result, $m, "item_name");
		$arrName4[$m] = mysql_result($position_result, $m, "item_name");
		$m++;
	}
	}
	
		
	$table_name = $_SESSION['db_prefix']."_list_company";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId6 = array ();
	$arrName6 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$p = 0;
	while ($p < $position_num) {
		$arrId6[$p] = mysql_result($position_result, $p, "item_name");
		$arrName6[$p] = mysql_result($position_result, $p, "item_name");
		$p++;
	}
	}
?>

<?php include('../include/wait.php') ?>

</head>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame">
<form id="feedbackform" method="get" action="vehicleWizbase.php">
    <div class="wizard_frame">
             <table width="630" id="table_wizard_frame">
                  <tr>
                    <td width="99"><label class="label_std">Make:</label>
                      &nbsp;&nbsp;
                      <label class="star">*</label></td>
                    <td width="158"><select name="make_select" class="select120"  >
                        <option value="<?php echo $_SESSION['make'] ?>" selected="selected"><?php echo $_SESSION['make'] ?></option>
                        <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
                      </select></td>
                    <td width="137">Model:&nbsp;&nbsp;
                      <label class="star">*</label></td>
                    <td width="216"><select name="model_select" class="select120"  >
                        <option value="<?php echo $_SESSION['model'] ?>" selected="selected"><?php echo $_SESSION['model'] ?></option>
                        <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
                      </select></td>
                  </tr>
                </table>
              </div>
            
              <div class="wizard_frame">
                <table width="630" id="table_wizard_frame">
                  <tr>
                    <td width="99">Fuel:&nbsp;&nbsp;
                      <label class="star">*</label></td>
                    <td width="158"><select name="fuel_select" class="select120"  >
                      <option value="<?php echo $_SESSION['fuel'] ?>"><?php echo $_SESSION['fuel'] ?></option>
                      <option value="diesel">diesel</option>
                      <option value="petrol">petrol</option>
                      <option value="none">none</option>
                    </select></td>
                    <td>Average consumption: 1 liter on <label class="star">*</label><input type="text" name="average_text" id="average_text" class="text50"  onKeyPress="return isNumberKey(event)" onkeyup=" this.value = this.value.replace (/(\..).*/, '$1')" maxlength="4" style="text-align:right" value="<?php echo $_SESSION['average'] ?>"> km</td>
                  </tr>
                </table>
              </div>
              
              <div class="wizard_frame">
                <table width="630" id="table_wizard_frame">
                  <tr>
                    <td width="99">Company:</td>
                    <td><select name="department_select" class="select160"  >
                        <option value="<?php echo $_SESSION['department'] ?>" selected="selected"><?php echo $_SESSION['department'] ?></option>
                        <?php
        	for ($p = 0; $p < count($arrId6); $p++) {
    		echo "<option value=" . "\"" . $arrId6[$p] . "\"" . ">" . $arrName6[$p] . "</option>";
	}
?>
                      </select></td>
                  </tr>
                </table>
              </div>
 <div class="wizard_spacer_frame" style="height:80px;"></div>             
 <div class="wizard_frame">             
              <table width="645" height="50" align="center" id="tableButtonBar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); MM_goToURL('parent','vehicleWizbase.php?s=&amp;p=1');return document.MM_returnValue" /></td>
                  <td width="115">&nbsp;</td>
                  <td width="99"><input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                    </span></td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel" /></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); " /></td>
                </tr>
              </table>
</form>
</div>
<!--form validation--> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("make_select","req","- make.");
  frmvalidator.addValidation("model_select","req","- model.");
  frmvalidator.addValidation("fuel_select","req","- type of fuel.");
  frmvalidator.addValidation("average_text","req","- average consumption.");
  </script>
<?php
	}
	?>
</body>
