<style type="text/css">
/*google map*/
#map {
	height: 300px;
}

#description {
	font-family: Roboto;font-size: 15px;font-weight: 300;
}

#infowindow-content .title {
	font-weight: bold;
}

#infowindow-content {
	display: none;
}

#map #infowindow-content {
	display: inline;
}

.pac-card {
	margin: 10px 10px 0 0;border-radius: 2px 0 0 2px;box-sizing: border-box;-moz-box-sizing: border-box;outline: none;box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);background-color: #fff;font-family: Roboto;
}

#pac-container {
	padding-bottom: 12px;margin-right: 12px;
}

.pac-controls {
	display: inline-block;padding: 5px 11px;
}

.pac-controls label {
	font-family: Roboto;font-size: 13px;font-weight: 300;
}

.error{
	box-shadow: 0 0 5px rgba(238, 75, 81, 1);
    padding: 3px 0px 3px 3px;
    margin: 5px 1px 3px 0px;
    border: 1px solid rgba(238, 75, 81, 1);
}
.success{
    box-shadow: 0 0 5px rgba(75, 238, 81, 1);
    padding: 3px 0px 3px 3px;
    margin: 5px 1px 3px 0px;
    border: 1px solid rgba(75, 238, 81, 1);
}
</style>

<section class="container-fluid">
	<div class="row">
		<div class="col-md-6">
			<div class="card bg-light-transparent" style="margin-bottom: 2rem;">
				<div class="card-header bg-white">
					<div class="float-left">
						<h5 class="card-title">Calendar</h5>
					</div>
				</div>
				<div class="card-body">
					<div class="card bg-white no-shadow">
						<div class="card-body">
							<div class="row">
								<div class="col-12">
									<div id="calendar"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-6">
			<div class="card bg-light-transparent" style="margin-bottom: 2rem;">
				<div class="card-header bg-white">
					<h5 class="card-title">Upcoming Hotel Booking</h5>
				</div>
				<div class="card-body">
					<div class="card bg-white no-shadow">
						<div class="card-body">
							<?php if(!empty($upcoming_request)): foreach($upcoming_request as $upcoming): ?>
								<div class="row">
									<div class="col-auto">
										<p data-trigger="hover" data-tooltip="tooltip" title="<?php echo $upcoming['dept_name'].'['.$upcoming['branchName'].']'; ?>"><?php echo $upcoming['dept_name'].'/'.$upcoming['branchName']; ?></p>
									</div>
									<div class="col text-right">
										<p><?php echo date('d-m-Y',strtotime($upcoming['checkin_date'])); ?></p>
									</div>
								</div>
							<?php endforeach;endif; ?>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<section class="container" style="padding-bottom: 2rem;">
	<div class="row">
		<div class="col-sm-12">
			<div class="tab-content" id="tabContent">
				<div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
					<div class="card bg-light-transparent">
						<div class="card-header bg-light">
							<h4 class="card-title"><?php echo (empty($ID))?'New ':'Edit '; ?> Hotel Booking Form</h4>
							<h6 class="card-title"><i>Instruction: Please make sure check in time before 48 hours.</i></h6>
						</div>
						<div class="card-body">
							<div class="card no-shadow">
								<div class="card-body">
									<?php if(!empty($ID)){ ?>
										<form id="hotelForm" class="form" action="<?php echo base_url('hr/Serviceform/hotel_edit') ?>" method="POST" onsubmit="return confirm('Confirm to update this form?')">
										<?php }else{ ?>	
											<form id="hotelForm" class="form" action="<?php echo base_url('hr/Serviceform/hotel_save') ?>" method="POST" onsubmit="return confirm('Confirm to proceed to room arrangment detail?')">
											<?php }?>

											<input type="text" class="form-control" name="hotelID" id="hotelID" value="<?php echo $ID; ?>" hidden>

											<div class="form-row">
												<div class="col-12">
													<div class="form-group">
														<h5><b>Requestor Info</b></h5>
														<hr>
														<div class="form-row">
															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label>Name</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control" name="name" id="name" value="<?php echo $row['created_name']; ?>" readonly/>	
																			<input type="text" class="form-control" name="name_id" id="name_id" value="<?php echo $row['createdBY']; ?>" hidden>
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control" name="name" id="name" value="<?php echo $_SESSION['user']['name']; ?>" readonly/>	
																			<input type="text" class="form-control" name="name_id" id="name_id" value="<?php echo $_SESSION['user']['id']; ?>" hidden>
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label for="email">Email Address</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control" name="email" id="email" value="<?php echo $row['created_email']; ?>" readonly/>
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control" name="email" id="email" value="<?php echo $_SESSION['user']['email']; ?>" readonly/>
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label for="department">Department</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control" name="department" id="department" value="<?php echo $row['created_dept_name'].' ['.$row['created_branchName'].']'; ?>" readonly/>
																			<input type="text" class="form-control" name="department_id" id="department_id" value="<?php echo $row['created_department_id']; ?>" hidden>
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control" name="department" id="department" value="<?php echo $_SESSION['user']['department_name'].' ['.$_SESSION['user']['branch_name'].']'; ?>" readonly/>
																			<input type="text" class="form-control" name="department_id" id="department_id" value="<?php echo $_SESSION['user']['department_id']; ?>" hidden>
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label for="datereq">Date Request</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="" class="form-control" name="datereq" id="datereq" value="<?php echo (!empty($ID))?date("d-m-Y",strtotime($row['createdTS'])):''; ?>" readonly/>
																		<?php endforeach;endif; } else { ?>
																			<input type="" class="form-control" name="datereq" id="datereq" value="<?php echo date("d-m-Y"); ?>" readonly/>
																		<?php } ?>
																</div>
															</div>
														</div>

														<br>

														<h5><b>Hotel Info</b></h5>
														<hr>

														<div class="form-row">
															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label for="hotelname">Hotel Name</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control" name="hotelname" id="hotelname" value="<?php echo (!empty($ID))?$row['hotel_name']:''; ?>">
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control" name="hotelname" id="hotelname" required>
																		<?php } ?>
																</div>
															</div>
															
															<div class="col-12 col-sm-6">
																<div class="form-group">
																	<label for="location">Hotel Location</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control" name="location" id="location" value="<?php echo (!empty($ID))?$row['location']:''; ?>">
																		<?php endforeach;endif; } else{ ?>
																			<input class="form-control" type="search" name="location" id="find_location" type="text" placeholder="Search Location" aria-label="Search" required>
																	<?php } ?>
																	<br>
																	
																	<div class="d-none" id="map"></div>
								                                       <div id="infowindow-content">
								                                        	<img src="" width="16" height="16" id="place-icon">
								                                          	<span id="place-name"  class="title"></span><br>
								                                          	<span id="place-address"></span>
								                                       </div>

																</div>
															</div>
															
															<div class="col-12 col-sm-3">
																<div class="form-group">
																	<label for="checkin_date">Check In Date</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control datepicker" name="checkin_date" id="checkin_date" value="<?php echo (!empty($ID))?date('d-m-Y',strtotime($row['checkin_date'])):''; ?>" onchange="calculate_request_hour()">
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control datepicker" name="checkin_date" id="checkin_date" required onchange="calculate_request_hour()">
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-3">
																<div class="form-group">
																	<label for="checkin_time"> Check In Time</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input placeholder="Select time" type="text" class="form-control timepicker" name="checkin_time" id="checkin_time" value="<?php echo (!empty($ID))?$row['checkin_time']:''; ?>" onchange="calculate_request_hour()">
																		<?php endforeach;endif; } else{ ?>
																			<input placeholder="Select time" type="text" class="form-control timepicker" name="checkin_time" id="checkin_time" required onchange="calculate_request_hour()">
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-3">
																<div class="form-group">
																	<label for="checkout_date">Check Out Date </label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input type="text" class="form-control datepicker" name="checkout_date" id="checkout_date" value="<?php echo (!empty($ID))?date('d-m-Y',strtotime($row['checkout_date'])):''; ?>">
																		<?php endforeach;endif; } else{ ?>
																			<input type="text" class="form-control datepicker" name="checkout_date" id="checkout_date" required>
																	<?php } ?>
																</div>
															</div>

															<div class="col-12 col-sm-3">
																<div class="form-group">
																	<label for="checkout_time">Check Out Time</label>
																	<?php if(!empty($ID)){ ?>
																		<?php if(!empty($rsHotelList)): foreach($rsHotelList as $row): ?>
																			<input placeholder="Select time" type="text" class="form-control timepicker" name="checkout_time" id="checkout_time" value="<?php echo (!empty($ID))?$row['checkout_time']:''; ?>">
																		<?php endforeach;endif; } else{ ?>
																			<input placeholder="Select time" type="text" class="form-control timepicker" name="checkout_time" id="checkout_time" required>
																	<?php } ?>
																</div>
															</div>
														</div>

														<div class="form-row <?php echo (isset($mode) && ($mode == 'view'))?'d-none':''; ?>">
															<div class="col-12">
																<h5><input type="checkbox" id="booking_checker" style="height: 1rem; width: 1rem;" onclick="checkbox(this)"> Please tick if you are booking for someone else.</h5>
															</div>
														</div>

														<div class="form-row">
															<div class="col-12 col-sm-6 d-none" id="guest_details_form">
																<div class="form-group">
																	<label for="guest_details">Guest Name [Department]</label>
																	<select class="form-control select" name="guest_details" id="guest_details">
																		<option value="-1" selected disabled>-- Please Select --</option>
																		<?php if($listName) foreach($listName as $key => $gID){ 
																			$dept_sName =  ($gID['department_name'])?' ['.$gID['department_short_name'].'] ':' [N/A]';
																		?>
																		<?php if(($_SESSION['user']['name']) != $gID['name']){ ?>
																			<option value="<?php echo $gID['id']; ?>" data-did="$gID['department_id']"><?php echo $gID['name'].$dept_sName; ?></option>
																		<?php } ?>
																		<?php } ?>
																	</select>
																</div>
															</div>

															<?php if(!empty($rsHotelList)) foreach($rsHotelList as $row){ ?>
																<?php if($row['requestor_id'] != $row['createdBY']){ ?>
																	<div class="col-12 col-sm-6 <?php echo (empty($ID))?'d-none':''; ?>">
																		<div class="form-group">
																			<label for="guest_details_input">Guest Name [Department]</label>
																			<input type="text" class="form-control" name="guest_name_input" id="guest_name_input" value="<?php echo $row['requestor'].' ['.$row['department_short_name'].']' ?>" readonly>
																			<input type="text" class="form-control" name="guest_details_input" id="guest_details_input" value="<?php echo $row['requestor_id']; ?>" hidden>
																		</div>
																	</div>
																<?php } ?>
															<?php } ?>
														</div>

														<div class="form-row" <?php echo (isset($mode) && ($mode == 'view'))?'style="display: none;"':''; ?>>
															<div class="col-12" style="padding-top: 2rem;">
																<div class="float-left <?php echo ($ID)?'d-none':''; ?>">
																	<table>
																		<tbody>
																			<tr>
																				<td class="text-center">
																					<label class="switch" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="Send me a copy of this form">
																						<input type="checkbox" name="send_email_checkbox">
																						<span class="slider round"></span>
																					</label>
																				</td>
																				<td class="p-3 py-1"><b><h6 style="">Send me a copy of this form</h6></b></td>
																			</tr>
																		</tbody>
																	</table>
																</div> 
																<div class="float-right">
																	<a class="btn btn-light" href="<?php echo base_url('hr/serviceform/hotel_list/'); ?>">Cancel</a>
																	<button type="submit" id="submitBtn" class="btn btn-primary"><?php echo ($ID)?'Update':'Next'; ?></button>
																</div> 
															</div>
														</div>
													</div>
												</div>
											</div>
										</form>
									</form>
								</div>
							</div>
						</div>

						<div class="card-body <?php echo (empty($ID))?'d-none':'' ?>" id="room_detail">
							<div class="card no-shadow">
								<div class="card-body">
									<div class="form-row">
										<div class="col-12">
											<div class="form-group">
												<h5 class="float-left"><b>Room Details</b></h5>
												<div class="float-right btn-group" <?php echo (isset($mode) && ($mode == 'view'))?'style="display: none;"':''; ?>>
													<button type="button" class="btn btn-outline-dark btn-sm" data-toggle="modal" data-target="#newRoomDetails" data-trigger="hover" data-tooltip="tooltip" title="Add New Details"><i class="fas fa-plus"></i> Add New Details</button>
												</div>
												<br><hr>
												<table class="table table-bordered table-striped table-hover" id="table_room_type">
													<thead class="text-center">
														<th>#</th>
														<th>Type of Room</th>
														<th>Staff Name</th>
														<th <?php echo (isset($mode) && ($mode == 'view'))?'style="display: none;"':''; ?>>Action</th>
													</thead>
													<tbody>
														<?php foreach($roomDetailList as $key => $roomDetail){ ?>
															<tr>
																<td class="text-center"><?php echo $key+1; ?></td>
																<td class=text-center><?php echo $roomDetail['room_type'] ?></td>
																<td>
																	<?php
																		$staff_explode = explode(',',$roomDetail['guest_room_name']);
																		foreach ($staff_explode as $staff) 
																		{
																			echo '<li>'.$staff.'</li>';
																		}
																	?>
																</td>
																<td class="text-center" <?php echo (isset($mode) && ($mode == 'view'))?'style="display: none;"':''; ?>>
																	<div class="btn-group">
																		<button class="btn btn-warning btn-sm" data-roomid="<?php echo $roomDetail['ID']; ?>" data-details="<?php echo base64_encode(json_encode($roomDetailList));?>" onclick="editRoom(this)"><i class="fas fa-edit"></i></button>
																		<button id="deleteButtonHotelRoom" class="btn btn-danger btn-sm" data-roomid="<?php echo $roomDetail['ID']; ?>" data-hotelid="<?php echo $roomDetail['hotel_id']; ?>" onclick="deleteRoom(this)"><i class="fas fa-trash"></i></button>
																	</div>
																</td>
															</tr>
														<?php } ?>
													</tbody>
												</table>
											</div>
											
											<div class="col-12" <?php echo (isset($mode) && ($mode == 'view'))?'style="display: none;"':''; ?> style="padding-top: 2rem;">
												<div class="float-right">
													<a class="btn btn-primary" href="<?php echo base_url('hr/serviceform/hotel_list/submit'); ?>">Submit</a>
												</div> 
											</div>

										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<!-- add new room -->
<div class="modal fade d-print-none" id="newRoomDetails" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">Room Details</h5>&emsp;
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                  </button>
            </div>
            <form class="form" id="roomDetailForm" action="<?php echo base_url('hr/Serviceform/hotel_save_room') ?>" method="POST" onsubmit="return confirm('Confirm to add new room detail?')">
	            <div class="modal-body">

	            	<input type="text" class="form-control" name="hotel_ID" id="hotel_ID" value="<?php echo $ID; ?>" hidden>

	                <div class="row">

	                	<div class="col-12">
	                		<label><b>Type of Room</b></label>
	                		<input type="text" class="form-control" name="typeroom" id="typeroom" required>
	                	</div>
	                	<div style="margin-bottom: 6rem;"></div>
	                	<div class="col-12">
	                		<label><b>Staff Name [Department] [IC No.] [Phone No.]</b></label>
	                		<select class="form-control select" multiple name="staff_id[]" id="staff_id" required placeholder="-- Please Select --">
								<option value="-1" disabled>-- Please Select --</option>
								<?php if($listName) foreach($listName as $key => $gID){ 
									$dept_sName =  ($gID['department_name'])?' ['.$gID['department_short_name'].'] ':' [N/A]';
									$ic_no =  ($gID['ic_no'])?' ['.$gID['ic_no'].'] ':' [N/A]';
									$phone =  ($gID['phone'])?' ['.$gID['phone'].'] ':' [N/A]';

									$flag = true;
									if($roomDetailList) foreach($roomDetailList as $key => $roomDetail)
									{
										$staff_explode = explode(',',$roomDetail['guest_room_id']);
										foreach ($staff_explode as $staff) 
										{
											if($staff == $gID['id']) $flag = false;
										}
									}

									if($flag){
								?>
									<option value="<?php echo $gID['id']; ?>"><?php echo $gID['name'].$dept_sName.$ic_no.$phone; ?></option>
								<?php } } ?>
							</select>
	                	</div>
	                </div>
	                <br>
	                <div class="float-right" style="padding-bottom: 1rem;">
	                	<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
						<button type="submit" class="btn btn-primary">Save</button>
	                </div>
	            </div>
            </form>
        </div>
    </div>
</div>
<!-- add new room -->

<!-- edit room -->
<div class="modal fade d-print-none" id="editRoomDetails" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="editTitle">Room Details</h5>&emsp;
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                  </button>
            </div>
            <form class="form" action="<?php echo base_url('hr/Serviceform/hotel_edit_room') ?>" method="POST" onsubmit="return confirm('Confirm to edit room detail?')">
	            <div class="modal-body">

	            	<input type="text" class="form-control" name="edit_hotel_ID" id="edit_hotel_ID" value="<?php echo $ID; ?>" hidden>
	            	<input type="text" class="form-control" name="room_ID" id="room_ID" value="" hidden>

	                <div class="row">

	                	<div class="col-12">
	                		<label><b>Type of Room</b></label>
	                		<input type="text" class="form-control" name="edit_typeroom" id="edit_typeroom" required>
	                	</div>
	                	<div style="margin-bottom: 6rem;"></div>
	                	<div class="col-12">
	                		<label><b>Staff Name [Department] [IC No.] [Phone No.]</b></label>
	                		<select class="form-control select" multiple name="edit_staff_id[]" id="edit_staff_id" placeholder="-- Please Select --">
								<option value="-1" disabled>-- Please Select --</option>
								<?php if($listName) foreach($listName as $key => $gID){ 
									$dept_sName =  ($gID['department_name'])?' ['.$gID['department_short_name'].'] ':' [N/A]';
									$ic_no =  ($gID['ic_no'])?' ['.$gID['ic_no'].'] ':' [N/A]';
									$phone =  ($gID['phone'])?' ['.$gID['phone'].'] ':' [N/A]';
								?>
									<option value="<?php echo $gID['id']; ?>"><?php echo $gID['name'].$dept_sName.$ic_no.$phone; ?></option>
								<?php } ?>
							</select>
	                	</div>
	                	<!-- <div class="col-12" style="padding-left: 2.5rem; padding-top: 1rem;"><ul id="currentStaff"></ul></div> -->
	                </div>
	                <br>
	                <div class="float-right" style="padding-bottom: 1rem;">
	                	<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
						<button type="submit" class="btn btn-primary">Update</button>
	                </div>
	            </div>
            </form>
        </div>
    </div>
</div>
<!-- edit room -->
<?php echo (!empty($approval) && $mode != "room_detail")?$approval:''; ?>

<style type="text/css">
	.tooltipevent
	{
		width:auto;
		height:auto;
		background:rgba(0,0,0,0.75);
		position:absolute;
		color: #fff;
		z-index:10001;
		padding:10px 10px 10px 10px ;  
		line-height: 200%;
	}
</style>

<script>
	$(document).ready(function()
	{
		$('#table_room_type').DataTable().destroy();
		var fc_event= '';
		var resource = <?php echo $resource;?>;

		var fullcalendar = $('#calendar').fullCalendar({ 
			themeSystem: 'bootstrap4',
			header: 
			{
				left: 'prev,next today',
				center: 'title',
				right: 'month,listMonth'
			},
			buttonText: {
				today: 'Today',
				month: 'Calendar',
				listMonth: 'List'
			},

			navLinks: true, // can click day/week names to navigate views
			editable: true,
         eventLimit: true, // allow "more" link when too many events
         events: <?php echo $fc_event; ?>,

         eventMouseover: function (data, event, param, resource = <?php echo $resource;?>) {
         	var js_res = JSON.parse(JSON.stringify(resource));
         	var hover_item = js_res[data.id];
         	var title = JSON.stringify(data.title);
         	var checkin = moment(hover_item.checkin_date).format('DD-MM-YYYY');
         	var checkout = moment(hover_item.checkout_date).format('DD-MM-YYYY');

         	tooltip = '<div class="tooltipevent"> Requester : '+hover_item.requestor+'['+hover_item.staff_id+']'+'<br/> Hotel name : '+hover_item.hotel_name+'<br/> Location : '+hover_item.location+'<br/> Check-in Date : '+checkin+'<br/> Check-out Date : '+checkout+'<br/>Department : '+hover_item.dept_name+'/'+hover_item.branchName+'</div>';

         	$("body").append(tooltip);
         	$(this).mouseover(function (e) {
         		$(this).css('z-index', 10000);
         		$('.tooltipevent').fadeIn('500');
         		$('.tooltipevent').fadeTo('10', 1.9);
         	}).mousemove(function (e) {
         		$('.tooltipevent').css('top', e.pageY + 10);
         		$('.tooltipevent').css('left', e.pageX + 20);
         	});
         },

         eventMouseout: function(data, event) {
         	$(this).css('z-index', 8);
         	$('.tooltipevent').remove();
         },
      });

		fullcalendar.fullCalendar();

		var mode = '<?php echo $mode ?>';
		if(mode != '' &&  mode == 'room_detail')
		{
			$('html, body').animate({
				scrollTop: $("#room_detail").offset().top
			}, 0);
		}
	});

	function checkbox(elem)
	{
		var booking_checker = document.getElementById("booking_checker");

		if(booking_checker.checked == true)
		{
			$('#guest_details_form').removeClass('d-none');
			$('#guest_details').attr('required','required');
		}else{
			$('#guest_details_form').addClass('d-none');
			$('#guest_details').removeAttr('required');
			// $('#guest_details').prop('selectedIndex',0);
			$("#guest_details").select2("val", "-1");
		}
	}

	function editRoom(elem)
	{
		var room_id 	= $(elem).data('roomid');
		var details 	= JSON.parse(atob($(elem).data('details')));

		if(details != '' && details != null && details != undefined)
		{
			$('#editRoomDetails').modal('show');
			$('#editTitle').text('Edit Room Details');

			$.each(details, function(index, value)
			{
				if(value.ID == room_id)
				{
					$('#edit_typeroom').val(value.room_type);
					$('#room_ID').val(value.ID);

					var guest_id 	= (value.guest_room_id).split(",");
					var guest 		= (value.guest_room_name).split(",");

					console.log(guest_id);
					console.log(guest);

					$('#edit_staff_id').select2("val",[guest_id])

					// if(guest != '')
					// {
					// 	$('#currentStaff').html('');
					// 	$.each(guest,function(key,row){
					// 		let template = `<li>${row}</li>`;
					// 		$('#currentStaff').append(template);
					// 	});
					// }else{
					// 	$('#currentStaff').html('');
					// }
				}
			});
		}else{
			alert('No Details Found!');
		}
	}

	function deleteRoom(elem)
	{
		var room_ID 	= $(elem).data('roomid');
		var hotel_ID 	= $(elem).data('hotelid');
		
		validateForm("#deleteButtonHotelRoom", "Delete this list?", function() {
			$.ajax({
				url:'<?php echo base_url('hr/serviceform/hotel_delete_room') ?>',
				data: {
					room_ID : room_ID,
					hotel_ID : hotel_ID
				},
				type: 'post',
				dataType: 'json',
				success: (data) => {
					if(data.status == "Success") {

						localStorage.setItem("status", data.status);
						localStorage.setItem("msg", data.msg);

						location.replace(data.redirect);

                    	// redirect(base_url('hr/serviceform/hotel_list'));
                 	}
              	}
           	});
		});
	}

	function calculate_request_hour()
	{
		var checkin_date = $('#checkin_date').val();
		var checkin_time = $('#checkin_time').val();
		var server_date	= '<?php echo date("Y-m-d H:i:s"); ?>';

		if(checkin_date != '' && checkin_date != null)
		{
			$.ajax({
				url:'<?php echo base_url('hr/serviceform/change_date_format') ?>',
				data: {
					checkin_date : checkin_date,
					checkin_time : checkin_time
				},
				type: 'post',
				dataType: 'json',
				success: (data) => {
					if(data.status == "success") {

						var date_request 	= moment(data.date_time); 
						var date_server 	= moment(server_date); 
						var date_diff		= Math.floor((date_request-date_server)/36e5);
						if(date_diff < 48)
						{
							iziToast.error({
								title: 'Error',
								message: "Check in time less than 48 hours. Please update to new time. Thank you.",
							});

							$('#submitBtn').attr('disabled','disabled');
							$('#submitBtn').css("cursor","not-allowed");
						}else{
							iziToast.success({
								title: 'Success',
								message: "Success",
							});

							$('#submitBtn').removeAttr('disabled');
							$('#submitBtn').css("cursor","pointer");
						}
	                }
	          	}
	       	});
		}
	}

</script>

<?php
$this->load->view('hr/policyprocedure/scripts/google_map.php');
?>