<?php

session_start();
ini_set("date.timezone", "Asia/Kuala_Lumpur");
require "form functions.php";
require "db_page.php";
$_SESSION['helpdesk_page'] = "main page.php";
?>

<?php 
if (isset($_POST['location']) && isset($_POST['task_id'])) {
    $loginHour = adjustTime($_POST['loginamorpm'], $_POST['loginHour']);
    $loginDay = $_POST['loginYear'] . "-" . $_POST['loginMonth'] . "-" . $_POST['loginDay'];
    $login_date = $loginDay . " " . $loginHour . ":" . $loginMinute . ":00";
    $db = retrieveHelpdeskDb();
    $sql = "insert into dispatch_track(dispatch_staffer,login_time,location,task_id) values ('" . $_POST['user_name'] . "','" . $login_date . "',\"" . $_POST['location'] . "\",'" . $_POST['task_id'] . "')";
    $rs = $db->query($sql);
    echo "Dispatch staffer has updated his status.<br>";
}
?>
<style type="text/css">
#cssTable {
background-color: #0066cb;
color: #ffcc35;

}
a:link {
text-decoration: none;
}

#exception a{
//POST Variables
if(isset($_POST['change_task'])){
	$task=$_POST['change_task'];

}

?>
<?php
//POST Variables

if((isset($_POST['taskId']))&&($_POST['taskId']!=="")){
	$receiveHour=0;
	$receiveMinute=0;
	$receiveMinute=$_POST['documentMinute'];

	$receiveHour=adjustTime($_POST['docamorpm'],$_POST['documentHour']);
	$receiveDay=$_POST['documentYear']."-".$_POST['selectMonth']."-".$_POST['selectDay'];
	$received_date=$receiveDay." ".$receiveHour.":".$receiveMinute.":00";

	
	$reference_number="HD-".date("Y")."".date("m")."".date("d")."-".date("H")."".date("i")."-".date("s");
	
	$db=new mysqli('localhost','root','','helpdesk');
	$sql="insert into accomplishment(task_id,action_taken,recommendation,status,accomplish_time) values (\"".$_POST['taskId']."\",\"".$_POST['action_taken']."\",\"".$_POST['recommendations']."\",'".$_POST['status']."','".$received_date."')";
	$rs=$db->query($sql);

	echo "Accomplishment has been submitted.<br>";
}
?>
<script language='javascript'>
function disableForm(a){