

<?php
require_once ('../include/tc_calendar.php');
$start = strtotime($_SESSION['issue_date']);
$d = date("d", $start );
$m = date("m", $start );
$y = date("Y", $start );


$table_name = $_SESSION['db_prefix']."_list_approve_names";
    $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_names_store";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId3[$b] = mysql_result($position_result, $b, "item_name");
		$arrName3[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
?>

<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>


<script>
function clear_list() {
	
	document.getElementById('list_a').selectedIndex=0;
	document.getElementById('list_a').options[document.getElementById('list_a').selectedIndex].text='';
	
	document.getElementById('list_b').selectedIndex=0;
	document.getElementById('list_b').options[document.getElementById('list_b').selectedIndex].text='';
	
	document.getElementById('list_c').selectedIndex=0;
	document.getElementById('list_c').options[document.getElementById('list_c').selectedIndex].text='';
	
	document.getElementById('list_d').selectedIndex=0;
	document.getElementById('list_d').options[document.getElementById('list_d').selectedIndex].text='';
	//alert('yes');
}
</script>

<script>
function page_select() {
	var product_group = '';
	
	product_group = document.getElementById('store_list_select').value;
	
	
	document.getElementById('list_a').hidden=true;
	document.getElementById('list_b').hidden=true;
	document.getElementById('list_c').hidden=true;
	document.getElementById('list_d').hidden=true;
	
	
	if (product_group=='Cleaning materials') {document.getElementById('list_a').hidden=false; document.getElementById('l').value='a' }
	if (product_group=='Consumables') {document.getElementById('list_a').hidden=false; document.getElementById('l').value='a' }
	if (product_group=='Fuel') {document.getElementById('list_d').hidden=false; document.getElementById('l').value='d' }
	if (product_group=='Lubricants') {document.getElementById('list_b').hidden=false; document.getElementById('l').value='b' }
	if (product_group=='Machine spares') {document.getElementById('list_c').hidden=false; document.getElementById('l').value='c' }
	if (product_group=='Motor spares') {document.getElementById('list_b').hidden=false; document.getElementById('l').value='b' }
	if (product_group=='Vortex Hydra spares') {document.getElementById('list_c').hidden=false; document.getElementById('l').value='c' }
	if (product_group=='PPE') {document.getElementById('list_a').hidden=false; document.getElementById('l').value='a' }
	if (product_group=='Tools') {document.getElementById('list_a').hidden=false; document.getElementById('l').value='a' }
	if (product_group=='Welding and Engineering') {document.getElementById('list_b').hidden=false; document.getElementById('l').value='b' }

}

</script>



</head>

<?php 
$page_name = "Stores-department supply";
include ("../navigation/access.php");

if ($permission_num==1) {
	 
	?>

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

<body onLoad="document.getElementById('list_<?php echo $_SESSION['l'] ?>').hidden=false; document.getElementById('l').value='<?php echo $_SESSION['l'] ?>'; MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame" style="min-height:240px;">
<form id="form1" method="get" action="supply_internalWizbase.php">
  <div class="wizard_frame">
      
        <label class="label_std" >Supply from stores group:&nbsp;&nbsp;</label>
        <label class="star">*</label>
        <select name="store_list_select" class="select200" id="store_list_select" onChange="page_select()" onFocus="clear_list();" >
          <option value="Cleaning materials">Cleaning materials</option>
          <option value="Consumables">Consumables</option>
          <option value="Fuel">Fuel</option>
          <option value="Lubricants">Lubricants</option>
          <option value="Machine spares">Machine spares</option>
          <option value="Motor spares">Motor spares</option>
          <option value="Vortex Hydra spares">Vortex Hydra spares</option>
          <option value="PPE">PPE</option>
          <option value="Tools">Tools</option>
          <option value="Welding and Engineering">Welding and Engineering</option>
          <option value="<?php echo $_SESSION['stores_group'] ?>" selected="selected"><?php echo $_SESSION['stores_group'] ?></option>
        </select>
        <br>
<br>
      Supply to:&nbsp;&nbsp;&nbsp;
      <label class="star">*</label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <select name="list_a" id="list_a" hidden="hidden;"  class="select200" onChange="sub_page_select()">
          <option value="<?php echo $_SESSION['supply_group'] ?>" selected="selected"><?php echo $_SESSION['supply_group'] ?></option>
          <option value="employee">Employee</option>
          <option value="department">Department</option>
          <option value="company">Company</option>
      </select>
        <select name="list_b" id="list_b" hidden="hidden;"  class="select200">
          <option value="<?php echo $_SESSION['supply_group'] ?>" selected="selected"><?php echo $_SESSION['supply_group'] ?></option>
          <option value="vehicle">Vehicle</option>
          <option value="machinery">Machinery</option>
        </select>
        <select name="list_c" id="list_c" hidden="hidden;"  class="select200">
          <option value="<?php echo $_SESSION['supply_group'] ?>" selected="selected"><?php echo $_SESSION['supply_group'] ?></option>
          <option value="machinery">Machinery</option>
        </select>
        <select name="list_d" id="list_d" hidden="hidden;"  class="select200">
          <option value="<?php echo $_SESSION['supply_group'] ?>" selected="selected"><?php echo $_SESSION['supply_group'] ?></option>
          <option value="vehicle">Vehicle</option>
      </select>
     
  </div>
        <br />
        <br />
        
    <div class="wizard_frame">
    <table width="600" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="291"> Issued by:&nbsp;
          <label class="star">*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="issued_by_select" class="select120"  >
  <option value="<?php echo $_SESSION['issued_by'] ?>" selected="selected"><?php echo $_SESSION['issued_by'] ?></option>
  <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
</select>
          </label></td>
        <td>&nbsp;&nbsp;</td>
        <td>Authorised  by:&nbsp;
          <label class="star">*</label></td>
        <td width="144"><select name="authorised_by_select" class="select120"  >
          <option value="<?php echo $_SESSION['authorised_by']?>" selected="selected"><?php echo $_SESSION['authorised_by'] ?></option>
          <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
        </select></td>
      </tr>
  <tr>
    <td>&nbsp;</td>
    <td width="30">&nbsp;</td>
    <td width="135">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

    </div>    
     
    <div class="wizard_frame">
          <table width="500" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="97">Issue date:</td>
              <td width="403"><?php

		$myCalendar = new tc_calendar("issue_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2015, 2090);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?></td>
            </tr>
          </table>
    </div>
   
        <div class="wizard_frame">
        <table width="590" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115">
              <input name="s" type="hidden" id="s" value="1" />
              <input name="p" type="hidden" id="p" value="1" />
              <input name="l" type="hidden" id="l" value="" />
            </td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel"  tabindex="-1"/></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
          </tr>
        </table>
        </div>
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  //var list = 'list_a';
  if (document.getElementById('l').value=='a') {var list = 'list_a'; }
//  if (document.getElementById('l').value=='b') {list = 'list_b'; }
//  if (document.getElementById('l').value=='c') {list = 'list_c'; }
//  if (document.getElementById('l').value=='d') {list = 'list_d'; }
 
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("store_list_select","req","- store item group.");
  frmvalidator.addValidation(list,"req","- supply group.");
  frmvalidator.addValidation("issued_by_select","req","- issued by.");
  frmvalidator.addValidation("authorised_by_select","req","- authorised by.");
</script>

<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php?date=";	?>
	<body onLoad="needToConfirm = false; accessdenied(); return false">
</body>
<?php }
?>

<html>