<!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']."_production_plan";
$dr_line_query = "SELECT production_date, item_type FROM $table_name WHERE  sub_category = 'Tiles' AND item_type = 'Double Roman' AND dry_approved = '0'  GROUP BY production_date ";
$dr_line_result = mySQL_query($dr_line_query);
$dr_line_num = mysql_num_rows($dr_line_result);

$table_name = $_SESSION['db_prefix']."_production_plan";
$sl_line_query = "SELECT production_date, item_type FROM $table_name WHERE  sub_category = 'Tiles' AND item_type = 'Slate' AND dry_approved = '0'  GROUP BY production_date ";
$sl_line_result = mySQL_query($sl_line_query);
$sl_line_num = mysql_num_rows($sl_line_result);

$table_name = $_SESSION['db_prefix']."_production_plan";
$ve_line_query = "SELECT production_date, item_type FROM $table_name WHERE  sub_category = 'Tiles' AND item_type = 'Venetian' AND dry_approved = '0'  GROUP BY production_date ";
$ve_line_result = mySQL_query($ve_line_query);
$ve_line_num = mysql_num_rows($ve_line_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 &amp; process 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": [
								{"iDataSort": 5},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
        <div align="right">
<img src="../images/info_blue.png" width="16" height="16">
<label class="label_info" style="font-size:10px">Click report no to open report or create to make a report</label>          
</div>
<table id="scroll_table" class="data_display">
<thead>
  <tr>
    <th align="left">Date</th>
    <th align="left">Batch code</th>
    <th align="left">Report no</th>
    <th align="left">Product</th>
    <th align="left">Production no</th>
    <th align="left">&nbsp;</th>
    </tr>
</thead>
  <?php 
  $i=0;
  while ($i<$dr_line_num) {
	  	$production_date = mysql_result($dr_line_result, $i, "production_date");
		$item_type = mysql_result($dr_line_result, $i, "item_type");
				
		$product_text='';
		if ($item_type == 'Double Roman') {
		$table_name = $_SESSION['db_prefix']."_production_plan";
		$report_query = "SELECT dry_report_no, production_no, production_date, batch_code, mix_design_name  FROM $table_name WHERE item_type = 'Double Roman' AND production_date = '".$production_date."' AND dry_approved = '0' ";
		$report_result = mySQL_query($report_query);
		$report_num = mysql_num_rows($report_result);
		$roman_text='';
		$production_roman_text='';
		$prod_roman_text='';
		$k=0;
		while ($k<$report_num)  {
			$report_no = mysql_result($report_result, $k, "dry_report_no");
			$batch_code = mysql_result($report_result, $k, "batch_code");
			$mix_design_name = mysql_result($report_result, $k, "mix_design_name");
			$production_no = mysql_result($report_result, $k, "production_no");
			$roman_text = $roman_text.$mix_design_name.'<br>';
			$production_roman_text = $production_roman_text.$production_no.'<br>';
			$prod_roman_text = $prod_roman_text.$production_no.'|';
			$k++;
		}
		}
		else {
			$roman_text='';
			$production_roman_text='';
			$prod_roman_text='';
		}
	
	?>	
		
		<tr>
    <td width="126" valign="top"><?php echo date("l, d-m-Y", strtotime($production_date)) ?></td>
    <td width="56" valign="top"><?php echo $batch_code ?></td>
    <td width="76" valign="top">
    <?php if ($report_no=='0') { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_roman_text ?>&item_type=<?php echo $item_type ?>&report_no=&approve=" onMouseover="ddrivetip('Click to create inspection report', 150)"; onMouseout="hideddrivetip()">Create</a>
    <?php } else { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_roman_text ?>&item_type=<?php echo $item_type ?>&report_no=<?php echo $report_no ?>&approve=" onMouseover="ddrivetip('Click to open inspection report', 150)"; onMouseout="hideddrivetip()"><?php echo $report_no ?></a>
    <?php } ?>
    </td>
    <td width="185" valign="top"><?php echo $roman_text ?></td>
    <td width="186" valign="top"><?php echo $production_roman_text ?></td>
    <td width="23" valign="top"><?php echo $production_date ?></td>
  </tr>
  <?php
  $i++;
  }
  ?>

<?php	
	$i=0;
  	while ($i<$sl_line_num) {
	  	$production_date = mysql_result($sl_line_result, $i, "production_date");
		$item_type = mysql_result($sl_line_result, $i, "item_type");	
		
		if ($item_type == 'Slate') {
		$table_name = $_SESSION['db_prefix']."_production_plan";
		$sl_report_query = "SELECT dry_report_no, production_no, production_date, batch_code, mix_design_name  FROM $table_name WHERE item_type = 'Slate' AND production_date = '".$production_date."' AND dry_approved = '0' ";
		$sl_report_result = mySQL_query($sl_report_query);
		$sl_report_num = mysql_num_rows($sl_report_result);
		$slate_text='';
		$production_slate_text='';
		$prod_slate_text='';
		$k=0;
		while ($k<$sl_report_num)  {
			$report_no = mysql_result($sl_report_result, $k, "dry_report_no");
			$batch_code = mysql_result($sl_report_result, $k, "batch_code");
			$mix_design_name = mysql_result($sl_report_result, $k, "mix_design_name");
			$production_no = mysql_result($sl_report_result, $k, "production_no");
			$slate_text = $slate_text.$mix_design_name.'<br>';
			$production_slate_text = $production_slate_text.$production_no.'<br>';
			$prod_slate_text = $prod_slate_text.$production_no.'|';
			$k++;
		}
		}
		else {
			$slate_text='';
			$production_slate_text='';
			$prod_slate_text='';
		}
	?>	
		<tr>
    <td width="126" valign="top"><?php echo date("l, d-m-Y", strtotime($production_date)) ?></td>
    <td width="56" valign="top"><?php echo $batch_code ?></td>
    <td width="76" valign="top">
    <?php if ($report_no=='0') { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_slate_text ?>&item_type=<?php echo $item_type ?>&report_no=&approve=" onMouseover="ddrivetip('Click to create inspection report', 150)"; onMouseout="hideddrivetip()">Create</a>
    <?php } else { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_slate_text ?>&item_type=<?php echo $item_type ?>&report_no=<?php echo $report_no ?>&approve=" onMouseover="ddrivetip('Click to open inspection report', 150)"; onMouseout="hideddrivetip()"><?php echo $report_no ?></a>
    <?php } ?>
    </td>
    <td width="185" valign="top"><?php echo $slate_text ?></td>
    <td width="186" valign="top"><?php echo $production_slate_text ?></td>
    <td width="23" valign="top"><?php echo $production_date ?></td>
  </tr>
  <?php
  $i++;
  }	
  ?>
  
  <?php
  $i=0;
  while ($i<$ve_line_num) {
	  	$production_date = mysql_result($ve_line_result, $i, "production_date");
		$item_type = mysql_result($ve_line_result, $i, "item_type");
	    
	    if ($item_type == 'Venetian') {
		$table_name = $_SESSION['db_prefix']."_production_plan";
		$ve_report_query = "SELECT dry_report_no, production_no, production_date, batch_code, mix_design_name  FROM $table_name WHERE item_type = 'Venetian' AND production_date = '".$production_date."' AND dry_approved = '0' ";
		$ve_report_result = mySQL_query($ve_report_query);
		$ve_report_num = mysql_num_rows($ve_report_result);
		$venetian_text='';
		$production_venetian_text='';
		$prod_venetian_text='';
		$k=0;
		while ($k<$ve_report_num)  {
			$report_no = mysql_result($ve_report_result, $k, "dry_report_no");
			$batch_code = mysql_result($ve_report_result, $k, "batch_code");
			$mix_design_name = mysql_result($ve_report_result, $k, "mix_design_name");
			$production_no = mysql_result($ve_report_result, $k, "production_no");
			$venetian_text = $venetian_text.$mix_design_name.'<br>';
			$production_venetian_text = $production_venetian_text.$production_no.'<br>';
			$prod_venetian_text = $prod_venetian_text.$production_no.'|';
			$k++;
		}
		}
		else {
			$venetian_text='';
			$production_venetian_text='';
			$prod_venetian_text='';
		}
	    
	    //$product_text = $roman_text.$slate_text.$venetian_text;
//		$production_text = $production_roman_text.$production_slate_text.$production_venetian_text;
//		$prod_text = $prod_roman_text.$prod_slate_text.$prod_venetian_text;
	  
	  ?>
            	
		<tr>
    <td width="126" valign="top"><?php echo date("l, d-m-Y", strtotime($production_date)) ?></td>
    <td width="56" valign="top"><?php echo $batch_code ?></td>
    <td width="76" valign="top">
    <?php if ($report_no=='0') { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_venetian_text ?>&item_type=<?php echo $item_type ?>&report_no=&approve=" onMouseover="ddrivetip('Click to create inspection report', 150)"; onMouseout="hideddrivetip()">Create</a>
    <?php } else { ?>
    <a href="../quality/dry_tile_inspection_sheet.php?production_text=<?php echo $prod_venetian_text ?>&item_type=<?php echo $item_type ?>&report_no=<?php echo $report_no ?>&approve=" onMouseover="ddrivetip('Click to open inspection report', 150)"; onMouseout="hideddrivetip()"><?php echo $report_no ?></a>
    <?php } ?>
    </td>
    <td width="185" valign="top"><?php echo $venetian_text ?></td>
    <td width="186" valign="top"><?php echo $production_venetian_text ?></td>
    <td width="23" valign="top"><?php echo $production_date ?></td>
  </tr>
  <?php
  $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>