
<?php
	if($_SESSION['p']==1) {
		    $_SESSION['machine_name'] = $_GET['machine_name_text'];
	}
	$table_name = $_SESSION['db_prefix']."_machinery";
	$query = "SELECT machine_name FROM $table_name WHERE machine_name = '". $_SESSION['machine_name']."' " ;
	$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="machineryWizbase.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="machineryWizbase.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><input type="text" name="make_text" id="make_text" class="text200" value="<?php echo $_SESSION['make'] ?>"></td>
                  </tr>
                </table>
              </div>
            
              <div class="wizard_frame">
                <table width="630" id="table_wizard_frame">
                  <tr>
                    <td width="99">Model:&nbsp;&nbsp;
                    <label class="star">*</label></td>
                    <td><input type="text" name="model_text" id="model_text" class="text200"  value="<?php echo $_SESSION['model'] ?>"></td>
                  </tr>
                </table>
              </div>
              
              <div class="wizard_frame">
                <table width="630" id="table_wizard_frame">
                  <tr>
                    <td width="99">Company: 
                      <label class="star">*</label></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>
                  <tr>
                    <td>In service: 
                      <label class="star">*</label></td>
                    <td><select name="in_service_select" id="in_service_select">
                      <option value="no">no</option>
                      <option value="yes">yes</option>
                      <option value="<?php echo $_SESSION['in_service'] ?>" selected="selected"><?php echo $_SESSION['in_service'] ?></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','machineryWizbase.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_text","req","- make.");
  frmvalidator.addValidation("model_text","req","- model.");
  frmvalidator.addValidation("department_select","req","- company.");
  frmvalidator.addValidation("in_service_select","req","- in service.");
  </script>
<?php
	}
	?>
</body>
