<?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 Create IC AMS</title>
	
	<?php	include ('header.php');	?>
	
	<div id="appCapsule">
        <div class="section wallet-card-section pt-1">
            <div class="wallet-card">
				<!--<div class="balance">
                    <div class="left">
                        <span class="title"></?php echo $fetch1['Employee_Full_Name']; ?></span>
                        <h4></?php echo $fetch1['Team_Name']; ?></h4>
                        <h6></?php echo $date = date("Y-m-d", time()); ?></h6>
                    </div>
                    <div class="right">
                        <a href="#"><img src="../assets/img/noimage.png" alt="logo" class="logo-profile"></a>
                    </div>
                </div>-->
				
				<?php	include ('include/wallet-balance.php');	?>
				
<?php
if(isset($_POST['sublms']))
{
	$query=mysqli_query($conn,"insert into ams_support (empid, empname, team_name, email, phone, DepartmentFor, requestfor, description, Location, status, empResponse, created_by) values ('".$_POST['empid']."', '".$_POST['empname']."', '".$_POST['team_name']."', '".$_POST['email']."', '".$_POST['phone']."', '".$_POST['DepartmentFor']."', '".$_POST['requestfor']."', '".$_POST['description']."', '".$_POST['Location']."', '".$_POST['status']."', '".$_POST['empResponse']."', '".$_POST['created_by']."')");
	//echo "<pre>"; print_r($_POST); exit;
	if($query==true)
		{
		echo "<script>window.location.href='support-track.php';</script>";         exit;
        echo "<div class='col-md-12 text-center btn btn-success'>Your details submitted successfully! </div>";
		}
	else
		{
		echo mysqli_error($conn);
		echo "<div class='col-md-12 text-center btn btn-danger'><strong>Error!</strong>Sorry something went wrong!</div>";	}
}
?>
					<form class="form-horizontal" name="cvt" action="" method="post" enctype="multipart/form-data" autocomplete="off">
						<div class="row"><hr>
							<div class="col-md-12 col-sm-12 text-center"><h4>Create new request</h4></div>
								<input class="form-control uc" type="hidden" name="empid" id="empid" value="<?php echo $fetch1['empid']; ?>" />
								<input class="form-control" type="hidden" name="empname" id="Employee_Full_Name" value="<?php echo $fetch1['Employee_Full_Name']; ?>" >
								<input class="form-control" type="hidden" name="team_name" id="Team_Name" value="<?php echo $fetch1['Team_Name']; ?>" >
								<input class="form-control" type="hidden" name="email" value="<?php echo $fetch1['Official_Email_Address_Long']; ?>" >
								<input class="form-control" type="hidden" name="phone" value="<?php echo $fetch1['Official_Mobile_1']; ?>" >

<script type="text/javascript">
function showSubDropdown() {
	var selectedValue = document.getElementById("DepartmentFor").value;
	var requestfor = document.getElementById("requestfor");
	requestfor.innerHTML = "";
	if (selectedValue === "AMS") {
		var options = ["New User(New Joining)", "No Value PunchIn/Out", "No Value Office Location", "Week Off Issues", "My Team Issues", "Out of Range", "Other"];
	} else if (selectedValue === "Admin") {
		var options = ["Office Supplies Request", "Travel Arrangements", "Emergency Response", "Security Concerns"];
	} else if (selectedValue === "HR") {
		var options = ["Employee Benefits", "Payroll and Salary", "Leave and Week Off", "Recruitment and Hiring", "Employee Onboarding", "Training and Development"];
	} else if (selectedValue === "IT") {
		var options = ["AMS Location Fetching Issues", "Audio System", "Backup and Recovery", "Battery and Power", "Cable Issues", "CCTV Issues", "CCTV Recording", "CPU Issues", "Door Access", "Desktop Not working", "Email Create", "Email Deactivate", "Email Issues", "Email Password Reset", "EPBX Issues", "Internet Issues", "Landline Phone Issues", "Laptop Not working", "LCD LED Display", "Mobile Device",  "Monthly Backup", "Mouse Keyboard Etc", "Monitor Problems", "Outlook not Working", "Printer Issues", "Software Issues", "System Shifting", "System Setup", "Wifi Issues", "Zoom Meeting"];
	} else if (selectedValue === "Salesforce") {
		var options = ["Login Issues", "Data Not Showing"];
	} else {
		var options = ["-Select Department First-"];
	}
	for (var i = 0; i < options.length; i++) {
		var option = document.createElement("option");
		option.text = options[i];
		option.value = options[i];
		requestfor.add(option);
	}
}
</script>

							<div class="col-md-2 col-sm-2">
								<label>Request  To<span class="text-danger">*</span></label>
								<select class="form-control" name="DepartmentFor" id="DepartmentFor"  onchange="showSubDropdown()" required>
									<option value="">-Select-</option>
									<option value="AMS">AMS Department</option>
									<option value="IT">IT Department</option>
									<!--
									<option value="Admin">Admin Department</option>
									<option value="HR">HR Department</option>
									<option value="Salesforce">Salesforce</option>-->
								</select>
							</div>
							
							<div class="col-md-2 col-sm-2">
								<label>Request For <span class="text-danger">*</span></label>
								<select class="form-control" id="requestfor" name="requestfor" required>
									<option value="">-Select Department First-</option>
								</select>
							</div>
							<div class="col-md-5 col-sm-5"><label>Description <span class="text-danger">*</span></label>
								<input class="form-control" type="text" name="description" placeholder="Description (Required)" required>
							</div>
							<div class="col-md-3 col-sm-3"><label>Office Location <span class="text-danger">*</span></label>
								<input class="form-control" type="text" name="Location" placeholder="Astralis, BW, Irish Tech Park . . ." required>
							</div>
						</div>
						<input class="form-control" type="hidden" name="status" value="Pending">
						<input class="form-control" type="hidden" name="empResponse" value="Pending">
						<input class="form-control" type="hidden" name="created_by" value="<?php echo $fetch1['empid']; ?>">
						<div class="col-md-12 col-sm-12 mt5 text-center"><br>
							<button type="submit" name="sublms" class="btn btn-success" onclick="setCookie('redirectCookie', 'enquire');">Submit</button>
						</div>
					</form>
				<!--</?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');	?>