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

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

$temp_date = strtotime($_SESSION['start_date']);
$end_date = date("Y-m-d", strtotime("+12 month", $temp_date));

$temp2_date = strtotime($end_date);
$end_date = date("Y-m-d", strtotime("-1 day", $temp2_date));



$table_name = $_SESSION['db_prefix']."_maintenance_contracts";
$update_query = "UPDATE $table_name SET  start_date = '".$_SESSION['start_date']."', end_date = '".$end_date."', cluster='".$_SESSION['cluster']."', quote_note='".$_SESSION['contract_notes']."'  WHERE contract_card_no = '".$_SESSION['contract_card_no']."' ";
execsql($update_query);


$table_name = $_SESSION['db_prefix']."_tracking_maintenance";
$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '127', '".$_SESSION['contract_card_no']."', '".$_SESSION['cust_id']."' ,'".$_SESSION['start_date']."', '".$_SESSION['cluster']."' )";
$trackingResult = mySQL_query($trackingQuery);

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

$contract_card_no = $_SESSION['contract_card_no'];

$_SESSION['contract_card_no']='';
$_SESSION['name']="";
$_SESSION['cust_id']='';
$_SESSION['start_date'] = date("Y-m-d");

?>

<script language="javascript" type="text/javascript">


        
		  window.location="../maintenance/maintenance_contract.php?contract_card_no=<?php echo $contract_card_no ?>" ;
        
       </script>

