
<?php 
$page_name = "Packing-design";
include ("../navigation/access.php");

if ($permission_num==1) {

	$table_name = $_SESSION['db_prefix']."_product_store";
	$position_query = "SELECT product_item_id, item_name FROM $table_name WHERE category = 'Product' AND subCategory = 'Sales product' AND mix_design_id IS NULL ";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = $con->query($position_query);
	if ($position_result!="") {
	$position_num = mysqli_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$row = mysqli_fetch_assoc($position_result);
		$arrId3[$b] = $row['product_item_id'];
		$arrName3[$b] = $row['item_name'];
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_product_store";
	$position_query = "SELECT product_item_id, item_name FROM $table_name WHERE category = 'Product' AND subCategory = 'Production' ";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = $con->query($position_query);
	if ($position_result!="") {
	$position_num = mysqli_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$row = mysqli_fetch_assoc($position_result);
		$arrId2[$b] = $row['product_item_id'];
		$arrName2[$b] = $row['item_name'];
		$b++;
	}
	}	

?> 

</head>

<?php include('../include/wait.php') ?>

<body onLoad=" <?php if ($_SESSION['error']==1) { ?>alertMessage(1, '', 'The design name <?php echo $_SESSION['packaging_design'] ?> already exists. Please select another name.'); document.getElementById('packaging_name_text').value='';  <?php } ?>; MM_showHideLayers('wait','','hide');" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide'); ">

<div class="page_middle_frame">
  <form id="form1" name="form1" method="get" action="packing_designWizbase.php">
    <table width=595 border="0" align="left" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
      <tr>
        <td>
          Select product  to make packaging recipe for:&nbsp;&nbsp;
          <label class="star">*</label>
&nbsp;
     <select name="product_select" class="select200"  >
          <option value="<?php echo $_SESSION['product_item_id'] ?>" selected="selected"><?php echo $_SESSION['product_name'] ?></option>
            <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
          </select>
        </td>
        <td width="1"></td>
      </tr>
      <tr>
        <td>
          Product to be packed with this packaging:&nbsp;&nbsp;
          <label class="star">*</label>
&nbsp;
     <select name="mix_design_id_select" class="select200"  >
          <option value="<?php echo $_SESSION['mix_design_id'] ?>" selected="selected"><?php echo $_SESSION['mix_design_name'] ?></option>
            <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
          </select>
&nbsp;&nbsp;&nbsp;</td>
        <td width="1"></td>
      </tr>
      <tr>
        <td>No of products packed with this design:&nbsp;&nbsp;&nbsp;<label class="star">*</label>&nbsp;&nbsp;&nbsp;&nbsp;
          <select name="pack_qty_select" class="select50"  >
            <option value="<?php echo $_SESSION['pack_qty'] ?>"><?php echo $_SESSION['pack_qty'] ?></option>
            <option value="1">1</option>
            <option value="2">2</option>
        </select></td>
        <td></td>
      </tr>
      <tr>
        <td>Design name:&nbsp;&nbsp;
        <label class="star">*</label>&nbsp;&nbsp;<input type="text" name="packaging_name_text" id="packaging_name_text" class="text300" value="<?php echo $_SESSION['packaging_design'] ?>"></td>
        <td></td>
      </tr>
    
    <tr>
      <td><table width="590" height="50" align="left" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115"></td>
            <td width="99"><input name="p" type="hidden" id="p" value="1" />
              <input name="error" type="hidden" id="error" value="0" />
              <input name="s" type="hidden" id="s" value="1" /></td>
            <td width="125" align="left"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../production/production_main.php?date=0&subCatSelect=Tiles');" value="Cancel"  tabindex="-1"/></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); validate();  " tabindex="5" /></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>

<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("product_select","req","- a product.");
  frmvalidator.addValidation("mix_design_id_select","req","- product to be packed.");
  frmvalidator.addValidation("pack_qty_select","req","- no of products to be packed.");
  frmvalidator.addValidation("packaging_name_text","req","- a design name.");
  </script>

</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "store/store_main.php?date=0&subCatSelect=Tiles";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
