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

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

if ($permission_num==1) {

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

include('../include/period_select_date.php');

$table_name = $_SESSION['db_prefix']."_production_plan";
$table_name2 = $_SESSION['db_prefix']."_production_plan_lines";
$product_query = "SELECT $table_name.production_no, $table_name.production_date, $table_name.mix_design_name, $table_name.batch_code, $table_name.sub_category FROM $table_name, $table_name2  WHERE $table_name.production_no = $table_name2.production_no AND  $table_name2.action = 'dep_count' AND ($table_name2.action_date  BETWEEN '".$start."' AND '".date('Y-m-d', strtotime(date("Y-m-d", strtotime($end))." +1 day"))."') ";
$product_result = mySQL_query($product_query);	
$product_result = mySQL_query($product_query);
$product_num = mysql_num_rows($product_result);	

?>
<!--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">Produced tiles & accessories</label>
  </div>

<div class="page_middle_frame">   

<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": "400px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"iDataSort": 6},
								{"iDataSort": 7},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false},
								{"bVisible": false}
							 ]
				} );
			} );
		</script>
       
        
<?php
$page='tile_received_list.php';
$reference_name='';
$reference='';
$reference_name_2='';
$reference_2='';
include('../include/period_select_block_2.php');
?>

<div class="page_inside_frame">            
          <table width="671" id="scroll_table" class="data_display" >
            <thead>
            <tr>
              <th align="center" >Production<br>no</th>
              <th >Production date</th>
              <th >Depallet date</th>
              <th >Product</th>
              <th >Quantity</th>
              <th >Batch code</th>
              <th width="26">&nbsp;</th>
              <th width="29">&nbsp;</th>
              </tr>
            </thead>
            <?php 
$i=0;

while ($i<$product_num) {
	$a1 = mysql_result($product_result, $i, "production_no");
	$a2 = mysql_result($product_result, $i, "production_date");	
	$a3 = mysql_result($product_result, $i, "sub_category");
	$a4 = mysql_result($product_result, $i, "mix_design_name");			
	$a6 = mysql_result($product_result, $i, "batch_code");
	
	
	$table_name = $_SESSION['db_prefix']."_production_plan_lines";
	$quantity_query = "SELECT quantity, action_date FROM $table_name WHERE production_no = '".$a1."' AND action = 'dep_count' ";
	$quantity_result = mySQL_query($quantity_query);
	$quantity_num = mysql_num_rows($quantity_result);
	$a5=0;
	$z=0;
	while ($z<$quantity_num) {
	  $a5 = mysql_result($quantity_result, $z, "quantity");	
	  $a7 = mysql_result($quantity_result, $z, "action_date");	 
	  		

$table_name = $_SESSION['db_prefix']."_store_items";
$item_query = "SELECT store_item_id, quantity FROM $table_name WHERE item_name = '".$a4."' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);
$store_item_id = mysql_result($item_result, 0, "store_item_id");
$quantity = mysql_result($item_result, 0, "quantity");
		
	
	$itemTT ="<table id=table_tool_tip ><tr><td  width=75>Item:</td><td width=200>".$a4."</td></tr><tr><td>Stock:</td><td>".$quantity."</td></tr></table><br><b>Click for details</b>";
	
	//$deliverTT ="<table id=table_tool_tip width=250 ><tr><td>Item</td><td>Quantity</td></tr>".$line_text."<tr><td>&nbsp;</td><td>&nbsp;</td></tr></table><br><b>Click for details</b>";
	
	//$orderTT ="<table id=table_tool_tip width=250 ><tr><td>Item</td><td>Quantity</td></tr>".$order_line_text."<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table><br><b>Click for details</b>";
	
	?>
            <tr>               
              <td width="89"align="left"  style="padding-left:0px;"><a href="../production/day_production_tiles_list.php?sub_cat=Tiles&date=<?php echo $a2 ?>" onmouseover="ddrivetip('Click for day production', 115)"; onmouseout="hideddrivetip()"><?php echo $a1 ?></a></td>
              <td width="96" align="left"><?php echo date("d-m-Y", strtotime($a2))?></td>
              <td width="96" align="left"><?php echo date("d-m-Y", strtotime($a7))?></td>
              <td width="168" align="left"><a href="store_item_display.php?store_item_id=<?php echo $store_item_id ?>" onmouseover="ddrivetip('<?php echo $itemTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $a4 ?></a></td>
              <td width="76" align="left"><?php echo $a5 ?></td>
              <td width="55" align="left"><?php echo $a6 ?></td>
              <td align="left"><?php echo $a2 ?></td>
              <td align="left"><?php echo $a7 ?></td>
            </tr>
            <?php
$z++;
	}			
			
  $i++;
}
?>
            <tfoot>
            </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 }
?>

