<?php
include('../include/session.php');

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$report_no = $_POST['report_no'];
$type = $_POST['type'];
$production_date = $_POST['production_date'];
//$mix_design_name = $_POST['mix_design_name'];
$tested_by = $_POST['tested_by_select'];
$test_date = $_POST['test_date'];
//$approved_by = $_POST['approved_by_select'];
//$approve_date = $_POST['approve_date'];
$surface_finish_1 = 0;
$surface_finish_2 = 0;
$surface_finish_3 = 0;
$surface_finish_4 = 0;
$surface_finish_5 = 0;
$surface_finish_6 = 0;
if (isset($_POST['surface_finish_1a'])) {$surface_finish_1 = 1;}
if (isset($_POST['surface_finish_1b'])) {$surface_finish_1 = 2;}
if (isset($_POST['surface_finish_2a'])) {$surface_finish_2 = 1;}
if (isset($_POST['surface_finish_2b'])) {$surface_finish_2 = 2;}
if (isset($_POST['surface_finish_3a'])) {$surface_finish_3 = 1;}
if (isset($_POST['surface_finish_3b'])) {$surface_finish_3 = 2;}
if (isset($_POST['surface_finish_4a'])) {$surface_finish_4 = 1;}
if (isset($_POST['surface_finish_4b'])) {$surface_finish_4 = 2;}
if (isset($_POST['surface_finish_5a'])) {$surface_finish_5 = 1;}
if (isset($_POST['surface_finish_5b'])) {$surface_finish_5 = 2;}
if (isset($_POST['surface_finish_6a'])) {$surface_finish_6 = 1;}
if (isset($_POST['surface_finish_6b'])) {$surface_finish_6 = 2;}
$length_1 = $_POST['length_1'];
$length_2 = $_POST['length_2'];
$length_3 = $_POST['length_3'];
$length_4 = $_POST['length_4'];
$length_5 = $_POST['length_5'];
$length_6 = $_POST['length_6'];
$width_1 = $_POST['width_1'];
$width_2 = $_POST['width_2'];
$width_3 = $_POST['width_3'];
$width_4 = $_POST['width_4'];
$width_5 = $_POST['width_5'];
$width_6 = $_POST['width_6'];
$th_body_1 = $_POST['th_body_1'];
$th_body_2 = $_POST['th_body_2'];
$th_body_3 = $_POST['th_body_3'];
$th_body_4 = $_POST['th_body_4'];
$th_body_5 = $_POST['th_body_5'];
$th_body_6 = $_POST['th_body_6'];
$th_lock_1 = $_POST['th_lock_1'];
$th_lock_2 = $_POST['th_lock_2'];
$th_lock_3 = $_POST['th_lock_3'];
$th_lock_4 = $_POST['th_lock_4'];
$th_lock_5 = $_POST['th_lock_5'];
$th_lock_6 = $_POST['th_lock_6'];
$side_lap_1 = $_POST['side_lap_1'];
$side_lap_2 = $_POST['side_lap_2'];
$side_lap_3 = $_POST['side_lap_3'];
$side_lap_4 = $_POST['side_lap_4'];
$side_lap_5 = $_POST['side_lap_5'];
$side_lap_6 = $_POST['side_lap_6'];
$batten_l_1 = $_POST['batten_l_1'];
$batten_l_2 = $_POST['batten_l_2'];
$batten_l_3 = $_POST['batten_l_3'];
$batten_l_4 = $_POST['batten_l_4'];
$batten_l_5 = $_POST['batten_l_5'];
$batten_l_6 = $_POST['batten_l_6'];
$batten_t_1 = $_POST['batten_t_1'];
$batten_t_2 = $_POST['batten_t_2'];
$batten_t_3 = $_POST['batten_t_3'];
$batten_t_4 = $_POST['batten_t_4'];
$batten_t_5 = $_POST['batten_t_5'];
$batten_t_6 = $_POST['batten_t_6'];
$batten_d_1 = $_POST['batten_d_1'];
$batten_d_2 = $_POST['batten_d_2'];
$batten_d_3 = $_POST['batten_d_3'];
$batten_d_4 = $_POST['batten_d_4'];
$batten_d_5 = $_POST['batten_d_5'];
$batten_d_6 = $_POST['batten_d_6'];
$b_nibs_1 = 0;
$b_nibs_2 = 0;
$b_nibs_3 = 0;
$b_nibs_4 = 0;
$b_nibs_5 = 0;
$b_nibs_6 = 0;
if (isset($_POST['b_nibs_1a'])) {$b_nibs_1 = 1;}
if (isset($_POST['b_nibs_1b'])) {$b_nibs_1 = 2;}
if (isset($_POST['b_nibs_2a'])) {$b_nibs_2 = 1;}
if (isset($_POST['b_nibs_2b'])) {$b_nibs_2 = 2;}
if (isset($_POST['b_nibs_3a'])) {$b_nibs_3 = 1;}
if (isset($_POST['b_nibs_3b'])) {$b_nibs_3 = 2;}
if (isset($_POST['b_nibs_4a'])) {$b_nibs_4 = 1;}
if (isset($_POST['b_nibs_4b'])) {$b_nibs_4 = 2;}
if (isset($_POST['b_nibs_5a'])) {$b_nibs_5 = 1;}
if (isset($_POST['b_nibs_5b'])) {$b_nibs_5 = 2;}
if (isset($_POST['b_nibs_6a'])) {$b_nibs_6 = 1;}
if (isset($_POST['b_nibs_6b'])) {$b_nibs_6 = 2;}
$nail_hole_1 = $_POST['nail_hole_1'];
$nail_hole_2 = $_POST['nail_hole_2'];
$nail_hole_3 = $_POST['nail_hole_3'];
$nail_hole_4 = $_POST['nail_hole_4'];
$nail_hole_5 = $_POST['nail_hole_5'];
$nail_hole_6 = $_POST['nail_hole_6'];
$mass_1 = $_POST['mass_1'];
$mass_2 = $_POST['mass_2'];
$mass_3 = $_POST['mass_3'];
$mass_4 = $_POST['mass_4'];
$mass_5 = $_POST['mass_5'];
$mass_6 = $_POST['mass_6'];
$knife_cut_1 = 0;
$knife_cut_2 = 0;
$knife_cut_3 = 0;
$knife_cut_4 = 0;
$knife_cut_5 = 0;
$knife_cut_6 = 0;
if (isset($_POST['knife_cut_1a'])) {$knife_cut_1 = 1;}
if (isset($_POST['knife_cut_1b'])) {$knife_cut_1 = 2;}
if (isset($_POST['knife_cut_2a'])) {$knife_cut_2 = 1;}
if (isset($_POST['knife_cut_2b'])) {$knife_cut_2 = 2;}
if (isset($_POST['knife_cut_3a'])) {$knife_cut_3 = 1;}
if (isset($_POST['knife_cut_3b'])) {$knife_cut_3 = 2;}
if (isset($_POST['knife_cut_4a'])) {$knife_cut_4 = 1;}
if (isset($_POST['knife_cut_4b'])) {$knife_cut_4 = 2;}
if (isset($_POST['knife_cut_5a'])) {$knife_cut_5 = 1;}
if (isset($_POST['knife_cut_5b'])) {$knife_cut_5 = 2;}
if (isset($_POST['knife_cut_6a'])) {$knife_cut_6 = 1;}
if (isset($_POST['knife_cut_6b'])) {$knife_cut_6 = 2;}
$colour_1 = 0;
$colour_2 = 0;
$colour_3 = 0;
$colour_4 = 0;
$colour_5 = 0;
$colour_6 = 0;
if (isset($_POST['colour_1a'])) {$colour_1 = 1;}
if (isset($_POST['colour_1b'])) {$colour_1 = 2;}
if (isset($_POST['colour_2a'])) {$colour_2 = 1;}
if (isset($_POST['colour_2b'])) {$colour_2 = 2;}
if (isset($_POST['colour_3a'])) {$colour_3 = 1;}
if (isset($_POST['colour_3b'])) {$colour_3 = 2;}
if (isset($_POST['colour_4a'])) {$colour_4 = 1;}
if (isset($_POST['colour_4b'])) {$colour_4 = 2;}
if (isset($_POST['colour_5a'])) {$colour_5 = 1;}
if (isset($_POST['colour_5b'])) {$colour_5 = 2;}
if (isset($_POST['colour_6a'])) {$colour_6 = 1;}
if (isset($_POST['colour_6b'])) {$colour_6 = 2;}
$cracks_1 = 0;
$cracks_2 = 0;
$cracks_3 = 0;
$cracks_4 = 0;
$cracks_5 = 0;
$cracks_6 = 0;
if (isset($_POST['cracks_1a'])) {$cracks_1 = 1;}
if (isset($_POST['cracks_1b'])) {$cracks_1 = 2;}
if (isset($_POST['cracks_2a'])) {$cracks_2 = 1;}
if (isset($_POST['cracks_2b'])) {$cracks_2 = 2;}
if (isset($_POST['cracks_3a'])) {$cracks_3 = 1;}
if (isset($_POST['cracks_3b'])) {$cracks_3 = 2;}
if (isset($_POST['cracks_4a'])) {$cracks_4 = 1;}
if (isset($_POST['cracks_4b'])) {$cracks_4 = 2;}
if (isset($_POST['cracks_5a'])) {$cracks_5 = 1;}
if (isset($_POST['cracks_5b'])) {$cracks_5 = 2;}
if (isset($_POST['cracks_6a'])) {$cracks_6 = 1;}
if (isset($_POST['cracks_6b'])) {$cracks_6 = 2;}
$compaction_1 = 0;
$compaction_2 = 0;
$compaction_3 = 0;
$compaction_4 = 0;
$compaction_5 = 0;
$compaction_6 = 0;
if (isset($_POST['compaction_1a'])) {$compaction_1 = 1;}
if (isset($_POST['compaction_1b'])) {$compaction_1 = 2;}
if (isset($_POST['compaction_2a'])) {$compaction_2 = 1;}
if (isset($_POST['compaction_2b'])) {$compaction_2 = 2;}
if (isset($_POST['compaction_3a'])) {$compaction_3 = 1;}
if (isset($_POST['compaction_3b'])) {$compaction_3 = 2;}
if (isset($_POST['compaction_4a'])) {$compaction_4 = 1;}
if (isset($_POST['compaction_4b'])) {$compaction_4 = 2;}
if (isset($_POST['compaction_5a'])) {$compaction_5 = 1;}
if (isset($_POST['compaction_5b'])) {$compaction_5 = 2;}
if (isset($_POST['compaction_6a'])) {$compaction_6 = 1;}
if (isset($_POST['compaction_6b'])) {$compaction_6 = 2;}
$lock_feather_1 = 0;
$lock_feather_2 = 0;
$lock_feather_3 = 0;
$lock_feather_4 = 0;
$lock_feather_5 = 0;
$lock_feather_6 = 0;
if (isset($_POST['lock_feather_1a'])) {$lock_feather_1 = 1;}
if (isset($_POST['lock_feather_1b'])) {$lock_feather_1 = 2;}
if (isset($_POST['lock_feather_2a'])) {$lock_feather_2 = 1;}
if (isset($_POST['lock_feather_2b'])) {$lock_feather_2 = 2;}
if (isset($_POST['lock_feather_3a'])) {$lock_feather_3 = 1;}
if (isset($_POST['lock_feather_3b'])) {$lock_feather_3 = 2;}
if (isset($_POST['lock_feather_4a'])) {$lock_feather_4 = 1;}
if (isset($_POST['lock_feather_4b'])) {$lock_feather_4 = 2;}
if (isset($_POST['lock_feather_5a'])) {$lock_feather_5 = 1;}
if (isset($_POST['lock_feather_5b'])) {$lock_feather_5 = 2;}
if (isset($_POST['lock_feather_6a'])) {$lock_feather_6 = 1;}
if (isset($_POST['lock_feather_6b'])) {$lock_feather_6 = 2;}
$granule_1 = 0;
$granule_2 = 0;
$granule_3 = 0;
$granule_4 = 0;
$granule_5 = 0;
$granule_6 = 0;
if (isset($_POST['granule_1a'])) {$granule_1 = 1;}
if (isset($_POST['granule_1b'])) {$granule_1 = 2;}
if (isset($_POST['granule_2a'])) {$granule_2 = 1;}
if (isset($_POST['granule_2b'])) {$granule_2 = 2;}
if (isset($_POST['granule_3a'])) {$granule_3 = 1;}
if (isset($_POST['granule_3b'])) {$granule_3 = 2;}
if (isset($_POST['granule_4a'])) {$granule_4 = 1;}
if (isset($_POST['granule_4b'])) {$granule_4 = 2;}
if (isset($_POST['granule_5a'])) {$granule_5 = 1;}
if (isset($_POST['granule_5b'])) {$granule_5 = 2;}
if (isset($_POST['granule_6a'])) {$granule_6 = 1;}
if (isset($_POST['granule_6b'])) {$granule_6 = 2;}
$pigment_1 = $_POST['pigment_1'];
$pigment_2 = $_POST['pigment_2'];
$pigment_3 = $_POST['pigment_3'];
$river_sand_1 = $_POST['river_sand_1'];
$river_sand_2 = $_POST['river_sand_2'];
$river_sand_3 = $_POST['river_sand_3'];
$silica_sand_1 = $_POST['silica_sand_1'];
$silica_sand_2 = $_POST['silica_sand_2'];
$silica_sand_3 = $_POST['silica_sand_3'];
$cement_1 = $_POST['cement_1'];
$cement_2 = $_POST['cement_2'];
$cement_3 = $_POST['cement_3'];
$water_1 = $_POST['water_1'];
$water_2 = $_POST['water_2'];
$water_3 = $_POST['water_3'];
$temperature = $_POST['temperature'];
$humidity = $_POST['humidity'];


$table_name = $_SESSION['db_prefix']."_wet_tile_spec";
$update_query = "UPDATE $table_name SET

tested_by = '".$tested_by."',
test_date = '".$test_date."',
surface_finish_1 = '".$surface_finish_1."', 
surface_finish_2 = '".$surface_finish_2."', 
surface_finish_3 = '".$surface_finish_3."', 
surface_finish_4 = '".$surface_finish_4."', 
surface_finish_5 = '".$surface_finish_5."', 
surface_finish_6 = '".$surface_finish_6."', 
length_1 = '".$length_1."', 
length_2 = '".$length_2."', 
length_3 = '".$length_3."', 
length_4 = '".$length_4."', 
length_5 = '".$length_5."', 
length_6 = '".$length_6."', 
width_1 = '".$width_1."', 
width_2 = '".$width_2."', 
width_3 = '".$width_3."', 
width_4 = '".$width_4."', 
width_5 = '".$width_5."', 
width_6 = '".$width_6."', 
th_body_1 = '".$th_body_1."',
th_body_2 = '".$th_body_2."',
th_body_3 = '".$th_body_3."',
th_body_4 = '".$th_body_4."',
th_body_5 = '".$th_body_5."',
th_body_6 = '".$th_body_6."', 
th_lock_1 = '".$th_lock_1."', 
th_lock_2 = '".$th_lock_2."',
th_lock_3 = '".$th_lock_3."',
th_lock_4 = '".$th_lock_4."',
th_lock_5 = '".$th_lock_5."',
th_lock_6 = '".$th_lock_6."',
side_lap_1 = '".$side_lap_1."',
side_lap_2 = '".$side_lap_2."',
side_lap_3 = '".$side_lap_3."',
side_lap_4 = '".$side_lap_4."',
side_lap_5 = '".$side_lap_5."',
side_lap_6 = '".$side_lap_6."',    
batten_l_1 = '".$batten_l_1."', 
batten_l_2 = '".$batten_l_2."', 
batten_l_3 = '".$batten_l_3."', 
batten_l_4 = '".$batten_l_4."', 
batten_l_5 = '".$batten_l_5."', 
batten_l_6 = '".$batten_l_6."', 
batten_t_1 = '".$batten_t_1."',
batten_t_2 = '".$batten_t_2."',
batten_t_3 = '".$batten_t_3."',
batten_t_4 = '".$batten_t_4."',
batten_t_5 = '".$batten_t_5."',
batten_t_6 = '".$batten_t_6."',  
batten_d_1 = '".$batten_d_1."', 
batten_d_2 = '".$batten_d_2."',
batten_d_3 = '".$batten_d_3."',
batten_d_4 = '".$batten_d_4."',
batten_d_5 = '".$batten_d_5."',
batten_d_6 = '".$batten_d_6."',
b_nibs_1 = '".$b_nibs_1."', 
b_nibs_2 = '".$b_nibs_2."', 
b_nibs_3 = '".$b_nibs_3."', 
b_nibs_4 = '".$b_nibs_4."', 
b_nibs_5 = '".$b_nibs_5."', 
b_nibs_6 = '".$b_nibs_6."',  
nail_hole_1 = '".$nail_hole_1."',
nail_hole_2 = '".$nail_hole_2."', 
nail_hole_3 = '".$nail_hole_3."', 
nail_hole_4 = '".$nail_hole_4."', 
nail_hole_5 = '".$nail_hole_5."', 
nail_hole_6 = '".$nail_hole_6."',  
mass_1 = '".$mass_1."',
mass_2 = '".$mass_2."',
mass_3 = '".$mass_3."',
mass_4 = '".$mass_4."',
mass_5 = '".$mass_5."',
mass_6 = '".$mass_6."',  
knife_cut_1 = '".$knife_cut_1."',
knife_cut_2 = '".$knife_cut_2."',
knife_cut_3 = '".$knife_cut_3."',
knife_cut_4 = '".$knife_cut_4."',
knife_cut_5 = '".$knife_cut_5."',
knife_cut_6 = '".$knife_cut_6."', 
colour_1 = '".$colour_1."', 
colour_2 = '".$colour_2."', 
colour_3 = '".$colour_3."', 
colour_4 = '".$colour_4."', 
colour_5 = '".$colour_5."', 
colour_6 = '".$colour_6."',  
cracks_1 = '".$cracks_1."', 
cracks_2 = '".$cracks_2."', 
cracks_3 = '".$cracks_3."', 
cracks_4 = '".$cracks_4."', 
cracks_5 = '".$cracks_5."', 
cracks_6 = '".$cracks_6."', 
compaction_1 = '".$compaction_1."',  
compaction_2 = '".$compaction_2."',
compaction_3 = '".$compaction_3."',
compaction_4 = '".$compaction_4."',
compaction_5 = '".$compaction_5."',
compaction_6 = '".$compaction_6."',
lock_feather_1 = '".$lock_feather_1."', 
lock_feather_2 = '".$lock_feather_2."', 
lock_feather_3 = '".$lock_feather_3."', 
lock_feather_4 = '".$lock_feather_4."', 
lock_feather_5 = '".$lock_feather_5."', 
lock_feather_6 = '".$lock_feather_6."', 
granule_1 = '".$granule_1."',  
granule_2 = '".$granule_2."', 
granule_3 = '".$granule_3."', 
granule_4 = '".$granule_4."', 
granule_5 = '".$granule_5."', 
granule_6 = '".$granule_6."', 
pigment_1 = '".$pigment_1."', 
pigment_2 = '".$pigment_2."', 
pigment_3 = '".$pigment_3."', 
river_sand_1 = '".$river_sand_1."',
river_sand_2 = '".$river_sand_2."',  
river_sand_3 = '".$river_sand_3."',    
silica_sand_1 = '".$silica_sand_1."',
silica_sand_2 = '".$silica_sand_2."', 
silica_sand_3 = '".$silica_sand_3."',  
cement_1 = '".$cement_1."',  
cement_2 = '".$cement_2."',  
cement_3 = '".$cement_3."',  
water_1 = '".$water_1."', 
water_2 = '".$water_2."', 
water_3 = '".$water_3."', 
temperature = '".$temperature."',  
humidity = '".$humidity."'
WHERE wet_report_no = '".$report_no."' ";

execsql($update_query);

$table_name = $_SESSION['db_prefix']."_tracking_quality";
$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '90', '".$test_date."', '".$report_no."' ,'','' )";
$trackingResult = mySQL_query($trackingQuery);	

$alert=0;
$alert_line = '';

if ($surface_finish_1==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 1 failed.';}
if ($surface_finish_2==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 2 failed.';}
if ($surface_finish_3==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 3 failed.';}
if ($surface_finish_4==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 4 failed.';}
if ($surface_finish_5==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 5 failed.';}
if ($surface_finish_6==2) {$alert=1; $alert_line = $alert_line.'<br>Surface finish 6 failed.';}

if ($type=='DR') {$l_min=414; $l_max=422; }
if ($type=='VE') {$l_min=414; $l_max=422; }
if ($type=='SL') {$l_min=415; $l_max=423; }
if ((($length_1<$l_min)||($length_1>$l_max))&&($length_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 1 is out of specification.';}
if ((($length_2<$l_min)||($length_2>$l_max))&&($length_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 2 is out of specification.';}
if ((($length_3<$l_min)||($length_3>$l_max))&&($length_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 3 is out of specification.';}
if ((($length_4<$l_min)||($length_4>$l_max))&&($length_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 4 is out of specification.';}
if ((($length_5<$l_min)||($length_5>$l_max))&&($length_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 5 is out of specification.';}
if ((($length_6<$l_min)||($length_6>$l_max))&&($length_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Length 6 is out of specification.';}


if ($type=='DR') {$w_min=328; $w_max=332; }
if ($type=='VE') {$w_min=328; $w_max=332; }
if ($type=='SL') {$w_min=330; $w_max=334; }
if ((($width_1<$w_min)||($width_1>$w_max))&&($width_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 1 is out of specification.';}
if ((($width_2<$w_min)||($width_2>$w_max))&&($width_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 2 is out of specification.';}
if ((($width_3<$w_min)||($width_3>$w_max))&&($width_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 3 is out of specification.';}
if ((($width_4<$w_min)||($width_4>$w_max))&&($width_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 4 is out of specification.';}
if ((($width_5<$w_min)||($width_5>$w_max))&&($width_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 5 is out of specification.';}
if ((($width_6<$w_min)||($width_6>$w_max))&&($width_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Width 6 is out of specification.';}


if ($type=='DR') {$thb_min=12; }
if ($type=='VE') {$thb_min=12; }
if ($type=='SL') {$thb_min=14; }
if ((($th_body_1<$thb_min))&&($th_body_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 1 is out of specification.';}
if ((($th_body_2<$thb_min))&&($th_body_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 2 is out of specification.';}
if ((($th_body_3<$thb_min))&&($th_body_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 3 is out of specification.';}
if ((($th_body_4<$thb_min))&&($th_body_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 4 is out of specification.';}
if ((($th_body_5<$thb_min))&&($th_body_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 5 is out of specification.';}
if ((($th_body_6<$thb_min))&&($th_body_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness body 6 is out of specification.';}


if ($type=='SL') { $thl_min=9; $thl_max=10; 
if ((($th_lock_1<$thl_min)||($th_lock_1>$thl_max))&&($th_lock_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_2<$thl_min)||($th_lock_2>$thl_max))&&($th_lock_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_3<$thl_min)||($th_lock_3>$thl_max))&&($th_lock_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_4<$thl_min)||($th_lock_4>$thl_max))&&($th_lock_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_5<$thl_min)||($th_lock_5>$thl_max))&&($th_lock_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_6<$thl_min)||($th_lock_6>$thl_max))&&($th_lock_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
}
else {
if ($type=='DR') {$thl_min=5; }
if ($type=='VE') {$thl_min=3; }
if ((($th_lock_1<$thl_min))&&($th_lock_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 1 is out of specification.';}
if ((($th_lock_2<$thl_min))&&($th_lock_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 2 is out of specification.';}
if ((($th_lock_3<$thl_min))&&($th_lock_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 3 is out of specification.';}
if ((($th_lock_4<$thl_min))&&($th_lock_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 4 is out of specification.';}
if ((($th_lock_5<$thl_min))&&($th_lock_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 5 is out of specification.';}
if ((($th_lock_6<$thl_min))&&($th_lock_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Thickness lock 6 is out of specification.';}
}

if ($type=='DR') {$sl_min=30; }
if ($type=='VE') {$sl_min=30; }
if ($type=='SL') {$sl_min=30; }
if ((($side_lap_1<$sl_min))&&($side_lap_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 1 is out of specification.';}
if ((($side_lap_2<$sl_min))&&($side_lap_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 2 is out of specification.';}
if ((($side_lap_3<$sl_min))&&($side_lap_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 3 is out of specification.';}
if ((($side_lap_4<$sl_min))&&($side_lap_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 4 is out of specification.';}
if ((($side_lap_5<$sl_min))&&($side_lap_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 5 is out of specification.';}
if ((($side_lap_6<$sl_min))&&($side_lap_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Side lap 6 is out of specification.';}


if ($type=='DR') {$bl_min=20; }
if ($type=='VE') {$bl_min=20; }
if ($type=='SL') {$bl_min=50; }
if ((($batten_l_1<$bl_min))&&($batten_l_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 1 is out of specification.';}
if ((($batten_l_2<$bl_min))&&($batten_l_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 2 is out of specification.';}
if ((($batten_l_3<$bl_min))&&($batten_l_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 3 is out of specification.';}
if ((($batten_l_4<$bl_min))&&($batten_l_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 4 is out of specification.';}
if ((($batten_l_5<$bl_min))&&($batten_l_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 5 is out of specification.';}
if ((($batten_l_6<$bl_min))&&($batten_l_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug L 6 is out of specification.';}

if ($type=='DR') {$bt_min=13; }
if ($type=='VE') {$bt_min=13; }
if ($type=='SL') {$bt_min=12; }
if ((($batten_t_1<$bt_min))&&($batten_t_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 1 is out of specification.';}
if ((($batten_t_2<$bt_min))&&($batten_t_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 2 is out of specification.';}
if ((($batten_t_3<$bt_min))&&($batten_t_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 3 is out of specification.';}
if ((($batten_t_4<$bt_min))&&($batten_t_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 4 is out of specification.';}
if ((($batten_t_5<$bt_min))&&($batten_t_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 5 is out of specification.';}
if ((($batten_t_6<$bt_min))&&($batten_t_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug T 6 is out of specification.';}


if ($type=='DR') {$bd_min=10; $bd_max=20; }
if ($type=='VE') {$bd_min=10; $bd_max=20; }
if ($type=='SL') {$bd_min=10; $bd_max=20; }
if ((($batten_d_1<$bd_min)||($batten_d_1>$bd_max))&&($batten_d_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 1 is out of specification.';}
if ((($batten_d_2<$bd_min)||($batten_d_2>$bd_max))&&($batten_d_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 2 is out of specification.';}
if ((($batten_d_3<$bd_min)||($batten_d_3>$bd_max))&&($batten_d_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 3 is out of specification.';}
if ((($batten_d_4<$bd_min)||($batten_d_4>$bd_max))&&($batten_d_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 4 is out of specification.';}
if ((($batten_d_5<$bd_min)||($batten_d_5>$bd_max))&&($batten_d_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 5 is out of specification.';}
if ((($batten_d_6<$bd_min)||($batten_d_6>$bd_max))&&($batten_d_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Batten lug D 6 is out of specification.';}

if ($b_nibs_1==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 1 failed.';}
if ($b_nibs_2==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 2 failed.';}
if ($b_nibs_3==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 3 failed.';}
if ($b_nibs_4==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 4 failed.';}
if ($b_nibs_5==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 5 failed.';}
if ($b_nibs_6==2) {$alert=1; $alert_line = $alert_line.'<br>Bottom nibs 6 failed.';}


if ($type=='DR') {$n_min=14; $n_max=20; }
if ($type=='VE') {$n_min=38; $n_max=44; }
if ($type=='SL') {$n_min=36; $n_max=42; }
if ((($nail_hole_1<$n_min)||($nail_hole_1>$n_max))&&($nail_hole_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 1 is out of specification.';}
if ((($nail_hole_2<$n_min)||($nail_hole_2>$n_max))&&($nail_hole_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 2 is out of specification.';}
if ((($nail_hole_3<$n_min)||($nail_hole_3>$n_max))&&($nail_hole_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 3 is out of specification.';}
if ((($nail_hole_4<$n_min)||($nail_hole_4>$n_max))&&($nail_hole_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 4 is out of specification.';}
if ((($nail_hole_5<$n_min)||($nail_hole_5>$n_max))&&($nail_hole_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 5 is out of specification.';}
if ((($nail_hole_6<$n_min)||($nail_hole_6>$n_max))&&($nail_hole_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Nail hole 6 is out of specification.';}

if ($type=='DR') {$m_min=4.05; $m_max=4.95; }
if ($type=='VE') {$m_min=4.5; $m_max=5.5; }
if ($type=='SL') {$m_min=4.68; $m_max=5.72; }
if ((($mass_1<$m_min)||($mass_1>$m_max))&&($mass_1!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 1 is out of specification.';}
if ((($mass_2<$m_min)||($mass_2>$m_max))&&($mass_2!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 2 is out of specification.';}
if ((($mass_3<$m_min)||($mass_3>$m_max))&&($mass_3!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 3 is out of specification.';}
if ((($mass_4<$m_min)||($mass_4>$m_max))&&($mass_4!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 4 is out of specification.';}
if ((($mass_5<$m_min)||($mass_5>$m_max))&&($mass_5!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 5 is out of specification.';}
if ((($mass_6<$m_min)||($mass_6>$m_max))&&($mass_6!='')) {$alert=1; $alert_line = $alert_line.'<br>Mass 6 is out of specification.';}

if ($knife_cut_1==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 1 failed.';}
if ($knife_cut_2==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 2 failed.';}
if ($knife_cut_3==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 3 failed.';}
if ($knife_cut_4==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 4 failed.';}
if ($knife_cut_5==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 5 failed.';}
if ($knife_cut_6==2) {$alert=1; $alert_line = $alert_line.'<br>Knife cut 6 failed.';}

if ($colour_1==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 1 failed.';}
if ($colour_2==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 2 failed.';}
if ($colour_3==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 3 failed.';}
if ($colour_4==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 4 failed.';}
if ($colour_5==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 5 failed.';}
if ($colour_6==2) {$alert=1; $alert_line = $alert_line.'<br>Body colour 6 failed.';}

if ($cracks_1==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 1 failed.';}
if ($cracks_2==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 2 failed.';}
if ($cracks_3==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 3 failed.';}
if ($cracks_4==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 4 failed.';}
if ($cracks_5==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 5 failed.';}
if ($cracks_6==2) {$alert=1; $alert_line = $alert_line.'<br>Cracks 6 failed.';}

if ($compaction_1==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 1 failed.';}
if ($compaction_2==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 2 failed.';}
if ($compaction_3==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 3 failed.';}
if ($compaction_4==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 4 failed.';}
if ($compaction_5==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 5 failed.';}
if ($compaction_6==2) {$alert=1; $alert_line = $alert_line.'<br>Compaction 6 failed.';}

if ($lock_feather_1==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 1 failed.';}
if ($lock_feather_2==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 2 failed.';}
if ($lock_feather_3==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 3 failed.';}
if ($lock_feather_4==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 4 failed.';}
if ($lock_feather_5==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 5 failed.';}
if ($lock_feather_6==2) {$alert=1; $alert_line = $alert_line.'<br>Lock feather 6 failed.';}

if ($granule_1==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 1 failed.';}
if ($granule_2==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 2 failed.';}
if ($granule_3==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 3 failed.';}
if ($granule_4==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 4 failed.';}
if ($granule_5==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 5 failed.';}
if ($granule_6==2) {$alert=1; $alert_line = $alert_line.'<br>Granule 6 failed.';}

if ($alert==1) {
  include('../include/wet_tile_alert.php');
}


if (isset($_POST['save_close_button']) )
	   { ?>
       <script>
	 		 window.location='quality_main.php';
		</script>
        <?php		 
	   }
	   
	if (isset($_POST['save_button']) )
	   {  ?>
       <script>
	          window.location="wet_tile_inspection_sheet.php?report_no=<?php echo $report_no?>&approve=";
	   </script>
        <?php		 
	   }
	   ?>