<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
include ("../navigation/header.php");
$page_name = $_GET['page_name'];
include ("../navigation/access.php");
?>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
</head>
<?php
if ($permission_num==1) {
	include ("../navigation/dry_feed_production_sidebar.php");

$page = $_GET['page_name'];
	
if ($page=='Mix-design-edit') {
$reference='dry_feed_mix_design_edit.php?design_no=';	
$page_name='Edit production packing design.';
$table_name = $_SESSION['db_prefix']."_mix_design";
$mix_query = "SELECT design_no, mix_design FROM $table_name WHERE product_type = 'Dry feed product' ORDER BY mix_design ASC";
$mix_result = $con->query($mix_query);
$mix_num = mysqli_num_rows($mix_result);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $mix_num) {
		$row = mysqli_fetch_assoc($mix_result);
		$arrId4[$w] = $row['design_no'];
		$arrName4[$w] = $row['mix_design'];
		$w++;
	}
}

if ($page=='Packing-design-edit') {
$reference='packaging_design_edit.php?design_no=';	
$page_name='Edit packaging design.';
$table_name = $_SESSION['db_prefix']."_packaging_design";
$packaging_query = "SELECT design_no, packaging_design FROM $table_name  ORDER BY packaging_design DESC";
$packaging_result = $con->query($packaging_query);

	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while($row = $packaging_result->fetch_assoc()) {
		$arrId4[$w] = $row["design_no"];
		$arrName4[$w] = $row["packaging_design"];

		$w++;
	}
}

if ($page=='Production-edit') {
$reference='dry_feed_production_edit.php?production_no=';
$page_name='Edit production packing';
$table_name = $_SESSION['db_prefix']."_production";
$production_query = "SELECT production_no, production_date, product_item_id FROM $table_name WHERE production_type = 'dry-feed' AND packing_design_no IS NULL ORDER BY production_no DESC";
$production_result = $con->query($production_query);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while($row = $production_result->fetch_assoc()) {
		$production_no = $row['production_no'];
		$production_date = $row['production_date'];
		$product_item_id = $row['product_item_id'];
		
		$table_name = $_SESSION['db_prefix']."_product_store";
		$item_name_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$product_item_id."'  ";
		$item_name_result = $con->query($item_name_query);
		$row = mysqli_fetch_assoc($item_name_result);
		$item_name = $row['item_name'];
						
		$arrId4[$w] = $production_no;
		$arrName4[$w] = $production_no.' '.date("d-m-Y", strtotime($production_date)).'  '.$item_name;
		$w++;
	}
}

if ($page=='Packing-edit') {
$reference='dry_feed_packing_edit.php?packing_no=';
$page_name='Packing';
$table_name = $_SESSION['db_prefix']."_production";
$table_name2 = $_SESSION['db_prefix']."_product_store_lines";
$packing_query = "SELECT $table_name.packing_no, $table_name.packing_date, $table_name.product_item_id FROM $table_name, $table_name2 WHERE $table_name.packing_no=$table_name2.packing_no AND $table_name.packing_date IS NOT NULL AND $table_name2.quantity_out = 0  ORDER BY $table_name.packing_no DESC";
$packing_result = $con->query($packing_query);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while($row = $packing_result->fetch_assoc()) {
		$packing_no = $row["packing_no"];
		$packing_date = $row["packing_date"];
		$product_item_id = $row["product_item_id"];
		
		$table_name = $_SESSION['db_prefix']."_product_store";
		$item_name_query = "SELECT item_name  FROM $table_name WHERE product_item_id = '".$product_item_id."' ";
		$item_name_result = $con->query($item_name_query);
		$row = mysqli_fetch_assoc($item_name_result);
		$item_name = $row['item_name'];


		$arrId4[$w] = $packing_no;
		$arrName4[$w] = $packing_no.'  '.date("d-m-Y", strtotime($packing_date)).'  '.$item_name;
		$w++;
	}
}




?>
<body>

<div class="main_frame">
<table width="630" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="52" colspan="4" align="left" valign="top"><div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select to edit</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
       <br />
<br /><br />
<br />
<br />
<br />

<div class="page_middle_frame"><br />
  <label class="label_std" style="font-size:16px;"><?php echo $page_name?></label>
  <br />
  <br />
  <form action="" method="get">
  <div class="wizard_frame">
    <label class="label_std"> Select  to edit : &nbsp;&nbsp;</label>
    <select name="job_no_select" autofocus="autofocus" class="selectbox300" id="job_no_select" onchange="window.location.href= this.form.job_no_select.options[this.form.job_no_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";	
		}
     ?>
    </select>
  </div>
  </form>
  <br />
  <br />
<br />
<br />
<br />

</div>
    </td>
    </tr>
    </table>
</div>

<?php include ('../navigation/side_bar.php'); ?>
</body>

<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "dry_feed_production/dry_feed_edit_select_production.php";	
    include ("../navigation/production_sidebar.php");?>
    <?php include ('../navigation/side_bar.php'); ?>
	<body onLoad="accessdenied(); return false">	
	</body>
<?php }
?>
</html>
