Esempio n. 1
0
function success_booking_details()
{
    if (is_empty_booking()) {
        empty_booking();
        redirect_js_script(get_bloginfo('url'));
    }
    $d = get_booking_by_id(booking_data('booking_ID'));
    $room_price = $d['room_price'];
    $nights = $d['no_of_night'];
    $output = '';
    $output .= '<div id="successBookingDetails">';
    $output .= '<a href="#" class="pull-right print-booking"><i class="fa fa-print"></i></a>';
    $output .= '<div  id="bookingDetailContent">';
    $output .= '<div class="success-booking-details">';
    $output .= '<div class="row">';
    $output .= '<div class="col-md-4 col-lg-3">';
    $output .= '<div class="reservation-sidebar">';
    $output .= '<div class="reservation-date">';
    $output .= '<h2 class="reservation-heading">Dates</h2>';
    $output .= '<ul>';
    $output .= '<li>';
    $output .= '<span>Check-In</span>';
    $output .= '<span>' . format_date($d['date_in']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Check-Out</span>';
    $output .= '<span>' . format_date($d['date_out']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Total Nights</span>';
    $output .= '<span>' . count_nights($d['date_in'], $d['date_out']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Total Guests</span>';
    $output .= '<span>' . $d['no_of_adult'] . ' Adults ' . $d['no_of_child'] . ' Children</span>';
    $output .= '</li>';
    $output .= '</ul>';
    $output .= '</div>';
    $output .= '<div class="reservation-room-selected">';
    $output .= '<h2 class="reservation-heading">Selected Room</h2>';
    $output .= '<div class="reservation-room-seleted_item">';
    $output .= '<div class="reservation-room-seleted_name has-package">';
    $output .= '<h2><a>' . get_the_title($d['room_type_ID']) . '</a></h2>';
    $output .= '</div>';
    $output .= '<ul>';
    $output .= '<li>';
    $output .= '<span>Max</span>';
    $output .= '<span>' . get_field('max_person', $d['room_type_ID']) . ' Person(s)</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Size</span>';
    $output .= '<span>' . get_field('room_size', $d['room_type_ID']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Bed</span>';
    $output .= '<span>' . get_field('bed', $d['room_type_ID']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Occupancy</span>';
    $output .= '<span>' . get_field('occupancy', $d['room_type_ID']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Room Price</span>';
    $output .= '<span>' . nf($room_price) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Total Nights</span>';
    $output .= '<span>x ' . count_nights($d['date_in'], $d['date_out']) . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Total Room</span>';
    $output .= '<span>x ' . booking_data('no_of_room') . '</span>';
    $output .= '</li>';
    $output .= '</ul>';
    $output .= '</div>';
    $output .= '<div class="reservation-room-seleted_total">';
    $output .= '<label>TOTAL</label>';
    $output .= '<span class="reservation-total">' . format_price($d['amount'], false) . '</span>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '<div class="col-md-8 col-lg-9">';
    $output .= '<div class="reservation_content">';
    $output .= '<div class="reservation-billing-detail success-details">';
    $output .= '<h4>BILLING DETAILS</h4>';
    $output .= '<ul>';
    $output .= '<li>';
    $output .= '<span>Booking #</span>';
    $output .= '<span>' . $d['booking_no'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Country</span>';
    $output .= '<span>' . $d['country'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Full Name</span>';
    $output .= '<span>' . $d['salutation'] . ' ' . $d['first_name'] . ' ' . $d['middle_name'] . ' ' . $d['last_name'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Date of Birth</span>';
    $output .= '<span>' . $d['birth_date'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Nationality</span>';
    $output .= '<span>' . $d['nationality'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Email Address</span>';
    $output .= '<span>' . $d['email_address'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Phone</span>';
    $output .= '<span>' . $d['primary_phone'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Address</span>';
    $output .= '<span>' . $d['address_1'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Apartment, suite, unit etc.</span>';
    $output .= '<span>' . $d['address_2'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Town / City</span>';
    $output .= '<span>' . $d['city'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Province</span>';
    $output .= '<span>' . $d['province'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Zip Code</span>';
    $output .= '<span>' . $d['zipcode'] . '</span>';
    $output .= '</li>';
    $output .= '<li>';
    $output .= '<span>Notes</span><br />';
    $output .= '<span>' . $d['notes'] . '</span>';
    $output .= '</li>';
    $output .= '</ul>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</form>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    empty_booking();
    return $output;
}
Esempio n. 2
0
 /**
  * custom_init()
  * 
  * Process booking post data
  * 
  * @param none
  * @return none
  */
 public function custom_init()
 {
     $action = browser_request('action');
     if ($action != '') {
         switch ($action) {
             case 'check_availability':
                 $data = $_POST;
                 push_to_booking_session(array('date_in' => array_data($data, 'date_in', date('Y-m-d')), 'date_out' => array_data($data, 'date_out', add_days_to_date(date('Y-m-d'), 1)), 'no_of_adult' => array_data($data, 'no_of_adult', 1), 'no_of_room' => array_data($data, 'no_of_room', 0), 'type' => 'BOOKING', 'no_of_child' => array_data($data, 'no_of_child', 0)));
                 redirect_by_page_path('rooms');
                 break;
             case 'book_room':
                 $data = $_POST;
                 if (array_data($data, 'room_type_ID', '') == '' || !is_bookable($data['room_type_ID'])) {
                     add_this_notices('error', 'Selected room is Out of Order.');
                     return;
                 }
                 if (is_date_and_room_not_available($data['room_type_ID'], format_db_date($data['date_in']), format_db_date($data['date_out']))) {
                     return;
                 }
                 if (!has_sufficient_room($data)) {
                     return;
                 }
                 $nights = count_nights($data['date_in'], $data['date_out']);
                 $room_price = get_room_price_with_nights($data['room_type_ID'], $data['date_in'], $data['date_out']);
                 $total_amount = calculate_total_amount($data['room_type_ID'], $data['date_in'], $data['date_out'], $data['no_of_room']);
                 push_to_booking_session(array('date_in' => $data['date_in'], 'date_out' => $data['date_out'], 'no_of_adult' => $data['no_of_adult'], 'no_of_child' => array_data($data, 'no_of_child', 0), 'room_type_ID' => $data['room_type_ID'], 'no_of_night' => $nights, 'no_of_room' => $data['no_of_room'], 'room_price' => $room_price, 'amount' => $total_amount, 'booking_ID' => 0, 'amount_paid' => 0, 'payment_status' => PAYMENT_DEFAULT_STATUS, 'booking_status' => BOOKING_DEFAULT_STATUS));
                 redirect_by_page_path('review');
                 break;
             case 'make_reservation':
                 if (is_empty_booking()) {
                     add_this_notices('error', 'Please select date.');
                     redirect_by_page_path('/');
                     return;
                 }
                 $data = get_booking_session();
                 if (!is_bookable($data['room_type_ID'])) {
                     add_this_notices('error', 'Selected room is Out of Order.');
                     return;
                 }
                 $data = push_to_booking_session(array_merge($data, $_POST, array('date_booked' => date('Y-m-d H:i:s'))));
                 if ($this->process($data)) {
                     redirect_by_page_path('success');
                 }
                 break;
             case 'save_booking':
                 if (isset($_POST['save_booking_field']) && wp_verify_nonce($_POST['save_booking_field'], 'save_booking_action')) {
                     $info = get_booking_by_id(browser_request('bid', 0));
                     $post = array_merge((array) $info, $_POST);
                     $post['no_of_night'] = count_nights($post['date_in'], $post['date_out']);
                     $post['room_price'] = get_room_price_with_nights($post['room_type_ID'], $post['date_in'], $post['date_out']);
                     $post['amount'] = calculate_total_amount($post['room_type_ID'], $post['date_in'], $post['date_out'], $post['no_of_room']);
                     $post['date_booked'] = array_data($info, 'date_booked', date('Y-m-d H:i:s'));
                     $post['type'] = 'RESERVATION';
                     $post['room_code'] = room_code($post['room_type_ID']);
                     if (($bid = $this->process($post)) != false) {
                         exit(wp_redirect('admin.php?page=edit-booking&bid=' . $bid));
                     }
                 }
                 break;
             case 'export-bookings':
                 $results = get_bookings_for_export();
                 // When executed in a browser, this script will prompt for download
                 // of 'test.xls' which can then be opened by Excel or OpenOffice.
                 require_class('php-export-data.class.php');
                 // 'browser' tells the library to stream the data directly to the browser.
                 // other options are 'file' or 'string'
                 // 'test.xls' is the filename that the browser will use when attempting to
                 // save the download
                 $exporter = new ExportDataExcel('browser', 'reports.xls');
                 $exporter->initialize();
                 // starts streaming data to web browser
                 $exporter->addRow(array('BOOKING NO', 'ROOM TYPE', 'ROOM PRICE', 'CHECK IN', 'CHECK OUT', 'NO OF NIGHTS', 'NO OF ROOMS', 'TOTAL AMOUNT', 'AMOUNT PAID', 'NO OF ADULT', 'NO OF CHILD', 'BOOKED BY', 'BIRTHDATE', 'EMAIL ADDRESS', 'PHONE', 'COUNTRY', 'ADDRESS 1', 'ADDRESS 2', 'PROVINCE', 'CITY', 'ZIPCODE', 'NATIONALITY', 'BOOKING STATUS', 'PAYMENT STATUS', 'DATE BOOKED'));
                 foreach ($results as $i => $r) {
                     // pass addRow() an array and it converts it to Excel XML format and sends
                     // it to the browser
                     $exporter->addRow($r);
                 }
                 $exporter->finalize();
                 // writes the footer, flushes remaining data to browser.
                 exit;
                 // all done
                 break;
         }
     }
 }