<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

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

<?php
include ("../navigation/header.php");
$page_name = "Quality-main";

$table_name = $_SESSION['db_prefix']."_dry_tile_spec";
$batch_query = "SELECT batch_code, production_date, dry_report_no FROM $table_name WHERE approved IS NULL  GROUP BY batch_code";
$batch_result = mySQL_query($batch_query);
$batch_num = mysql_num_rows($batch_result);

?>

</head>

<body>

<?php



include ("../navigation/access.php");
if ($permission_num==1) {
include ("../navigation/quality_sidebar.php");
?>

<div class="main_frame">
 
<div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Dry tile  inspections</label></td>
            </tr>
        </table>
</div>
<div class="page_inside_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": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"iDataSort": 3},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table id="scroll_table" class="data_display">
<thead>
  <tr>
    <th align="left">Report no</th>
    <th align="left">Batch code</th>
    <th align="left">Production date</th>
    <th align="left">Product</th>
    <th align="left">&nbsp;</th>
    </tr>
</thead>
  <?php 
  $i=0;
  
  while ($i<$batch_num) {
	  $batch_code = mysql_result($batch_result, $i, "batch_code");
	  $production_date = mysql_result($batch_result, $i, "production_date");
	  
	  
	  	$products_text = '';
	  	$table_name = $_SESSION['db_prefix']."_production_plan";
		$products_query = "SELECT mix_design_name FROM $table_name WHERE batch_code = '".$batch_code."' AND sub_category = 'Tiles' ";
		$products_result = mySQL_query($products_query);
		$products_num = mysql_num_rows($products_result);
		$k=0;
		while ($k<$products_num) {
		 $product = mysql_result($products_result, $k, "mix_design_name");
		
		$table_name = $_SESSION['db_prefix']."_dry_tile_spec";
		$report_query = "SELECT dry_report_no FROM $table_name ";
		$report_result = mySQL_query($report_query);
		$report_no = mysql_result($report_result, 0, "dry_report_no");
		
	  
	  ?>
  <tr>
    <td width="75"><?php echo $report_no ?></td>
    <td width="75"><a href="dry_tile_inspection_sheet.php?batch_code=<?php echo $batch_code ?>&product=<?php echo $product ?>&approve=" onMouseOver="ddrivetip('Click to open inspection report.', 175)"; onMouseOut="hideddrivetip()"><?php echo $batch_code ?></a></td>
    <td width="106"><?php echo date("d-m-Y", strtotime($production_date)) ?></td>
    <td width="249"><?php echo $product ?></td>
    <td width="54"><?php echo $production_date ?></td>
  </tr>
  <?php
  $k++;
		}
  $i++;
  }
  ?>
</table>

</div>
</div>



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

</body>

<?php } else {
	
$_SESSION['denied_return'] = $_SESSION['location'];	
include ("../navigation/quality_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>


</html>