function gdlr_print_hotel_availability_item($settings = array()) { $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" '; global $gdlr_spaces, $hotel_option; $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : ''; $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : ''; $current_date = current_time('Y-m-d'); $next_date = date('Y-m-d', strtotime($current_date . "+1 days")); $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => 1, 'gdlr-children-number' => 0); $ret = gdlr_get_item_title($settings); $ret .= '<div class="gdlr-hotel-availability-wrapper'; if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') { $ret .= ' gdlr-hotel-branches-enable'; } $ret .= '" ' . $margin_style . $item_id . ' >'; $ret .= '<form class="gdlr-hotel-availability gdlr-item" id="gdlr-hotel-availability" method="post" action="' . esc_url(add_query_arg(array($hotel_option['booking-slug'] => ''), home_url('/'))) . '" >'; if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') { $ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => '')); } $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in'])); $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night'])); $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out'])); $ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'], 'multiple' => true)); $ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'], 'multiple' => true)); $ret .= '<div class="gdlr-hotel-availability-submit" >'; $ret .= '<input type="hidden" name="hotel_data" value="1" >'; $ret .= '<input type="hidden" name="gdlr-room-number" value="1" />'; $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >'; $ret .= '</div>'; $ret .= '<div class="clear"></div>'; $ret .= '</form>'; $ret .= '</div>'; return $ret; }
function gdlrs_get_reservation_date_form($single_form = false, $data = array()) { $ret = ''; if (!empty($_POST['hotel_data'])) { $value = $_POST; } else { $current_date = current_time('Y-m-d'); $next_date = date('Y-m-d', strtotime($current_date . "+1 days")); $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1); } // branch (if enable) global $hostel_option; if (!empty($hostel_option['enable-hotel-branch']) && $hostel_option['enable-hotel-branch'] == 'enable') { if (is_single()) { $term = get_the_terms(get_the_ID(), 'hostel_room_category'); if (!empty($term)) { $term = reset($term); $value['gdlr-hotel-branches'] = $term->term_id; } else { $value['gdlr-hotel-branches'] = ''; } } else { if (empty($value['gdlr-hotel-branches'])) { $value['gdlr-hotel-branches'] = ''; } } $ret .= gdlrs_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => $value['gdlr-hotel-branches'])); $ret .= '<div class="clear"></div>'; } // date $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in'])); $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']), 1); $ret .= '<div class="clear"></div>'; $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out'])); $ret .= '<div class="clear"></div>'; // room $ret .= gdlr_get_reservation_combobox(array('title' => __('Guests', 'gdlr-hotel'), 'slug' => 'gdlr-room-number', 'id' => 'gdlr-room-number', 'value' => $value['gdlr-room-number']), 1); $ret .= '<div class="clear"></div>'; if ($single_form) { $ret .= '<input type="hidden" name="hotel_data" value="1" >'; $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >'; } else { if (empty($_POST['hotel_data'])) { $ret .= '<a id="gdlr-reservation-bar-button" class="gdlr-reservation-bar-button gdlr-button with-border" href="#" >' . __('Check Availability', 'gdlr-hotel') . '</a>'; } } $ret .= '<div class="clear"></div>'; return $ret; }
function gdlr_get_reservation_date_form($single_form = false, $data = array()) { $ret = ''; if (!empty($_POST['hotel_data'])) { $value = $_POST; } else { $current_date = current_time('Y-m-d'); $next_date = date('Y-m-d', strtotime($current_date . "+1 days")); $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => array(2), 'gdlr-children-number' => array(0)); // for single room page global $gdlr_post_option; if (!empty($gdlr_post_option['max-people']) && intval($gdlr_post_option['max-people']) < 2) { $value['gdlr-adult-number'] = 1; } } // branch (if enable) global $hotel_option; if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') { if (is_single()) { $term = get_the_terms(get_the_ID(), 'room_category'); if (!empty($term)) { $term = reset($term); $value['gdlr-hotel-branches'] = $term->term_id; } else { $value['gdlr-hotel-branches'] = ''; } } else { if (empty($value['gdlr-hotel-branches'])) { $value['gdlr-hotel-branches'] = ''; } } $ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => $value['gdlr-hotel-branches'])); $ret .= '<div class="clear"></div>'; } // date $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in'])); $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']), 1); $ret .= '<div class="clear"></div>'; $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out'])); $ret .= '<div class="clear"></div>'; // room $ret .= gdlr_get_reservation_combobox(array('title' => __('Rooms', 'gdlr-hotel'), 'slug' => 'gdlr-room-number', 'id' => 'gdlr-room-number', 'value' => $value['gdlr-room-number']), 1); $ret .= '<div class="clear"></div>'; $ret .= '<div class="gdlr-reservation-people-amount-wrapper" id="gdlr-reservation-people-amount-wrapper" >'; for ($i = 0; $i < $value['gdlr-room-number']; $i++) { $ret .= '<div class="gdlr-reservation-people-amount">'; $ret .= '<div class="gdlr-reservation-people-title" >' . __('Room', 'gdlr-hotel') . ' <span>' . ($i + 1) . '</span></div>'; $ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'][$i], 'multiple' => true), 1); $ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'][$i], 'multiple' => true)); $ret .= '<div class="clear"></div>'; $ret .= '</div>'; } $ret .= '</div>'; // gdlr-reservation-people-amount-wrapper $ret .= '<div class="clear"></div>'; if ($single_form) { $ret .= '<input type="hidden" name="hotel_data" value="1" >'; $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >'; } else { if (empty($_POST['hotel_data'])) { $ret .= '<a id="gdlr-reservation-bar-button" class="gdlr-reservation-bar-button gdlr-button with-border" href="#" >' . __('Check Availability', 'gdlr-hotel') . '</a>'; } } $ret .= '<div class="clear"></div>'; return $ret; }