<head>

<?php
include('../include/session.php'); 
$show = $_GET['show'];
$today = date("Y-m-d");

if ($show==0) {
$table_name = $_SESSION['db_prefix']."_stockloss";
$stock_date_query = "SELECT stockId, date FROM $table_name WHERE category = 'Production' ORDER BY date DESC";
$stock_date_result = mySQL_query($stock_date_query);
$stock_date_num = mysql_num_rows($stock_date_result);
}

if ($show==1) {
$table_name = $_SESSION['db_prefix']."_store_items";
$item_query = "SELECT store_item_id, item_name, category, subCategory, unit, minimumStock FROM $table_name WHERE category = 'Production' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);
}


?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/main.css" />

<!--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/alert_message.js"  type="text/javascript"></script>

</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');">

<?php 
if ($show==0) { ?>
<div class="page_middle_frame">
Select stock count date.
</div>
<?php } ?>

<?php 
if ($show==1) { ?>
<div class="page_middle_frame">
<form name="form1" id="form1" action="stockCountWiz4_save.php" method="get">
<table width="525" id="dataTable">
  <thead>
  <tr>
    <td width="305">Item</td>
    <td width="76">Unit</td>
    <td width="88">Counted qty</td>
    <td width="36">&nbsp;</td>
  </tr>
  </thead>
  <?php
  $i=0;
  while ($i<$item_num) {
	  $store_item_id = mysql_result($item_result, $i, "store_item_id");
	  $item = mysql_result($item_result, $i, "item_name");
	  $category = mysql_result($item_result, $i, "category");
	  $subCategory = mysql_result($item_result, $i, "subCategory");	  
	  $unit = mysql_result($item_result, $i, "unit");
	?>
  <tr>
    <td><?php echo $item ?>
        <input name="item_name_text<?php echo $i ?>" id="item_name_text<?php echo $i ?>" type="hidden" value="<?php echo $item ?>">
        <input name="store_item_id_text<?php echo $i ?>" type="hidden" value="<?php echo $store_item_id ?>">
        <input name="category_text<?php echo $i ?>" type="hidden" value="<?php echo $category ?>">
        <input name="subCategory_text<?php echo $i ?>" type="hidden" value="<?php echo $subCategory ?>">
    </td>
    <td><?php echo $unit ?></td>
    <td align="center"><input type="text" name="counted_qty_text<?php echo $i ?>" id="counted_qty_text<?php echo $i ?>" class="text60"   onkeypress="return numbersonly(this, event)" style="text-align:right" autocomplete="off"></td>
    <td>&nbsp;</td>
  </tr>
  <?php
  $i++;
  }
  ?>
</table>
<br>
<br>

 <div class="page_inside_frame">
      <table width="645" border="0">
        <tr>
          <td width="405"><div align="left"> <img src="../images/info_blue.png" width="16" height="16">
            <label class="label_info">Quantity for all items need to be entered before saving.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Only one stock count per day can be done.</label>
          </div></td>
          <td width="230" align="right">
            <input name="line_num" id="line_num" type="hidden" value="<?php echo $item_num ?>">
            <input name="button2" type="button" class="imagebutton" id="button2" onClick="cancel_confirmation(3, '../store/store_main.php');" value="Close"/>
            <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onClick="needToConfirm = false; " /></td>
        </tr>
      </table>
    </div> 
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
     
  for (i = 0; i < 150; i++) {
	frmvalidator.addValidation("counted_qty_text"+i,"req","- qty for "+document.getElementById('item_name_text'+i).value+".");
  }
  </script>   
</div>
<?php } ?>

</body>