<?php
    $table_name = $_SESSION['db_prefix']."_store_items";
	$check_query = "SELECT item_name FROM $table_name WHERE  item_name = '".$_SESSION['item_name']."' " ;
	$check_result = $con->query($check_query);
	$check_num = mysqli_num_rows($check_result);
	if ($check_num!=0) { 
	$_SESSION['error']=1;
	$_SESSION['p']=2;
	

	?>
    
    <script language="javascript" type="text/javascript">
        <!--
	 needToConfirm = false;
	 window.location="storeWizbase.php?s=0&p=2";
        -->
     </script>

<?php	
       }
    else{
	
?>
</head>

<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">
<form id="feedbackform" method="get" action="storeWizbase.php">
  <table width=700 border="0" align="left" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
    <tr>
      <td width="525" >
      
      <?php if ($_SESSION['category'] == "Product" ) { ?>
      <div class="wizard_frame">
          <label class="label_std">Minimum stock:&nbsp;&nbsp;&nbsp;</label>
          <input class="text100" id="minimumStockText" name="minimumStockText"  value="<?php echo $_SESSION['minimumStock'] ?>" type="text" onKeyPress="return numbersonly(this, event)" autofocus style="text-align:right" autocomplete="off"/>
          
          <label class="star">*</label>
          <label class="label_std">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
            <br>
            &nbsp;Sales Price:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label>
          <input type="text" name="price_text" id="price_text" class="text100" style="text-align:right" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" value="<?php echo $_SESSION['price'] ?>" >
          <label class="star">*</label>
<input name="unit_group" type="hidden" value="no">
      &nbsp;&nbsp;&nbsp;&nbsp;
      </div>

        <?php }
		else {
		 ?>
      
   <div class="wizard_frame">
          <p>
            <label class="label_std">Minimum stock:&nbsp;&nbsp;&nbsp;</label>
            <input class="text100" id="minimumStockText" name="minimumStockText" value="<?php echo $_SESSION['minimumStock'] ?>" type="text" onKeyPress="return numbersonly(this, event)" style="text-align:right" autofocus autocomplete="off" />
            <label class="star">*</label>
            
          </p>
          <p>
            <label class="label_std">Cost  Price:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <input type="text" name="price_text" id="price_text" class="text100" style="text-align:right" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" value="<?php echo $_SESSION['price'] ?>" autocomplete="off">
            <label class="star">*</label>
            <input name="unit_group2" type="hidden" value="no">
&nbsp;&nbsp;&nbsp;&nbsp;
<label class="label_std">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label>

          </p>
   </div>
  <br /><br /><br />
  
 <?php 
 if ($_SESSION['subCategory'] == 'Ingredients') {
	 
	 $table_name = $_SESSION['db_prefix']."_ingredients";
    $position_query = "SELECT Code, Ingredients FROM $table_name ORDER BY Ingredients ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = $con->query($position_query);
	$position_num = mysqli_num_rows($position_result);
	$k = 0;
	while ($k < $position_num) {
	while($row = $position_result->fetch_assoc()) {
		$arrId3[$k] = $row["Code"];
		$arrName3[$k] = $row["Code"].'  '.$row["Ingredients"];
		$k++;
	}
	}
	 ?>
  <div class="wizard_frame">
 Ingredient reference:&nbsp;&nbsp;&nbsp;&nbsp;
<select name="ingredients_select" class="select200"  >
  <option value=" "> </option>
     <option value="" selected></option>
     <?php
        	for ($k = 0; $k < count($arrId3); $k++) {
    		echo "<option value=" . "\"" . $arrId3[$k] . "\"" . ">" . $arrName3[$k] . "</option>";
	}
?>
 </select>
  </div>
<?php
 }
 ?>
 
 
 <br /><br /><br />

        <div class="wizard_frame">
          <label class="label_std">Unit:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label class="label_std">
            <input type="radio" name="unit_group" value="no" id="unit_group_0" <?php if ($_SESSION['unit']=="no") { echo "checked='checked' " ;} ?> />
            no</label>
          <label class="label_std">
            <input type="radio" name="unit_group" value="kg" id="unit_group_1" <?php if ($_SESSION['unit']=="kg") { echo "checked='checked' " ;} ?> />
            kg</label>
          <label class="label_std">
            <input type="radio" name="unit_group" value="ltr" id="unit_group_2" <?php if ($_SESSION['unit']=="ltr") { echo "checked='checked' " ;} ?> />
            ltr</label>
          <label class="label_std">
            <input type="radio" name="unit_group" value="m" id="unit_group_3" <?php if ($_SESSION['unit']=="m") { echo "checked='checked' " ;} ?> />
            m</label>
          <label class="label_std">
            <input type="radio" name="unit_group" value="m2" id="unit_group_4" <?php if ($_SESSION['unit']=="m2") { echo "checked='checked' " ;} ?> />
            m2</label>
          <label class="label_std">
            <input type="radio" name="unit_group" value="pair" id="unit_group_5" <?php if ($_SESSION['unit']=="pair") { echo "checked='checked' " ;} ?> />
            pair</label>
          &nbsp;&nbsp;&nbsp;
          <label class="star">*</label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnable:&nbsp;&nbsp;
<select name="return_select" id="return_select">
  <option value="yes">yes</option>
          <option value="no">no</option>
          <option value="<?php echo $_SESSION['returnable'] ?>" selected="selected"><?php echo $_SESSION['returnable'] ?></option>
</select>
        <label class="star">*</label>
</div>

 
        <?php } ?>   
        <br /><br /><br /></td>
    </tr>
    <tr>
      <td><table width="590" height="50" align="left" id="table_button_bar">
          <tr>
            <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_showHideLayers('wait','','show');MM_goToURL('parent','storeWizbase.php?s=&amp;p=2');return document.MM_returnValue" /></td>
            <td width="115">
              <input name="s" type="hidden" id="s" value="3" />
              <input name="p" type="hidden" id="p" value="3" />
              </td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php?date=0&subCatSelect=Tiles');" value="Cancel" /></td>
            <td width="110" align="left"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false;  validate();  MM_showHideLayers('wait','','show');"  tabindex="2"/></td>
          </tr>
        </table></td>
    </tr>
  </table>
 
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  function validate() {
  frmvalidator.addValidation("minimumStockText","req","- the minimum stock.");
  frmvalidator.addValidation("price_text","req","- sales price.");
  <?php if ($_SESSION['category']!="Product") { ?>
  frmvalidator.addValidation("unit_group","selone","- an unit.");
  frmvalidator.addValidation("return_select","req","- returnable.");
  <?php } ?>
  
  }
</script>
<?php
}
?>
</body>