<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php 
include ("../navigation/header.php");

$page_name = "DF-Production-main";
include ("../navigation/access.php");

if ($permission_num==1) {

include ("../navigation/dry_feed_production_sidebar.php");
include('../include/period_select_date.php');	
 
$table_name = $_SESSION['db_prefix']."_production";	 	
$display_query = "SELECT production_no, production_date, product_item_id, skips_no, skip_products_no, recycled_no, production_cost, batch_code, produced_no FROM $table_name WHERE production_type = 'dry-feed' AND production_date >= '".$start."' AND production_date <= '".$end."' GROUP BY production_no ORDER BY production_no DESC ";
$display_result = $con->query($display_query);
$display_num = mysqli_num_rows($display_result);
		
?> 

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</head>


<body>

<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">Production packing list</label></div>
   
<br />
<br /><br />
<br />
<?php
$page='dry_feed_production_list.php';
$reference_name='';
$reference='';
$reference_name_2='';
$reference_2='';
include('../include/period_select_block.php');
?>


    
<br />
<div class="page_middle_frame">
<!--jscript-->
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
								{"iDataSort": 8},
								{"iDataSort": 9},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false},
								{"bVisible": false}
                         	 ]
				} );
			} );
		</script>    	
<table width="572" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th align="center">Prod<br>
	      no</th>
		  <th align="center">Production<br>
	      date</th>
		  <th align="center">Product</th>
		  <th align="center">Production<br>weight</th>
		  <th align="center">Packed<br>products</th>
          <th align="center">Total<br>
          packed</th>
		  <th align="center">Batch code</th>
		  <th align="center">Production<br>
	      cost</th>
		  <th align="center">&nbsp;</th>
		  <th align="center">&nbsp;</th>
	    </tr>
	</thead>
	<tbody>
  <?php
    $b3_tot = 0;
	$b4_tot = 0;
	$b5_tot = 0;
	$b7_tot = 0;
	$b8_tot = 0;
	
  	while($row = $display_result->fetch_assoc()) {
		 $b0 = $row["production_no"];
		 $b1 = $row["production_date"];
		 $b2 = $row["product_item_id"];
		 $b3 = $row["skips_no"];
		 $b4 = $row["recycled_no"];
		 $b5 = $row["produced_no"];
		 $b6 = $row["batch_code"];
		 $b7 = $row["production_cost"];
		 $b8 = $row["skip_products_no"];
		 
		 $table_name = $_SESSION['db_prefix']."_product_store";
		 $item_name_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$b2."' ";
		 $item_name_result = $con->query($item_name_query);
		 $row = mysqli_fetch_assoc($item_name_result);
		 $b2a = $row['item_name'];
		 
		 $b3_tot = $b3_tot + $b3;
		 $b4_tot = $b4_tot + $b4;
		 $b5_tot = $b5_tot + $b5;
		 $b7_tot = $b7_tot + $b7;
		 $b8_tot = $b8_tot + $b8;

						
		?>
		<tr >
		  <td align="left"><a href="dry_feed_production_slip.php?production_no=<?php echo $b0 ?>"><?php echo $b0 ?></a></td>
		  <td align="left" ><?php echo date("d-m-Y", strtotime($b1)) ?></td>
		  <td align="left"><?php echo $b2a ?></td>
		  <td align="right"><?php echo $b3 ?></td>
		  <td align="right"><?php echo $b8 ?></td>
		  <td align="right"><?php echo $b5 ?></td>
		  <td align="left"><?php echo $b6 ?></td>
		  <td align="right"><?php echo $b7 ?></td>
		  <td align="right"><?php echo $b0 ?>&nbsp;</td>
		  <td align="right"><?php echo $b1 ?>&nbsp;</td>
	    </tr>
	<?php
	}
	?>
	<tfoot>	
        <tr >
		  <td align="right">Totals:</td>
		  <td align="left" >&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right"><?php echo $b3_tot ?></td>
		  <td align="right"><?php echo $b8_tot ?></td>
		  <td align="right"><?php echo $b5_tot ?></td>
		  <td align="right">&nbsp;</td>
		  <td align="right"><?php echo number_format($b7_tot, 2, '.', ',') ?></td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
	    </tr> 
    </tfoot>      
</table>
<br>
	

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