<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include ("../navigation/header.php");

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

if ($permission_num==1) {

include ("../navigation/store_sidebar.php");
include('../include/period_select_date.php');

$base_product_item_id = $_GET['product_item_id'];

$table_name = $_SESSION['db_prefix']."_product_store";
$base_product_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$base_product_item_id."' ";
$base_product_result = $con->query($base_product_query);
$row = mysqli_fetch_assoc($base_product_result);
$base_product_name = $row['item_name'];

$table_name = $_SESSION['db_prefix']."_recycle_history";
$display_query = "SELECT * FROM $table_name WHERE base_item_id = '".$base_product_item_id."'  ORDER BY history_id DESC";
$display_result = $con->query($display_query);


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

<body>

<div class="main_frame">
 
  <div class="page_head_frame">
    <label class="label_page_head">Recycle history <?php echo $base_product_name ?></label></div>
<div class="page_middle_frame">
<?php
$page='recycle_item_history.php';
$reference_name='product_item_id';
$reference=$base_product_item_id;
$reference_name_2='';
$reference_2='';
include('../include/period_select_block_2.php');
?>      
<br>
<br>

<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": "420px",
					"bPaginate": false,
					"bScrollCollapse": true,
					/*"aaSorting": [[ 1, "desc" ]],*/
					"aoColumns": [
								{"iDataSort": 8},
								{"iDataSort": 6},
								{"bSortable": true},
								{"iDataSort": 7},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false},
								{"bVisible": false},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>



<div class="page_inside_frame">

<div align="left">
            <label class="label_end"><img src="../images/round_green.png" width="8" height="8" />: Delivered&nbsp;&nbsp;<img src="../images/round_orange.png" width="8" height="8" />:Part delivered&nbsp;&nbsp;<img src="../images/round_red.png" width="8" height="8" />:On order&nbsp;&nbsp;<img src="../images/round_black.png" width="8" height="8">&nbsp;&nbsp;Cancelled&nbsp;&nbsp;<img src="../images/round_grey.png" alt="" width="8" height="8">&nbsp;&nbsp;Partly cancelled</label></div>
          
<table width="675" id="scroll_table" class="data_display" >
            <thead>
            <tr>
              <th width="58" >Date</th>
              <th width="89" >Product</th>
              <th width="117" >Batch code/action</th>
              <th width="54" align="center" >recycle<br>qty</th>
              <th width="54" align="center" >recycle<br>
              stock</th>
              <th width="91" >reason</th>
              <th width="111" >notes</th>
              <th width="14">&nbsp;</th>
              <th width="17">&nbsp;</th>
              <th width="26">&nbsp;</th>
            </tr>
            </thead>
            
            <?php
			while($row = $display_result->fetch_assoc()) {
			$date = $row["date"];
			$product_item_id = $row["product_item_id"];
			$batch_code = $row["batch_code"];
			$recycle_no = $row["recycle_no"];
			$recycle_stock = $row["recycle_stock"];
			$recycle_reason = $row["recycle_reason"];
			$recycle_notes = $row["recycle_notes"];
						
			$table_name = $_SESSION['db_prefix']."_product_store";
			$product_name_query = "SELECT item_name FROM $table_name WHERE product_item_id = '".$product_item_id."' ";
			$product_name_result = $con->query($product_name_query);
			$row = mysqli_fetch_assoc($product_name_result);
			$product_name = $row['item_name'];
		
			?>
        <tr>
              <td align="left"  style="padding-left:0px;"><?php echo date("d-m-Y", strtotime($date)) ?></td>
              <td align="left"><?php echo $product_name ?></td>
              <td align="left"><?php echo $batch_code ?></td>
              <td align="right"><?php echo $recycle_no ?></td>
              <td align="right"><?php echo $recycle_stock ?></td>
              <td align="left"><?php echo $recycle_reason ?></td>
              <td align="left"><?php echo $recycle_notes ?></td>
              <td align="left">&nbsp;</td>
              <td align="left">&nbsp;</td>
              <td align="left">&nbsp;</td>
            </tr>
			<?php
			}
			?>
            <tfoot>
              <tr>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td align="right" valign="bottom">&nbsp;</td>
                <td >&nbsp;</td>
                <td >&nbsp;</td>
                <td >&nbsp;</td>
              </tr>
            </tfoot>
          </table>
</div>
</div>
</div> 
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
    $_SESSION['denied_return'] = "store/store_main.php?date=";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>

