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

$progressQuery = "SELECT productId FROM nam_products WHERE category = '". $_SESSION['store']."' AND stockTake = 'P' ORDER BY productName ASC ";
$progressResult = execsql($progressQuery);
$progressNum = mysql_num_rows($progressResult);

$countQuery = "SELECT productId FROM nam_products WHERE category = '". $_SESSION['store']."'  ORDER BY productName ASC ";
$countResult = execsql($countQuery);
$countNum = mysql_num_rows($countResult);

?>


<link rel="stylesheet" type="text/css" href="../css/wizard.css" />

<script>
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to stop?\n\nYou can stop and restart the count later.");
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 stockcount.";
  }
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;
       }
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>



  <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">
          <?php if ($countNum != $progressNum) {  ?>
          <img src="../img/warning.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 prepare the stock list for a new stock count by clicking the prepare button and wait for confirmation that the list is prepared. <?php } else { ?>
        To do a stock take, the stock list for <?php echo $_SESSION['store'] ?> needs to be prepared.<br /><br />

Click the "Prepare" button and wait for confirmation that the list is prepared. </label> <?php } ?>     
      </p>
      <form id="form1" name="form1" method="get" action="stockCountWizbase.php">
      <p class="wizard">
        <label class="std">To prepare the list for <?php echo $_SESSION['store'] ?>, click:</label>
      &nbsp;&nbsp;&nbsp;
      <input name="prepareButton" type="submit" class="imagebutton" id="prepareButton" onclick="needToConfirm = false; " value="Prepare" />
      <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'] ?>" />
      </p>
      </form>
      <p class="wizard">
        <label class="std"><img src="../img/Info_Box_Blue.png" width="32" height="32" /><?php echo $_SESSION['message1'] ?></label>
</p></td>
    </tr>
    <tr>
      <td><table width="590" height="50" align="center" id="tableButtonBar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115">&nbsp;</td>
            <td width="99"><span class="wizard">
              <input name="error" type="hidden" id="error" value="0" />
            </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="button" name="next_button" class="imagebutton" value="Next" onclick="needToConfirm = false; MM_goToURL('parent','stockCountWizbase.php?p=3&s=3&c=2');return document.MM_returnValue" /></td>
          </tr>
        </table></td>
    </tr>
  </table>

<!--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("priceText","req","Please enter the price.");
  </script>
