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

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

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

if ($permission_num==1) {

include ("../navigation/production_sidebar.php");
include('../include/period_select_date.php');	
 
$table_name = $_SESSION['db_prefix']."_recycle";	 	
$display_query = "SELECT * FROM $table_name WHERE packing_recycled_date >= '".$start."' AND packing_recycled_date <= '".$end."' ORDER BY production_recycle_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">Recycle</label></div>
   
<br />
<br /><br />
<br />
<?php
$page='production_tiles_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": [
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true}
                         	 ]
				} );
			} );
		</script>    	
<table width="572" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th align="center">Packing<br>
	      no</th>
		  <th align="center">Product</th>
		  <th align="center">Packing<br>
	      date</th>
		  <th align="center">Damaged<br>
		    no</th>
		  <th align="center">Recycled<br>
	      to production</th>
		  <th align="center">Production<br>
	      date</th>
		  <th align="center">Recycled<br>
		    no</th>
		  <th align="center">&nbsp;</th>
	    </tr>
	</thead>
	<tbody>
  <?php
  	while($row = $display_result->fetch_assoc()) {
		 $b0 = $row["production_recycle_no"];
		 $b1 = $row["product_item_id"];
		 $b2= $row["packing_recycled_date"];
		 $b3 = $row["damaged_no"];
		 $b4 = $row["production_recycled_no"];
		 $b5 = $row["production_recycle_date"];
		 $b6 = $row["recycled_no"];
//		 $b7 = $row["damaged_no"];
//		 $b8 = $row["batch_code"];
		 
		 $table_name = $_SESSION['db_prefix']."_product_store";
		 $item_name_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$b1."' ";
		 $item_name_result = $con->query($item_name_query);
		 $row = mysqli_fetch_assoc($item_name_result);
		 $b1a = $row['item_name'];

						
		?>
		<tr >
		  <td align="left"><a href="packing_slip.php?production_no=<?php echo $b0 ?>"><?php echo $b0 ?></a></td>
		  <td align="left" ><?php echo $b1a ?></td>
		  <td align="left"><?php echo date("d-m-Y", strtotime($b2)) ?></td>
		  <td align="right"><?php echo $b3 ?></td>
		  <td align="left"><?php echo $b4 ?></td>
		  <td align="left"><?php if ($b5!='') {echo date("d-m-Y", strtotime($b5));} ?></td>
		  <td align="right"><?php echo $b6 ?></td>
		  <td align="left">&nbsp; </td>
	    </tr>
	<?php
	}
	?>
	<tfoot>	
        <tr >
		  <td align="right">Totals:</td>
		  <td align="left" >&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</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'] = "production/production_main.php?";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>