<?php
date_default_timezone_set('Asia/Kolkata'); 
//echo $date = date("Y-m-d", time());
include ('../config.php');
@session_start();
@$user_id1=$_SESSION['user_id1'];
@$idvfied1=$_SESSION['idverified1'];
@$namevfied1=$_SESSION['namevfied1'];
if(!isset($_SESSION['user_id1'])){
	header("Location: index.php");
}

$timeout = 60 * 60 * 24 * 365;
$s_name = session_name();
if(isset( $_COOKIE[ $s_name ] )) {
  setcookie( $s_name, $_COOKIE[ $s_name ], time() + $timeout, '/' );
}

$sel1=mysqli_query($conn,"select * from hr_dump where empid='".@$user_id1."'");
$fetch1=mysqli_fetch_array($sel1);

$queryFR=mysqli_query($conn,"select * from tracker where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);

$queryFR=mysqli_query($conn,"select * from emp_leave where Functional_Reporting='$fetch1[Employee_Number]'");
$dataFR=mysqli_fetch_array($queryFR);
?>

<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Support Track IC AMS</title>
	
	<?php	include ('header.php');	?>
	
	<div id="appCapsule">
        <div class="section wallet-card-section pt-1">
            <div class="wallet-card">
				<?php	include ('include/wallet-balance.php');	?>
<?php
date_default_timezone_set('Asia/Kolkata'); 
if(isset($_POST['ReqClose']))
{
$query = mysqli_query($conn,"update ams_support set empResponse='".$_POST['empResponse']."', empResponseDate='". date('Y-m-d H:i:s')."', CompletedBy='".$_POST['CompletedBy']."', status='".$_POST['status']."' where id='".$_GET['id']."' ");

if($query==true) {
	echo "<script>window.location.href='support-track.php';</script>";			exit; 
	echo "<div class='alert alert-success col-sm-12'><strong>Successfully updated!</strong> Post details updated Successfully!</div>";
	}

else {
	echo "Error: " . $query . "<br>" . mysqli_error($conn);
	echo "<div class='col-md-12 text-center btn btn-danger'><strong>Error!</strong>Sorry something went wrong!</div>";
	}
}
	
$postquery="select * from ams_support where id='".$_GET['id']."'";
$result=mysqli_query($conn,$postquery);
$datan=mysqli_fetch_assoc($result);
?>
				
				<form class="form-horizontal" name="support" action="" method="post" enctype="multipart/form-data" autocomplete="off">
					<div class="row bg-primary text-white pt-2 mb-2">
						<div class="col-md-7 col-sm-7"><h5>Request For : <?php echo $datan['requestfor']; ?></h5></div>
						<div class="col-md-5 col-sm-5"><h5>Final Status : <?php echo $datan['status']; ?></h5></div>
					</div>	
					<div class="row mt-2 mb-4 border rounded py-2">
						<div class="col-md-3 col-sm-3 mb-1"><b>Department For :</b> <?php echo $datan['DepartmentFor']; ?></div>
						<div class="col-md-3 col-sm-3 mb-1"><b>Location :</b> <?php echo $datan['Location']; ?></div>
						<div class="col-md-3 col-sm-3 mb-1"><b>Assign To :</b> 
							<?php // echo $datan['assignto'];
							$Assignq=mysqli_query($conn,"select * from hr_dump where empid='$datan[assignto]'");
							$dataAssign=mysqli_fetch_array($Assignq);
							echo $dataAssign['Employee_Full_Name'];
							?>
						
						</div>
						<div class="col-md-3 col-sm-3 mb-1"><b>Created at :</b> <?php echo $datan['created_at']; ?></div>
	
						<div class="col-md-6 col-sm-6 mb-1"><b>Description :</b> <?php echo $datan['description']; ?></div>
						<div class="col-md-6 col-sm-6 mb-1"><b>Admin Remark :</b> <?php echo $datan['remark']; ?></div>

						<div class="col-md-12 col-sm-12 text-center">
							<input class="form-control" type="hidden" name="empResponse" value="Resolved" >
							<input class="form-control" type="hidden" name="status" value="Completed" >
							<input class="form-control" type="hidden" name="CompletedBy" value="<?php echo $fetch1['empid']; ?>" >
							<button type="submit" name="ReqClose" class="btn btn-success btn-sm">Close Now</button>
						</div>
					</div>
				</form>
				
				<div class="row">
					<div class="col-md-12 text-center"><a href="support-track.php" class="btn btn-primary btn-sm">Go Back</a></div>
				</div>
				<!--</?php	include ('include/wallet-section.php');	?> -->
            </div>
        </div>
		
		
        
		<!--</?php	include ('include/quik_links.php');	?>
		</?php	include ('include/extra_links.php');	?>-->
	
	<?php	include ('include/copyright.php');	?>
	</div>
	
	<?php	include ('footer.php');	?>