<?php 
if ($_SESSION['subCategory'] == "Fuel" ) { ?>
       <script type="text/javascript">
	      function toggle1()  {
	        document.getElementById('directContainer').style.display = 'none';
	        document.getElementById('dieselContainer').style.display = 'block';
		  }
	   </script> 
	  <?php   } 
	else { ?>
	   <script type="text/javascript">
	      function toggle1()  {
			document.getElementById('directContainer').style.display = 'block';
	        document.getElementById('dieselContainer').style.display = 'none';
		  }
	    </script> 
<?php }  ?>
	

<?php 
if ($_SESSION['issued_to'] == "employee" ) { ?>
<script type="text/javascript">
     function toggle2()  {
			document.getElementById('employeeContainer').style.display = 'block';
	 }
</script> 
<?php } ?>

<?php 
if ($_SESSION['issued_to'] == "representative" ) { ?>
<script type="text/javascript">
     function toggle2()  {
			document.getElementById('repContainer').style.display = 'block';
	 }
</script> 
<?php } ?>

<?php 
if ($_SESSION['issued_to'] == "department" ) { ?>
<script type="text/javascript">
     function toggle2()  {
			document.getElementById('departmentContainer').style.display = 'block';
	 }
</script> 
<?php } ?>

<?php 
if ($_SESSION['category'] == "Store Item" ) { ?>
<script type="text/javascript">
    function toggle() {
         document.getElementById('directContainer').style.display = 'block';
	     document.getElementById('dieselContainer').style.display = 'none';       
           }
	 
</script> 
<?php  } ?>

<?php
//department select box
$department = file('../include/department.txt');
$options = '';
foreach ($department as $department) {
    $options .= '<option value="'.$department.'">'.$department.'</option>';
}
$department_select = '<select name="department_select" class="wizard1"> <option selected="selected">'. $_SESSION['department'].'</option> '.$options.'</select>';  
?>


<script language="JavaScript">
    function change1() {
                document.getElementById('employeeContainer').style.display = 'block';
				document.getElementById('repContainer').style.display = 'none';
				document.getElementById('departmentContainer').style.display = 'none';
           }
		
	function change2() {
                document.getElementById('employeeContainer').style.display = 'none';
				document.getElementById('repContainer').style.display = 'block';
			    document.getElementById('departmentContainer').style.display = 'none';
           }
    function change3() {
                document.getElementById('employeeContainer').style.display = 'none';
				document.getElementById('repContainer').style.display = 'none';
			    document.getElementById('departmentContainer').style.display = 'block';
           }
</script>



<?php
$dropDownQuery = "SELECT account_no, name FROM nam_rad_tocotex  ORDER BY name ASC";
	$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$q = 0;
	$arrId = array ();
	$arrName = array ();
	while ($q < $num) {
		$arrId[$q] = mysql_result($dropDownResult, $q, "account_no");
		$arrName[$q] = mysql_result($dropDownResult, $q, "name");
		$q++;
	}
	
	$repQuery = "SELECT repId, first_name, last_name FROM nam_rad_representatives  ORDER BY first_name ASC";
	$repResult = execsql($repQuery);
	$repNum = mysql_num_rows($repResult);
	$r = 0;
	$arr2Id = array ();
	$arr2Name = array ();
	while ($r < $repNum) {
		$arr2Id[$r] = mysql_result($repResult, $r, "repId");
		$arr2Name[$r] = mysql_result($repResult, $r, "first_name")." ".mysql_result($repResult, $r, "last_name");
		$r++;
	}
	
	$empQuery = "SELECT  empId, empFName, empLName FROM nam_employees  ORDER BY empFName ASC";
	$empResult = execsql($empQuery);
	$empNum = mysql_num_rows($empResult);
	$s = 0;
	$arr3Id = array ();
	$arr3Name = array ();
	while ($s < $empNum) {
		$arr3Id[$s] =  mysql_result($empResult, $s, "empId");
		$arr3Name[$s] = mysql_result($empResult, $s, "empFName")." ".mysql_result($empResult, $s, "empLName");
		$s++;
	}
	
	$vehQuery = "SELECT  reg_no FROM nam_vehicle  ORDER BY reg_no ASC";
	$vehResult = execsql($vehQuery);
	$vehNum = mysql_num_rows($vehResult);
	$t = 0;
	$arr4Id = array ();
	$arr4Name = array ();
	while ($t < $vehNum) {
		$arr4Id[$t] =  mysql_result($vehResult, $t, "reg_no");
		$arr4Name[$t] = mysql_result($vehResult, $t, "reg_no");
		$t++;
	}
?>

          
</script>

<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<!--form validation-->
<script language="javascript" type="text/javascript" >
<!--
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to cancel this entry?");
var url='showAllProducts.php?cat=Tiles and Accessories&productSelect=All&colorSelect=All'
if (okToRefresh)
	{
			window.location=url;
	}
}
// -->
</script>
<script language="JavaScript">
  var needToConfirm = true;
  window.onbeforeunload = confirmExit;
   function confirmExit()
  {
    if (needToConfirm)
      return "You did not finish the wizard./nIf you leave now your data will not be saved.";
  }
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>

<script language="Javascript">
       <!--
       function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;
 
          return true;
       }
       //-->
    </script>
  
    
<body onLoad="toggle1(); <?php if ($_SESSION['issued_to'] =="employee") { 
					echo "change1()";
					} ?>
                    <?php if ($_SESSION['issued_to'] =="representative") { 
					echo "change2()";
					} ?>
                    <?php if ($_SESSION['issued_to'] =="department") { 
					echo "change3()";
					} ?>">
    
<form id="feedbackform" method="get" action="issueWizbase.php"> 
  <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
    <tr>
      <td width="525" ><p class="wizard"><label class="std">Issued for:</label>
          <select name="companySelect" id="companySelect"  class="wizard3">
            <option value="<?php echo $_SESSION['account_no'] ?>"><?php echo $_SESSION['companyName']?></option>
            <?php
    	for ($i = 0; $i < count($arrId); $i++) 
		  {
			echo "<option value=".$arrId[$i]. ">" . $arrName[$i] . "</option>";	
	    }
     ?>
          </select>
          <label class="star">*</label>
</p>
      <div id='directContainer' class='directContainer'>
  <br>
<br>
    
        <p class="wizard" >
          <label>
<input type="radio" name="issued_to_group" value="employee" id="issued_to_group_0" onChange="change1();" <?php if ($_SESSION['issued_to'] == "employee") { echo "checked=checked";}?>  >
employee</label>
          <label>
<input type="radio" name="issued_to_group" value="representative" id="issued_to_group_1" onChange="change2();" <?php if ($_SESSION['issued_to'] == "representative") { echo "checked=checked";}?>  >
representative</label>
          
          <label>
<input type="radio" name="issued_to_group" value="department" id="issued_to_group_2" onChange="change3();" <?php if ($_SESSION['issued_to'] == "department") { echo "checked=checked";}?>  >
department</label>
          &nbsp;&nbsp;
          <label class="star">*</label>
        </p>
     
        <div id="repContainer">
        <p class="wizard" >
        representative: &nbsp;
        <select name="repSelect" id="repSelect"  class="wizard3">
          <option value="<?php echo $_SESSION['repId'] ?>"><?php echo $_SESSION['rep']?></option>
          <?php
    	for ($i = 0; $i < count($arr2Id); $i++) {
			echo "<option value=".$arr2Id[$i]. ">" . $arr2Name[$i] . "</option>";	
	    }
     ?>
        </select>&nbsp;&nbsp;<label class="star">*</label>
        </p>
        </div>
         <div id="employeeContainer">
         <p class="wizard" >
        employee: &nbsp;
          <select name="empSelect" id="empSelect"  class="wizard3"> 
            <option value="<?php echo $_SESSION['empId'] ?>"><?php echo $_SESSION['employee']?></option>
            <?php
    	for ($s = 0; $s < count($arr3Id); $s++) {
			echo "<option value=".$arr3Id[$s]. ">" . $arr3Name[$s] . "</option>";	
	    }
     ?>
          </select>&nbsp;&nbsp;<label class="star">*</label>
        </p>  </div>
       <div id="departmentContainer">
       <p class="wizard" >
        department: &nbsp;<span class="wizard"><?php echo $department_select ?></span>&nbsp;&nbsp;<label class="star">*</label></div> 
       
       </div>
        </div>
        
        <div  id="dieselContainer" class="dieselContainer">
        <p class="wizard"> <label class="std">Issued to reg.no.:</label>
          <select name="regNoSelect" id="regNoSelect" class="wizard3">
            <option value="<?php echo $_SESSION['regNo'] ?>"><?php echo $_SESSION['regNo']?></option>
            <?php
    	for ($t = 0; $t < count($arr4Id); $t++) {
			echo "<option value=".$arr4Id[$t]. ">" . $arr4Name[$t] . "</option>";	
	    }
     ?>
          </select>
        
          <label class="star">*</label>
        </p>
        <p class="wizard"><label class="std">Mileage: </label>
          <input type="text" name="mileageText" id="mileageText" class="wizard1" value="<?php echo $_SESSION['mileage'] ?>"/>
          <label class="star">*</label>
<label class="std">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;driver:</label> 
        <select name="driverSelect" id="driverSelect"  class="wizard3">
          <option value="<?php echo $_SESSION['repId'] ?>" selected><?php echo $_SESSION['driver']?></option>
          <?php
    	for ($i = 0; $i < count($arr2Id); $i++) {
			echo "<option value=".$arr2Id[$i]. ">" . $arr2Name[$i] . "</option>";	
	    }
     ?>
        </select>
        
          <label class="star">*</label>
        </p>
        </div>
        <p class="wizard">
          <label class="left">Notes:</label>
            <textarea name="notesText" rows="3" class="wizard1" id="notesText"  style="width:400px;height:40px"  ><?php echo $_SESSION['notes'] ?></textarea>
          
        </p></td>
    </tr>
    <tr>
      <td><table width="590" height="50" align="center" id="tableButtonBar">
          <tr>
            <td width="117"><input type="submit" name="prev_button" id="prev_button" class="imagebutton" value="Prev" onClick=" needToConfirm = false; " /></td>
            <td width="115"><span class="wizard">
              <input name="s" type="hidden" id="s" value="3" />
              <input name="p" type="hidden" id="p" value="3" />
            </span></td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; confirmRefresh();" value="Cancel" /></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; " /></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  
  <?php  if ($_SESSION['subCategory']=="Fuel") { ?>
     frmvalidator.addValidation("regNoSelect","req","Please select registration number.");
     frmvalidator.addValidation("mileageText","req","Please enter mileage.");
     frmvalidator.addValidation("driverSelect","req","Please select driver.");
  <?php } else { ?>
    
    frmvalidator.addValidation("companySelect","req","Please enter company.");
    frmvalidator.addValidation("issued_to_group","selone","Please select issued to.");
	
	frmvalidator.addValidation("empSelect","req","Please select employee.",
        "VWZ_IsChecked(document.forms['feedbackform'].elements['issued_to_group'],'employee')");
	
	frmvalidator.addValidation("repSelect","req","Please select representative.",
        "VWZ_IsChecked(document.forms['feedbackform'].elements['issued_to_group'],'representative')");
	
	frmvalidator.addValidation("department_select","req","Please select department.",
        "VWZ_IsChecked(document.forms['feedbackform'].elements['issued_to_group'],'department')");
	
	//if(document.myform.operation['issued_to_group_0'].checked == true) {	
   //       frmvalidator.addValidation("empSelect","req","Please select employee.");
	//}
	//if(document.myform.operation['issued_to_group_1'].checked == true) {
//		  frmvalidator.addValidation("repSelect","req","Please select representative.");
//	}
//	if(document.myform.operation['issued_to_group_2'].checked == true) {
//          frmvalidator.addValidation("departmentSelect","req","Please select department.");
//	}
    
    
	<?php } ?>
</script>

</body>