function gdlr_ajax_hotel_booking() { if (!empty($_POST['data'])) { parse_str($_POST['data'], $data); } if (!empty($_POST['contact'])) { parse_str($_POST['contact'], $contact); } if (!empty($_POST['service'])) { parse_str($_POST['service'], $service); $data['service'] = empty($service['service-select']) ? array() : $service['service-select']; $data['service-amount'] = empty($service['service-amount']) ? array() : $service['service-amount']; } else { if (empty($data['service'])) { $data['service'] = array(); $data['service-amount'] = array(); } } $ret = array(); // query section if ($_POST['state'] == 2) { $data['gdlr-room-id'] = empty($data['gdlr-room-id']) ? array() : $data['gdlr-room-id']; $room_number = gdlr_get_edited_room($data['gdlr-room-number'], $data['gdlr-room-id']); // room form $ret['room_form'] = gdlr_get_reservation_room_form($data, $room_number); // content area if (empty($data['gdlr-check-in']) || empty($data['gdlr-check-out']) || $data['gdlr-check-out'] < $data['gdlr-check-in']) { $ret['content'] = '<div class="gdlr-room-selection-complete">'; $ret['content'] .= '<div class="gdlr-room-selection-title" >' . __('Date field invalid', 'gdlr-hotel') . '</div>'; $ret['content'] .= '<div class="gdlr-room-selection-content" >' . __('Please select \'check in\' and \'check out\' date from reservation bar again.', 'gdlr-hotel') . '</div>'; $ret['content'] .= '</div>'; } else { if ($data['gdlr-room-number'] > $room_number) { $ret['content'] = gdlr_get_booking_room_query($data, $room_number); } else { $data['gdlr-hotel-branches'] = empty($data['gdlr-hotel-branches']) ? '' : $data['gdlr-hotel-branches']; $ret['content'] = '<div class="gdlr-room-selection-complete">'; $ret['content'] .= '<div class="gdlr-room-selection-title" >' . __('Room Selection is Complete', 'gdlr-hotel') . '</div>'; $ret['content'] .= '<div class="gdlr-room-selection-caption" >' . __('You can edit your booking by using the panel on the left', 'gdlr-hotel') . '</div>'; $ret['content'] .= gdlr_get_booking_services($data['gdlr-hotel-branches'], $data['service']); $ret['content'] .= '<div class="gdlr-room-selection-divider" ></div>'; $ret['content'] .= '<a class="gdlr-button with-border gdlr-room-selection-next">' . __('Go to next step', 'gdlr-hotel') . '</a>'; $ret['content'] .= '</div>'; } } $ret['state'] = 2; } else { if ($_POST['state'] == 3) { if (!empty($data['service'])) { $ret['service'] = ''; foreach ($data['service'] as $key => $service_id) { $ret['service'] .= '<input type="hidden" name="service[]" value="' . $service_id . '" />'; $ret['service'] .= '<input type="hidden" name="service-amount[]" value="' . $data['service-amount'][$key] . '" />'; } } if (empty($_POST['contact'])) { $ret['summary_form'] = gdlr_get_summary_form($data); $ret['content'] = gdlr_get_booking_contact_form(); $ret['state'] = 3; } else { $validate = gdlr_validate_contact_form($contact); if (!empty($validate)) { $ret['state'] = 3; $ret['error_message'] = $validate; } else { $ret['summary_form'] = gdlr_get_summary_form($data, false); if ($_POST['contact_type'] == 'contact') { $booking = gdlr_insert_booking_db(array('data' => $data, 'contact' => $contact, 'payment_status' => 'booking')); global $hotel_option; $mail_content = gdlr_hotel_mail_content($contact, $data, array(), array('total_price' => $booking['total-price'], 'pay_amount' => 0, 'booking_code' => $booking['code'])); gdlr_hotel_mail($contact['email'], __('Thank you for booking the room with us.', 'gdlr-hotel'), $mail_content); gdlr_hotel_mail($hotel_option['recipient-mail'], __('New room booking received', 'gdlr-hotel'), $mail_content); $ret['content'] = gdlr_booking_complete_message(); $ret['state'] = 4; } else { global $hotel_option; $booking = gdlr_insert_booking_db(array('data' => $data, 'contact' => $contact, 'payment_status' => 'pending')); if ($contact['payment-method'] == 'paypal') { $ret['payment'] = 'paypal'; $ret['payment_url'] = $hotel_option['paypal-action-url']; $ret['addition_part'] = gdlr_additional_paypal_part(array('title' => __('Room Booking', 'gdlr-hotel'), 'invoice' => $booking['invoice'], 'price' => $booking['pay-amount'])); } else { if ($contact['payment-method'] == 'stripe') { $ret['content'] = gdlr_get_stripe_form(array('invoice' => $booking['invoice'])); } else { if ($contact['payment-method'] == 'paymill') { $ret['content'] = gdlr_get_paymill_form(array('invoice' => $booking['invoice'])); } else { if ($contact['payment-method'] == 'authorize') { $ret['content'] = gdlr_get_authorize_form(array('invoice' => $booking['invoice'], 'price' => $booking['pay-amount'])); } } } } // made payment $ret['state'] = 3; } } } } } if (!empty($data)) { $ret['data'] = $data; } die(json_encode($ret)); }
if (!empty($_POST['hotel_data'])) { echo gdlr_booking_process_bar(2); } else { echo gdlr_booking_process_bar(1); } } ?> <div class="gdlr-booking-content-wrapper" > <div class="gdlr-booking-content-inner" id="gdlr-booking-content-inner" > <?php if (!empty($_GET['state']) && $_GET['state'] == 4 && !empty($_GET['invoice'])) { echo gdlr_booking_complete_message(); } else { if (!empty($_POST['hotel_data'])) { echo gdlr_get_booking_room_query($_POST, 0); } else { echo gdlr_booking_date_range(); } } ?> </div> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <?php get_sidebar('left'); ?>