<link rel="stylesheet" type="text/css" href="../css/jquery.autocomplete.css" />
<script type="text/javascript" src="../css/jquery.1.4.2.js"></script>
<script type="text/javascript" src="../css/jquery.autocomplete.js"></script>

<?php
include('../include/formValidations.php');
$cat=$_SESSION['store'];
$sub_cat=$_SESSION['sub_cat'];
if ($cat=="Tiles and Accessories") { 
$dropDownQuery = "SELECT productId, productName FROM products WHERE category ='$cat' AND isRemoved = '0' AND subCategory <> 'Old' ORDER BY productName ASC";
}
if ($cat=="Direct Materials") { 
$dropDownQuery = "SELECT productId, productName FROM products WHERE category ='$cat' AND isRemoved = '0' AND subCategory <> 'Old' ORDER BY productName ASC";
}
if ($cat=="Store Item") {
       $dropDownQuery = "SELECT productId, productName FROM products WHERE category ='$cat' AND subCategory = '$sub_cat' AND isRemoved = '0' AND subCategory <> 'Old' ORDER BY productName ASC";
}


$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$a = 0;
	$arrId = array ();
	$arrName = array ();
	while ($a < $num) {
		$arrId[$a] = mysql_result($dropDownResult, $a, "productId");
		$arrName[$a] = mysql_result($dropDownResult, $a, "productName");
		$a++;
	}

?>




<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<script>
 $(document).ready(function(){
  $("#productName_text").autocomplete("store_autocomplete.php", {
        selectFirst: true
  });
 });
</script>
<script>
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>


<form id="form1" name="form1" method="get" action="returnWizbase.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"> Select product to be returned:&nbsp;&nbsp;&nbsp; </label>
        <select name="productText" id="productText" class="wizard3" >
          <option value="<?php echo $_SESSION['productId']?>" > <selected="selected">  <?php echo $_SESSION['productName']?></option>
          <?php
    	for ($i = 0; $i < count($arrId); $i++) {
		echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] . "</option>";
		$_SESSION['productName'] = $arrName[$i];
		//foreach($arrId as $key=>$value){
			//echo "<option value=\"delivery.php?productId=".$arrId[$i]."&cat=$cat&formEnabled2=1&date=$date" . "\"" . ">" . $arrName[$i] . "</option>";	
	    }
     ?>
        </select>
        &nbsp;
        <label class="star">*</label>
        <br />
          <br />
          <label class="std">Quantity:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="text" class="wizard2" name="quantityText" id="quantityText" value="<?php echo $_SESSION['quantity']?>" onkeypress="return numbersonly(this, event)"/>
          &nbsp;
          <label class="star">*</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label class="std">Products to be returned to stock?&nbsp;&nbsp;&nbsp; </label>
          <select name="returnSelect" id="returnSelect" class="wizard2">
            <option value="yes">yes</option>
            <option value="no">no</option>
            <option value="<?php echo $_SESSION['retStock'] ?>" selected="selected"><?php echo $_SESSION['retStock'] ?></option>
          </select>
      &nbsp;
      <label class="star">*</label>
      </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">&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; confirmRefresh();" value="Cancel" /></td>
            <td width="110" align="left"><input type="submit" name="next_button" class="imagebutton" value="Next" onclick="needToConfirm = false; " /></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
<!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("productText","req","Please select a product.");
  frmvalidator.addValidation("quantityText","req","Please enter the quantity.");
  frmvalidator.addValidation("returnSelect","req","Please indicate to return to stock.");
  </script>
