<?php

global $post, $errors_config_hotel;
session_start();
if( ! defined( 'ABSPATH' ) ) exit;
	
if(!is_admin()) {
	if(!empty($errors_config_hotel) && is_user_logged_in()==true) {
		?><h3>Please configure the following on eaSYNC Booking settings:</h3><span>Go to your backend and find "eaSYNC Booking" on the sidebar and click "Settings" then click the "General" and click "Hotel Booking"</span><ul><?php
		foreach ($errors_config_hotel as $error) {
			?>
			<li><?php echo $error; ?></li>
			<?php
		}
		exit;
		?></ul><?php
	}elseif(!empty($errors_config_hotel) && is_user_logged_in()==false){
		?><h3>This module is currently under maintenance, check back soon!</h3><?php
		exit;
	}
}

$_SESSION['sync_form'] = 'hotel';
$_SESSION['sync_page_redirect'] = $post->post_name;

?>
<div class="sync_form_wrapper_set sync_check_booking" style="display:none;">
	<div class="go_back">
		<span class="back_text"><i class="fa fa-arrow-left"></i>  Back</span>
	</div>
	<div class="ref_head">
		<h2>Search Bookings</h2>
	</div>
	<div class="get_reference">
		<input type="text" class="ref_number" name="ref_number" placeholder="Enter Reference Number" >
		<span class="search_ref"> Search </span>
	</div>
</div>

<div class="booking_form_wrapper">
    <?php
        include('search-room.php');
        include('search-list.php');
    ?>
</div>

<div class="modall sync-transform fade sync-modal-booking-info" id="booking_info" tabindex="-1" role="dialog" aria-labelledby="customer-infoLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
	<div class="modal-dialog modal-md" role="document" data-keyboard="false">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" >
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-bodyy">
				<div class="booking-details">
					<div class="cust_name"></div>
					<div class="person_info">
						<div class="person_labels"></div>
						<div class="space"></div>
						<div class="person_data"></div>
					</div>
					<div class="book_head"></div>
					<div class="booking_details">
						<div class="booking_labels"></div>
						<div class="space"></div>
						<div class="booking_data"></div>
					</div>
					<br>
					<div class="cancel_section">
						<?php $get_val = $wpdb->get_results($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s", 'sync_car_grace_period')); ?>
						<span class="note" style="text-align: left;"><strong>Note:</strong> Cancellations are only allowed <?php echo $get_val[0]->option_value; ?> days prior to booked date.</span>
						
						<?php 
							$table_name = $wpdb->prefix . 'sync_options';
							$tmp_array1 = array('sync_hotel_grace_period', 'sync_hotel_refund_rate');
							$placeholders1 = implode(',', array_fill(0, count($tmp_array1), '%s'));
							$check = $wpdb->get_results($wpdb->prepare("SELECT * from $table_name  where option_name IN ($placeholders1)", $tmp_array1));

							if( (!empty($check[0]->option_value)) && (!empty($check[1]->option_value))) { ?>
								<input class="cancel_booking" type="button" value="Cancel Booking" id="">
							<?php } 
						?>

					</div>
					<br>
				</div>
			</div>
		</div>
	</div>
</div>

<div class="modall sync-transform fade sync-modal-booking-notFound" id="booking_notFound" tabindex="-1" role="dialog" aria-labelledby="customer-infoLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
	<div class="modal-dialog modal-md" role="document" data-keyboard="false">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" >
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-bodyy">
				<div class="rental-details">
					<h3>No Record Found.</h3>
				</div>
				<br>
				<div class="button_close">
					<input class="close_modal" type="button" value="Close" data-dismiss="modal">
				</div>
			</div>
		</div>
	</div>
</div>

<div class="modall sync-transform fade sync-modal-booking-info" id="show_cancel" tabindex="-1" role="dialog" aria-labelledby="customer-infoLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
	<div class="modal-dialog" role="document" data-keyboard="false">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" >
				<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-bodyy">
				<div class="cancel_content">
					<div class="cancel_body">
						<div class="cancel_details">
							<div class="breakdown_label">
								<h2>Cancellation Cost Breakdown</h2>
							</div>
							<br>
							<div class="breakdown_details">
								<div class="breakdown_labels"></div>
								<div class="space"></div>
								<div class="breakdown_calculation"></div>
							</div>
							<hr style="border: 1px solid;">
							<div class="return_details">
								<div class="return_label"></div>
								<div class="space"></div>
								<div class="return_amount"></div>
							</div>
							<br>
						</div>
						<div class="cancel_action">
							<input class="confirm_cancel" type="button" value="Confirm" id="">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<div class="modall sync-transform fade sync-modal-booking-info" id="cancel_success" tabindex="-1" role="dialog" aria-labelledby="customer-infoLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
	<div class="modal-dialog" role="document" data-keyboard="false">
		<div class="modal-content">
			<div class="modal-bodyy">
				<div class="cancel_content">
					<div class="cancel_body">
						<h2>Cancellation Request Sent.</h2>
						<div class="sub_content">
							<span class="content">Please allow 1-2 business days to review and assist you with your request.</span>
						</div>
						<br>
						<div class="button_close" style="text-align:center;">
							<input class="close_modal" type="button" value="Close">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>