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

$userId = $_SESSION['username'];
date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s"); 


$table_name = $_SESSION['db_prefix']."_compiled_jobs";
$update_query = "UPDATE $table_name SET  inspect='yes'  WHERE job_card_no = '".$_SESSION['job_card_no']."' ";
execsql($update_query);
	

$table_name = $_SESSION['db_prefix']."_inspection_report";
$inspection_query = "INSERT INTO $table_name (job_card_no, cust_id, inspection_date, inspected_by, job_approved, agreed, completed, cust_signed, filled ) VALUES ('".$_SESSION['job_card_no']."', '".$_SESSION['cust_id']."', '".$_SESSION['inspection_date']."', '".$_SESSION['inspect']."', '".$_SESSION['approved']."', '".$_SESSION['agreed']."', '".$_SESSION['completed']."', '".$_SESSION['signed']."', '".$_SESSION['filled']."' ) ";
execsql($inspection_query);

$table_name6 = $_SESSION['db_prefix']."_order_history";
$history_query = "INSERT INTO $table_name6 (job_card_number, note_date, note_text, user_name ) VALUES ('".$_SESSION['job_card_no']."', '".$entry_date."', 'Job inspected on ".date("d-m-Y", strtotime($_SESSION['inspection_date']))." by ".$_SESSION['inspect'].".', '".$_SESSION['username']."' ) ";
	execsql($history_query);


$table_name = $_SESSION['db_prefix']."_tracking_orders";
$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '92', '".$_SESSION['job_card_no']."', '".$_SESSION['project']."' ,'".$_SESSION['inspect']."','' )";
$trackingResult = mySQL_query($trackingQuery);

include('../include/order_inspection_alert.php');
	
	
$job_card_no = $_SESSION['job_card_no'];
 
	 	$_SESSION['job_card_no']='';
	 	$_SESSION['name']="";
	 	$_SESSION['deliver_date']='';
	 	$_SESSION['cust_id']='';
	 
	 	$_SESSION['quote_note'] = '';
		$_SESSION['inspect']='';
		$_SESSION['cust_id']='';
		$_SESSION['order_date']='';
		$_SESSION['project_description'] = '';
		$_SESSION['project'] = '';
		$_SESSION['project_no'] = '';
		$_SESSION['project_place'] = '';
		$_SESSION['project_area'] = '';
		$_SESSION['deliver_date'] = '';
		$_SESSION['work_days'] = '';
		$_SESSION['value'] = '';
		$_SESSION['deliver_date']= '';

      $_SESSION['forman']='';
		$_SESSION['forman_name']='';
	 	
		
?>

<script language="javascript" type="text/javascript">
        
		  window.location="inspection_report.php?job_card_no=<?php echo $job_card_no ?>" ;
        
       </script>

