<head>
<?php

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

$table_name = $_SESSION['db_prefix']."_store_items";
if ($_SESSION['subCategory']=="Timber") {
$dropDownQuery = "SELECT store_item_id, item_name, unit FROM $table_name WHERE category= '".$_SESSION['category']."' AND subCategory = '".$_SESSION['subCategory']."' ORDER BY depth, width, class, length ASC";

}
else { 
$dropDownQuery = "SELECT store_item_id, item_name, unit FROM $table_name WHERE category= '".$_SESSION['category']."' AND subCategory = '".$_SESSION['subCategory']."' and branch = '".$_SESSION['userbranch']."' ORDER BY item_name ASC";
}
$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$a = 0;
	$arrId = array ();
	$arrName = array ();
	while ($a < $num) {
		$arrId[$a] = mysql_result($dropDownResult, $a, "store_item_id");
		$arrName[$a] = mysql_result($dropDownResult, $a, "item_name");
		$arrUnit[$a] = mysql_result($dropDownResult, $a, "unit");
		
		$a++;
	}

?>

<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/go_to_URL.js"  type="text/javascript"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<!--reference to main.css removed-->
<link href="../css/wizard.css" rel="stylesheet" type="text/css" />
<style type="text/css">
select.store_item_select {
	width: 230px;
}
</style>
</head>
<?php include('../include/wait.php') ?>
<link href="../css/wait.css" rel="stylesheet" type="text/css">
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame" style="position:relative;">
<form id="form1" name="form1" method="get" action="deliverWizbase.php"> 
  <div class="wizard_frame">
          Selected category:&nbsp;&nbsp;<?php echo $_SESSION['subCategory']; ?><br>
<br>

          <label class="label_std"> Select product to deliver:&nbsp;&nbsp;&nbsp; </label>
          <select  name="store_item_select" class="selectbox300" id="store_item_select" style="width:250px;" autofocus   onchange="document.getElementById('unit_text').value = (document.getElementById('store_item_select').options[document.getElementById('store_item_select').selectedIndex].text).slice(-5) ">
            <option value=" " selected="selected"> </option>
            <?php
    	for ($i = 0; $i < count($arrId); $i++) {
		echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] ."&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;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;". $arrUnit[$i]." </option>";
		$_SESSION['productName'] = $arrName[$i];
		
	    }
     ?>
          </select>
          &nbsp;
          <label class="star">*</label>
          <br />
          <br />
          <label class="label_std">Quantity:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="text" class="text60" name="quantityText" id="quantityText" value="<?php echo $_SESSION['quantity']?>" onKeyPress="return numbersonly(this, event)" style="text-align:right"/>
          &nbsp;
          <input name="unit_text" type="text" id="unit_text" size="4"  style="border:hidden; background-color:transparent;" />
          <label class="star">* </label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label class="label_std">Order no.:</label>
          &nbsp;&nbsp;&nbsp;
          <input name="order_text" type="text" class="text100" onKeyPress="return numbersonly(this, event)" />
          <br />
          <br />
          <table width="500" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="97"><label class="label_std">Deliver  date:</label></td>
              <td width="403"><?php

		$myCalendar = new tc_calendar("deliver_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?></td>
            </tr>
          </table>
          
        </div>
<div class="button_bar_frame" style="margin-top:125px;" >    
    <table width="590" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; MM_goToURL('parent','deliverWizbase.php?s=&p=1');return document.MM_returnValue; MM_showHideLayers('wait','','show');"  tabindex="-1"/></td>
            <td width="115">&nbsp;</td>
            <td width="99"><span class="wizard">
              <input name="error" type="hidden" id="error" value="0" />
              <input name="p" type="hidden" id="p" value="2" />
              <input name="s" type="hidden" id="s" value="2" />
              </span></td>
            <td width="125" align="left"><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" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
          </tr>
        </table>
        </div>
</form>
</div>
<!--form validation--> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("store_item_select","req","Please select a product.");
  frmvalidator.addValidation("quantityText","req","Please enter the quantity.");
  frmvalidator.addValidation("priceText","req","Please enter the price.");
  </script> 
