<head>

<?php
if ($_SESSION['category']=='Production') {

$table_name = $_SESSION['db_prefix']."_store_items";
$progressQuery = "SELECT store_item_id FROM $table_name WHERE category = '".$_SESSION['category']."' AND stockTake = 'P' ORDER BY item_name";
$progressResult = execsql($progressQuery);
$progressNum = mysql_num_rows($progressResult);

$countQuery = "SELECT store_item_id FROM $table_name WHERE category = '".$_SESSION['category']."'   ORDER BY item_name ASC";
$countResult = execsql($countQuery);
$countNum = mysql_num_rows($countResult);
}
else {

$table_name = $_SESSION['db_prefix']."_store_items";
$progressQuery = "SELECT store_item_id FROM $table_name WHERE category = '".$_SESSION['category']."' AND subCategory = '". $_SESSION['subCategory']."' AND stockTake = 'P' ORDER BY item_name";
$progressResult = execsql($progressQuery);
$progressNum = mysql_num_rows($progressResult);

$countQuery = "SELECT store_item_id FROM $table_name WHERE category = '".$_SESSION['category']."' AND subCategory = '". $_SESSION['subCategory']."'  ORDER BY item_name ASC";
$countResult = execsql($countQuery);
$countNum = mysql_num_rows($countResult);
}

?>


</head>
<?php include('../include/wait.php') ?>
<link href="../css/wait.css" rel="stylesheet" type="text/css">

<body onLoad="MM_showHideLayers<?php if ($_SESSION['finished'] =="0") { ?>('info_frame','','show','ok_frame','','hide','wait','','hide') <?php  } else { ?> ('info_frame','','hide','ok_frame','','show','wait','','hide'); <?php } ?>" onFocus="MM_showHideLayers('wait','','hide');" >
<div class="page_middle_frame">
<label class="label_std">
      <?php if ($countNum != $progressNum) {  ?>
      <div class="wizard_frame"> <img src="../images/exclamation_mark_blue.png" width="32" height="32" /> There is a stock count in progress.<br />
        <br />
        &nbsp; If you want to complete this stock count click 'Next', otherwise refrsh the stock list for a new stock count by clicking the 'Restart count' button and wait for confirmation that the list is prepared. <br>
<br>

       <form id="form1" name="form1" method="get" action="stockCountWizbase.php">
        
          <label class="std">
            To refresh the list and re-start the count for <?php echo $_SESSION['subCategory'] ?>, click:</label>
          &nbsp;&nbsp;&nbsp;
          <input name="prepareButton" type="submit" class="imagebutton" id="prepareButton" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" value="Restart count" tabindex="1"/>
          <input name="s" type="hidden" id="s" value="2" />
          <input name="p" type="hidden" id="p" value="2" />
          <input name="prepare" type="hidden" id="prepare" value="yes" />
          <input name="category" type="hidden" id="category" value="<?php echo $_SESSION['store'] ?>" />
        
</form> 
        </div>
      <br />
      <?php } ?>
      
      <br />
      <br />
       <?php if ($countNum == $progressNum) {  ?>
      <form id="form1" name="form1" method="get" action="stockCountWizbase.php">
        <div class="wizard_frame" id="info_frame">
          <label class="std"><img src="../images/info_blue.png" width="32" height="32">List is not prepared yet.<br>
To prepare the list for "<?php if ($_SESSION['category']=='Production') { echo 'Production materials'; } else { echo $_SESSION['subCategory'];} ?>", click:</label>
          &nbsp;&nbsp;&nbsp;
          <input name="prepareButton" type="submit" class="imagebutton" id="prepareButton" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" value="Prepare" tabindex="1"/>
          <input name="s" type="hidden" id="s" value="2" />
          <input name="p" type="hidden" id="p" value="2" />
          <input name="prepare" type="hidden" id="prepare" value="yes" />
          <input name="category" type="hidden" id="category" value="<?php echo $_SESSION['store'] ?>" />
        </div>
</form>  
<?php } ?>     
      <div class="wizard_frame" id="ok_frame"><img src="../images/check_mark_blue.png" width="32" height="32" /><?php echo $_SESSION['message1'] ?></div>
<div class="wizard_frame" align="right" >
            <input name="error" type="hidden" id="error" value="0" />
            <input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(2, '../store/store_main.php?date=0&subCatSelect=Tiles')" value="Stop" />
            <input type="button" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false;  MM_showHideLayers('wait','','show'); MM_goToURL('parent','stockCountWizbase.php?p=3&s=3&c=2');return document.MM_returnValue;" tabindex="2"/>
            </div>
      
</div>
<!--form validation-->
</body>
