<?php 
include("includes/FCKeditor/fckeditor.php");
$file_name		= "index?page=view";
$form_action	= "insert";
$button_value 	= "Add";
$table_name 	= "leave_holiday_management";
$id	 = "";
$vat = "";
$query_string = "";
$page_name      = "Leave Request";
$from = $_REQUEST['from'];
$employee_name_id = $_SESSION['admin_user_id'];
$clock_no_id = $_SESSION['admin_user_id'];
################################################## START INSERT ##################################################
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'insert'){	
	utility::addslashesOnAllInput(array("query_string"));
	
    $employee_name_id				= $_REQUEST['employee_name_id'];
	$clock_no_id					= $_REQUEST['clock_no_id'];
	
	$leave_start_time				= $_REQUEST['leave_start_time'];	
	$leave_holiday_start_date		= utility::setFormatedDate($_REQUEST['leave_holiday_start_date']);
	$leave_end_time					= $_REQUEST['leave_end_time'];
	$leave_holiday_end_date		    = utility::setFormatedDate($_REQUEST['leave_holiday_end_date']);
	
	$is_bereavement_leave			= $_REQUEST['is_bereavement_leave'];	
	$is_paternity_leave		        = $_REQUEST['is_paternity_leave'];
	$is_doctor_dentist_appointment	= $_REQUEST['is_doctor_dentist_appointment'];
	$is_parental_leave_unpaid		= $_REQUEST['is_parental_leave_unpaid'];	
	$is_time_off_dependent_emergency	= $_REQUEST['is_time_off_dependent_emergency'];	
	$is_extended_unpaid_leave		= $_REQUEST['is_extended_unpaid_leave'];
	$is_other_reason				= $_REQUEST['is_other_reason'];
	
	$leave_further_details			= $_REQUEST['leave_further_details'];
	$is_leave_authorised			= $_REQUEST['is_leave_authorised'];
	$leave_authorised_by			= $_REQUEST['leave_authorised_by'];
	$leave_auth_date_time			= utility::setFormatedDate($_REQUEST['leave_auth_date_time']);	
	$is_received_hrs_in_adv			= $_REQUEST['is_received_hrs_in_adv'];
	$rejection_reason				= $_REQUEST['rejection_reason'];
	$leave_actions					= $_REQUEST['leave_actions'];

	$created_by					= $_SESSION['user_id'];
	$created_on					= date("Y-m-d H:i:s");	
	$updated_by					= $_SESSION['user_id'];
	$leave_holiday_type			= 2;

	$sql = "employee_name_id = '".$employee_name_id."', clock_no_id = '".$clock_no_id."', leave_start_time = '".$leave_start_time."', leave_holiday_start_date = '".$leave_holiday_start_date."', leave_end_time = '".$leave_end_time."', leave_holiday_end_date = '".$leave_holiday_end_date."', is_bereavement_leave = '".$is_bereavement_leave."', is_paternity_leave = '".$is_paternity_leave."', is_doctor_dentist_appointment = '".$is_doctor_dentist_appointment."', is_parental_leave_unpaid = '".$is_parental_leave_unpaid."', is_time_off_dependent_emergency = '".$is_time_off_dependent_emergency."', is_extended_unpaid_leave = '".$is_extended_unpaid_leave."', is_other_reason = '".$is_other_reason."', leave_further_details = '".$leave_further_details."', is_authorised = '".$is_leave_authorised."', authorised_by = '".$leave_authorised_by."', auth_date_time = '".$leave_auth_date_time."',is_received_hrs_in_adv = '".$is_received_hrs_in_adv."', rejection_reason = '".$rejection_reason."', leave_actions = '".$leave_actions."', leave_holiday_type = '".$leave_holiday_type."',created_on = '".$created_on."', created_by = '".$created_by."', updated_by = '".$updated_by."'";

	$sql= "INSERT INTO $table_name SET ".$sql; 


	mysqli_query($conn,$sql);
	$leave_id = mysqli_insert_id($conn);

	
	if(isset($_FILES['document_upload']['name']) && $_FILES['document_upload']['name'] !=""){
		$path = $_FILES['document_upload']['name'];
		$ext = pathinfo($path, PATHINFO_EXTENSION);
		if($ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "JPG" || $ext == "JPEG" || $ext == "PNG" || $ext == "pdf"){
			$digits = 5;
			$random_number = rand(pow(10, $digits-1), pow(10, $digits)-1);
			$uploaddir = 'leave_documents/';
			$old_document	=	$uploaddir.$hidden_document_upload;	
			if(file_exists($old_document)){
				unlink($old_document);
			}
			$document_upload_array = explode(".",$_FILES['document_upload']['name']);
			$docu_ext = array_pop($document_upload_array);
			$doc_name = implode('.', $document_upload_array);
			//$document_upload = $id."_".$document_upload_array[0]."_".$random_number.".".$document_upload_array[1];
			$document_upload = $leave_id."_".$doc_name."_".$random_number.".".$docu_ext;
			$document_upload = str_replace(" ","_",$document_upload);
			$uploadfile = $uploaddir . $document_upload;
			move_uploaded_file($_FILES['document_upload']['tmp_name'], $uploadfile);
			$sql= "UPDATE $table_name SET document_upload = '$document_upload' WHERE id = '$leave_id' ";
			mysqli_query($conn,$sql);
			
			$_SESSION['info_message'] = "File added successfully";
		}else{
			$document_upload = $hidden_document_upload;
			$_SESSION['message'] = "Please upload only pdf/jpg/jpeg/png";
		}
    }
	
	
	$_SESSION['info_message'] = "Leave Request added successfully";
	header("Location: $file_name");
    exit();
}
################################################# END INSERT #################################################

################################################## START EDIT ##################################################
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit'){	
	$id = $_REQUEST['id'];
	$leave_id = utility::app_crypt($_REQUEST['leave_id'],'d');
		if($_REQUEST['id'] != $leave_id){
			die("Invaild URL");
		}
	$form_action 	= "update";
	$button_value 	= "Update";
	$page_name      = "Edit Leave Request";
	$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
	
    $sql= "SELECT * FROM $table_name WHERE id = $id";
    $result_edit = mysqli_query($conn,$sql);
    $row_edit = mysqli_fetch_array($result_edit);
	$row_edit = utility::validate_crypt_data($row_edit);
	
    $employee_name_id				= $row_edit['employee_name_id'];
	$clock_no_id					= $row_edit['clock_no_id'];
	
	$leave_start_time				= $row_edit['leave_start_time'];	
	$leave_holiday_start_date		= $row_edit['leave_holiday_start_date'];
	$leave_end_time					= $row_edit['leave_end_time'];
	$leave_holiday_end_date		    = $row_edit['leave_holiday_end_date'];
	
	$is_bereavement_leave			= $row_edit['is_bereavement_leave'];	
	$is_paternity_leave		        = $row_edit['is_paternity_leave'];
	$is_doctor_dentist_appointment	= $row_edit['is_doctor_dentist_appointment'];
	$is_parental_leave_unpaid		= $row_edit['is_parental_leave_unpaid'];	
	$is_time_off_dependent_emergency	= $row_edit['is_time_off_dependent_emergency'];	
	$is_extended_unpaid_leave		= $row_edit['is_extended_unpaid_leave'];
	$is_other_reason				= $row_edit['is_other_reason'];
	
	$leave_further_details			= $row_edit['leave_further_details'];
	$is_leave_authorised			= $row_edit['is_authorised'];
	$leave_authorised_by			= $row_edit['authorised_by'];
	$leave_auth_date_time			= $row_edit['auth_date_time'];
	$is_received_hrs_in_adv			= $row_edit['is_received_hrs_in_adv'];
	$rejection_reason				= $row_edit['rejection_reason'];
	$leave_actions					= $row_edit['leave_actions'];
	$document_upload			    = $row_edit['document_upload'];
}
################################################# END EDIT ################################################# 


################################################## START UPDATE ################################################## 
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'update'){    
	utility::addslashesOnAllInput(array("query_string"));
	
	$id  						= $_REQUEST['id'];
	
    $employee_name_id  			= $_REQUEST['employee_name_id'];
	$clock_no_id			    = $_REQUEST['clock_no_id'];
	
	$leave_start_time			= $_REQUEST['leave_start_time'];	
	$leave_holiday_start_date	= utility::setFormatedDate($_REQUEST['leave_holiday_start_date']);
	$leave_end_time				= $_REQUEST['leave_end_time'];
	$leave_holiday_end_date		= utility::setFormatedDate($_REQUEST['leave_holiday_end_date']);
	
	$is_bereavement_leave			= $_REQUEST['is_bereavement_leave'];	
	$is_paternity_leave		        = $_REQUEST['is_paternity_leave'];
	$is_doctor_dentist_appointment	= $_REQUEST['is_doctor_dentist_appointment'];
	$is_parental_leave_unpaid		= $_REQUEST['is_parental_leave_unpaid'];	
	$is_time_off_dependent_emergency	= $_REQUEST['is_time_off_dependent_emergency'];	
	$is_extended_unpaid_leave		= $_REQUEST['is_extended_unpaid_leave'];
	$is_other_reason				= $_REQUEST['is_other_reason'];
	
	$leave_further_details			= $_REQUEST['leave_further_details'];
	$is_leave_authorised			= $_REQUEST['is_leave_authorised'];
	$leave_authorised_by			= $_REQUEST['leave_authorised_by'];
	$leave_auth_date_time			= utility::setFormatedDate($_REQUEST['leave_auth_date_time']);	
	$is_received_hrs_in_adv			= $_REQUEST['is_received_hrs_in_adv'];
	$rejection_reason				= $_REQUEST['rejection_reason'];
	$leave_actions					= $_REQUEST['leave_actions'];
	
	$hidden_document_upload 		= $_REQUEST['hidden_document_upload'];
	if(isset($_FILES['document_upload']['name']) && $_FILES['document_upload']['name'] !=""){
		$path = $_FILES['document_upload']['name'];
		$ext = pathinfo($path, PATHINFO_EXTENSION);
		if($ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "JPG" || $ext == "JPEG" || $ext == "PNG" || $ext == "pdf"){
			$digits = 5;
			$random_number = rand(pow(10, $digits-1), pow(10, $digits)-1);
			$uploaddir = 'leave_documents/';
			$old_document	=	$uploaddir.$hidden_document_upload;	
			if(file_exists($old_document)){
				unlink($old_document);
			}
			$document_upload_array = explode(".",$_FILES['document_upload']['name']);
			$docu_ext = array_pop($document_upload_array);
			$doc_name = implode('.', $document_upload_array);
			//$document_upload = $id."_".$document_upload_array[0]."_".$random_number.".".$document_upload_array[1];
			$document_upload = $id."_".$doc_name."_".$random_number.".".$docu_ext;
			$document_upload = str_replace(" ","_",$document_upload);
			$uploadfile = $uploaddir . $document_upload;
			move_uploaded_file($_FILES['document_upload']['tmp_name'], $uploadfile);
			
			$_SESSION['info_message'] = "File updated successfully";
		}else{
			$document_upload = $hidden_document_upload;
			$_SESSION['message'] = "Please upload only pdf/jpg/jpeg/png";
		}
    }else{
		$_SESSION['info_message'] = "File updated successfully";
		$document_upload = $hidden_document_upload;
	}
	
	
	$updated_by		 		    = $_SESSION['user_id'];
	
	$sql = "employee_name_id = '".$employee_name_id."', clock_no_id = '".$clock_no_id."', leave_start_time = '".$leave_start_time."', leave_holiday_start_date = '".$leave_holiday_start_date."', leave_end_time = '".$leave_end_time."', leave_holiday_end_date = '".$leave_holiday_end_date."', is_bereavement_leave = '".$is_bereavement_leave."', is_paternity_leave = '".$is_paternity_leave."', is_doctor_dentist_appointment = '".$is_doctor_dentist_appointment."', is_parental_leave_unpaid = '".$is_parental_leave_unpaid."', is_time_off_dependent_emergency = '".$is_time_off_dependent_emergency."', is_extended_unpaid_leave = '".$is_extended_unpaid_leave."', is_other_reason = '".$is_other_reason."', leave_further_details = '".$leave_further_details."',is_received_hrs_in_adv = '".$is_received_hrs_in_adv."', rejection_reason = '".$rejection_reason."', leave_actions = '".$leave_actions."',document_upload = '".$document_upload."',updated_by = '".$updated_by."'";
	$sql= "UPDATE $table_name SET ".$sql." WHERE id = '".$id."'";
    mysqli_query($conn,$sql);
	
	$query_string = (isset($_REQUEST['query_string']) && !empty($_REQUEST['query_string'])) ? $_REQUEST['query_string'] : "";
	
  	$query_string = str_ireplace("page=add", "page=view", $query_string);
	$query_string = "&".$query_string;
	
	$leave_id = urlencode(utility::app_crypt($id,'e'));
	
	$_SESSION['info_message'] = "Leave Request updated successfully";
	if(isset($from) && $from == "view_leave_progress"){
		header("Location: index?page=view_leave_progress&from=view_customer&leave_id=$leave_id&id=$id");
		exit();
	}
	
    header("Location: $file_name$query_string");
    exit();
}
################################################# END UPDATE ################################################# 
?>
<style>
em{color:red;font-size: 20px;position: absolute;}

fieldset {
    border-top: 4px solid #dedede; 
    border-right: 1px solid #dedede;
    border-bottom: 1px solid #dedede; 
    border-left: 1px solid #dedede; 
    padding: 15px;
    margin-bottom: 10px;
}

legend {
    width: auto;
    color: #a423a4;
}
</style>

<section class="content-header">
	<div class="container-fluid">
		<div class="row mb-2">
			<div class="col-sm-6">
				<h1>
					<?=$page_name;?>
				</h1>
			</div>
			<div class="col-sm-6">
			<?
			$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
			if(isset($from) && $from == "view_leave_progress"){
				$query_string = str_ireplace("page=add", "page=view_leave_progress", $query_string);
			}else {
				$query_string = str_ireplace("page=add", "page=view", $query_string);
			}
				
			?>
			<button type="button" id="back" name="back" value="back"  style="float:right;margin-right:5px;margin-bottom:8px;" class="btn btn-primary" onclick="window.location.href = 'index?<?=$query_string;?>'">Back</button>
			</div>
		</div>
	</div>
</section>
<section class="content">
	<div class="row">
		<div class="col-12">
			<!----------------------- Message ------------------------------->
			<? if(isset($_SESSION['info_message'])){ ?>
			  <div class="alert alert-info alert-dismissable">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
				<? echo $_SESSION['info_message']; unset($_SESSION['info_message']);?>
			  </div>
			  <? } ?>
			<!----------------------- End Message ------------------------------->
			<!-- general form elements -->
              <div class="card">
                <form class="" method="post" name="form1" id="form1" action="index?page=add&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
                  <div class="card-body">
					  <div class="row">
						  <div class="col-lg-12 col-sm-12">
							<div class="row">
								<div class="form-group col-lg-3">
									<div class="">
									  <label class="control-label " for="Employee Name">Employee Name<em>*</em></label>
										<? $gsi->getEmployeeList("employee_name_id", $employee_name_id, "100%", false, "form-control employee_name_id"); ?>

									</div>
								</div>
								<div class="form-group col-lg-3">
								  <div class="">
									<label class="control-label" for="Clock No.">Clock No.<em>*</em></label>
									 <? $gsi->getEmployeeClockNoList("clock_no_id", $clock_no_id, "100%", false, "form-control"); ?>
								 </div>
								</div>
							</div>
							<div class="row">
							 <div class="form-group col-lg-3"> 
								<label class="control-label" for="Leave Start Date">Leave Start Date</label> 
								<div class="">
									<input type="text" class="form-control datepicker" id="leave_holiday_start_date" name="leave_holiday_start_date"  value="<?php echo (isset($leave_holiday_start_date) && $leave_holiday_start_date !="") ? utility::getFormatedDate($leave_holiday_start_date) : "";?>" placeholder="DD-MM-YYYY" autocomplete="off">
								</div>
							</div>
							<div class="form-group col-lg-3"> 
								<label class="control-label" for="Leave Start Time">Leave Start Time</label> 
								<div class="">
									<? utility::getTimeList("leave_start_time", $leave_start_time,"00:00","Time",false,"form-control select2",""); ?>
								</div>
							</div>
							<div class="form-group col-lg-3"> 
								<label class="control-label" for="Leave End Date">Leave End Date</label> 
								<div class="">
									<input type="text" class="form-control datepicker" id="leave_holiday_end_date" name="leave_holiday_end_date"  value="<?php echo (isset($leave_holiday_end_date) && $leave_holiday_end_date !="") ? utility::getFormatedDate($leave_holiday_end_date) : "";?>" placeholder="DD-MM-YYYY" autocomplete="off">
								</div>
							</div>
							<div class="form-group col-lg-3"> 
								<label class="control-label" for="Leave End Time">Leave End Time</label>
								<div class="">
									<? utility::getTimeList("leave_end_time", $leave_end_time,"00:00","Time",false,"form-control select2",""); ?>
								</div>
							</div>
							</div>
							<div class="form-section mt-2">
							<h4 class="" style="margin-top: 0; margin-bottom: 0;color:#9c4893;">Reasons</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
							<div class="form-group col-lg-6">
							<div class="row">
							<div class="form-group col-lg-6">
								<label class="control-label" for="Bereavement Leave">Bereavement Leave<em></em></label>
								</div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_bereavement_leave" name="is_bereavement_leave" value="1"  <?php echo ($is_bereavement_leave ==1) ? 'checked':''; ?>> 
								</div>
							</div>
							</div>
							<div class="form-group col-lg-6">
							<div class="row">
							<div class="form-group col-lg-6">
								<label class="control-label" for="Paternity Leave">Paternity Leave<em></em></label>
								<span class="small" style="display: block; margin-top: -9px;">(see notes in Employee Handbook)</span>
								</div>
								<div class="col-lg-6">
								    <input type="checkbox" class="flat-red" id="is_paternity_leave" name="is_paternity_leave" value="1"  <?php echo ($is_paternity_leave ==1) ? 'checked':''; ?>> 
								</div>
						    </div>
							</div>
							</div>
							<div class="row">
							<div class="form-group col-lg-6">
							<div class="row">
								<div class="col-lg-6">
								<label class="control-label" for="appointment">
									Doctor / Dentist / Hospital Appointment<em></em>
								</label>
								<span class="small" style="display: block; margin-top: -9px;">(please attach copy of appointment card)</span>
                                </div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_doctor_dentist_appointment" name="is_doctor_dentist_appointment" value="1" <?php echo ($is_doctor_dentist_appointment == 1) ? 'checked' : ''; ?>>
								</div>
								<div class="form-group">
									<input type="file" name="document_upload" id="document_upload" accept=".pdf,.jpg,.jpeg,.png"/>
									<div>
										<?php
										$dir = "leave_documents/";
										if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
											if (is_file($dir . $document_upload)) {
												$ext = pathinfo($document_upload, PATHINFO_EXTENSION);
												if ($ext == "jpg" || $ext == "jpeg" || $ext == "png") {
													$image_path = '<a href="../' . $dir . $document_upload . '" target="_blank"><img class="primary text-primary" style="width:100px;border:1px solid #777" src="../' . $dir . $document_upload . '"> </a>';
												} elseif ($ext == "pdf") {
													$image_path = '<a href="../' . $dir . $document_upload . '" target="_blank"><span class="primary text-primary" title="' . $document_upload . '">' . utility::ellipsis($document_upload, 20) . '</span></a>';
												}
											} else {
												$image_path = '<img style="width:100px;border:1px solid #777" src="../' . $dir . 'no-image.gif">';
											}
											echo $image_path;
										}
										?>
										<input type="hidden" name="hidden_document_upload" value="<?php echo $document_upload; ?>">
									</div>
								</div>
							</div>
                          </div>
							<div class="form-group col-lg-6">
							    <div class="row">
								<div class="col-lg-6">
								<label class="control-label" for="Parental Leave- 'unpaid'">Parental Leave- 'Unpaid'<em></em></label>
								<span class="small" style="display: block; margin-top: -9px;">(see notes in Employee Handbook)</span>
								</div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_parental_leave_unpaid" name="is_parental_leave_unpaid" value="1"  <?php echo ($is_parental_leave_unpaid ==1) ? 'checked':''; ?>> 
								</div>
								</div>
							</div>
							</div>
							<div class="row">
							<div class="form-group col-lg-6">
							<div class="row">
								<div class="col-lg-6">
								<label class="control-label" for="Time Off Work To Care A Dependent/ Family Emergency - 'Unpaid'">Time Off Work To Care A Dependent/ Family Emergency - 'Unpaid'<em></em></label>
								</div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_time_off_dependent_emergency" name="is_time_off_dependent_emergency" value="1"  <?php echo ($is_time_off_dependent_emergency ==1) ? 'checked':''; ?>> 
								</div>
								</div>
							</div>
							<div class="form-group col-lg-6">
							<div class="row">
								<div class="col-lg-6">
								<label class="control-label" for="Extended 'Unpaid' leave">Extended 'Unpaid' leave<em></em></label>
								<span class="small" style="display: block; margin-top: -9px;">(see notes in Employee Handbook)</span>
								</div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_extended_unpaid_leave" name="is_extended_unpaid_leave" value="1"  <?php echo ($is_extended_unpaid_leave ==1) ? 'checked':''; ?>> 
								</div>
								</div>
							</div>
							<div class="form-group col-lg-6">
							<div class="row">
								<div class="col-lg-6">
								<label class="control-label" for="Other Reason">Other Reason<em></em></label>
								</div>
								<div class="col-lg-6">
									<input type="checkbox" class="flat-red" id="is_other_reason" name="is_other_reason" value="1"  <?php echo ($is_other_reason ==1) ? 'checked':''; ?>> 
								</div>
								</div>
							</div>
							</div>
							</div>
							<div class="row">
								<div class="form-group col-lg-12">
								  <label class="control-label" for="leave_further_details">Please give further details relating to the above reason:-(i.e. name of person / relationship to you etc.)<em></em></label>
								  <div class="">
									<textarea id="leave_further_details" name="leave_further_details" rows="3" cols="50" maxlength="500" class="form-control" placeholder="Please give further details relating to the above reason"  style="resize: vertical;"><?php echo $leave_further_details;?></textarea>
								  </div>
								</div>
							</div>
							<div class="row">
							    <div class="form-group col-lg-4">
									<label class="control-label" for="Authorised">Authorised?<em></em></label>
									<div class="">
										<input type="checkbox" class="flat-red" id="is_leave_authorised" name="is_leave_authorised" value="1"  <?php echo ($is_leave_authorised ==1) ? 'checked':''; ?>> 
									</div>
								</div>
								<div class="form-group col-lg-4">
									<div class="">
									  <label for="authorisedBy" class="form-label">Authorised By</label>
								<? $gsi->getEmployeeList("leave_authorised_by", $leave_authorised_by, "100%", false, "form-control"); ?>
									</div>
								</div>
								<div class="form-group col-lg-4">
									<label class="control-label" for="Authorised Date & Time">Authorised Date & Time</label>
									<div class="d-flex">
										<input type="text" class="form-control datepicker" id="leave_auth_date_time" name="leave_auth_date_time" value="<?php echo (isset($leave_auth_date_time) && $leave_auth_date_time != "") ? date("d-m-Y H:i:s", strtotime($leave_auth_date_time)) : ""; ?>" placeholder="DD-MM-YYYY" autocomplete="off" readonly>
										<?// utility::getTimeList("leave_auth_time", $leave_auth_time,"00:00","Time",false,"form-control select2",""); ?>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-lg-12">
								  <label class="control-label" for="rejection_reason">Rejection Reason<em></em></label>
								  <div class="">
									<textarea id="rejection_reason" name="rejection_reason" rows="3" cols="50" maxlength="500" class="form-control" placeholder="Rejection Reason"  style="resize: vertical;" readonly><?php echo $rejection_reason;?></textarea>
								  </div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-lg-4">
									<label class="control-label" for="Received 24 hours in advance?">Received 24 hours in advance?<em></em></label>
									<div class="">
										<input type="checkbox" class="flat-red" id="is_received_hrs_in_adv" name="is_received_hrs_in_adv" value="1"  <?php echo ($is_received_hrs_in_adv ==1) ? 'checked':''; ?>> 
									</div>
								</div>
								<div class="form-group col-lg-4">
									<div class="">
									  <label class="control-label" for="Actions">Actions<em></em></label>
										<input type="text" id="leave_actions" name="leave_actions" value="<?php echo $leave_actions;?>" class="form-control" placeholder="Actions">
									</div>
								</div>
							</div>
							
						 </div>
					  </div><!-- /.row -->
                  </div><!-- /.box-body -->
                  <div class="card-footer">
					<input type="hidden" id="id" name="id" value="<?php echo $id;?>">
					<input type="hidden" id="from" name="from" value="<?php echo $from;?>">
					<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
                    <button type="submit" id="submit" name="submit" value="<?php echo $button_value;?>" class="btn btn-primary">Submit
						<i class="fas fa-sync-alt fa-spin" style="display:none;" id="page_load_div"></i>
					</button>
                  </div>
                </form>
              </div><!-- /.box -->
		</div>
	</div>
</section>
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="<?php echo $siteURL ?>/bootstrap-old/css/bootstrap.css">

<script type="text/javascript">
$(document).ready(function(){
	$("#employee_name_id").prop("disabled", true);
	$("#leave_auth_date_time").prop("disabled", true);
	$("#is_leave_authorised").prop("disabled", true);
	$("#clock_no_id").prop("disabled", true);
	$("#leave_authorised_by").prop("disabled", true);
	
	$('#form1').submit(function(){
		$("#submit").attr("disabled", true);
		$("#employee_name_id").prop("disabled", false);
		$("#clock_no_id").prop("disabled", false);
		$("#is_leave_authorised").prop("disabled", false);
		$("#leave_auth_date_time").prop("disabled", false);
		$("#leave_authorised_by").prop("disabled", false);
		$('#page_load_div').show();
	});
	
});
</script>
