static function _hotelValidateByID($hotel_id, $check_in, $check_out, $adult_num, $child_num, $number_room) { $cant_book = array(); global $wpdb; $rooms = HotelHelper::_getAllRoomHotelID($hotel_id); if (is_array($rooms) && count($rooms)) { foreach ($rooms as $room) { $default_state = get_post_meta($room, 'default_state', true); if (!$default_state) { $default_state = 'available'; } $number_room_ori = intval(get_post_meta($room, 'number_room', true)); $room_price = STPrice::getRoomPriceOnlyCustomPrice($room, $check_in, $check_out, 1); if ($room_price <= 0) { $cant_book[] = $room; } else { $adult_number = intval(get_post_meta($room, 'adult_number', true)); $child_number = intval(get_post_meta($room, 'children_number', true)); if ($adult_number < $adult_num || $child_number < $child_num) { // overload people $cant_book[] = $room; } else { $data_room = AvailabilityHelper::_getdataHotel($room, $check_in, $check_out); if (is_array($data_room) && count($data_room)) { $start = $check_in; $end = $check_out; for ($i = $start; $i <= $end; $i = strtotime('+1 day', $i)) { $in_date = false; $status = 'available'; $num_room = 0; foreach ($data_room as $key => $val) { if ($i == $val->check_in && $i == $val->check_out) { //in date $status = $val->status; if (!$in_date) { $in_date = true; } } } if ($in_date) { if ($status != 'available') { $cant_book[] = $room; break; } } else { if ($default_state == 'available') { if ($number_room > $number_room_ori) { $cant_book[] = $room; break; } } else { $cant_book[] = $room; break; } } } } else { // dont have custom price if ($default_state == 'available') { if ($number_room > $number_room_ori) { $cant_book[] = $room; } } else { $cant_book[] = $room; } } } } } } $room_full_ordered = HotelHelper::_get_room_cant_book_by_id($hotel_id, date('Y-m-d', $check_in), date('Y-m-d', $check_out), $number_room); if (is_array($room_full_ordered) && count($room_full_ordered)) { $cant_book = array_unique(array_merge($cant_book, $room_full_ordered)); } return $cant_book; }
static function _holidayValidate($check_in) { global $wpdb; $cant_book = self::_get_holiday_cant_order($check_in); $holidays = self::_getAllHolidayID(); $results = array(); $today = date('Y-m-d'); if (is_array($holidays) && count($holidays)) { foreach ($holidays as $holiday) { $type_holiday = get_post_meta($holiday, 'type_holiday', true); $data_holiday = AvailabilityHelper::_getdataHolidayEachDate($holiday, strtotime($check_in), strtotime($check_in)); $booking_period = intval(get_post_meta($holiday, 'holidays_booking_period', true)); if (is_array($data_holiday) && count($data_holiday)) { $full = 0; foreach ($data_holiday as $key => $val) { $period = TravelHelper::dateDiff($today, date('Y-m-d', $val->check_in)); if ($val->status != 'available' || $period < $booking_period) { $full += 1; } } if ($full == count($data_holiday)) { $results[] = $holiday; } } else { if ($type_holiday != 'daily_holiday') { $results[] = $holiday; } } } } if (count($results)) { $cant_book = array_unique(array_merge($cant_book, $results)); } return $cant_book; }
echo $check_out; ?> " readonly="readonly" class="form-control"> </div> </div> <div id="list_tour_item" data-type-tour="<?php echo $type_tour; ?> " style="display: none; width: 500px; height: auto;"> <?php $start = date('Y-m-01', strtotime(date('Y-m-d'))); $start = strtotime($start); $end = date('Y-m-t', $start); $end = strtotime($end); $lists = AvailabilityHelper::_get_list_availability_tour_frontend(get_the_ID(), $start, $end); if (is_array($lists) && count($lists)) { foreach ($lists as $list) { ?> <div class="item_tour" style="padding-left: 20px"> <?php if ($type_tour == 'daily_tour') { ?> <div class="mb10"><input type="radio" class="i-radio" name="select_tour" data-start="<?php echo $list['start']; ?> " data-end="<?php echo $list['end']; ?> "><strong><?php echo __('Departure date', ST_TEXTDOMAIN);
static function _tourValidate($check_in) { global $wpdb; $cant_book = self::_get_tour_cant_order($check_in); $tours = self::_getAllTourID(); $results = array(); $today = date('Y-m-d'); if (is_array($tours) && count($tours)) { foreach ($tours as $tour) { $type_tour = get_post_meta($tour, 'type_tour', true); $data_tour = AvailabilityHelper::_getdataTourEachDate($tour, strtotime($check_in), strtotime($check_in)); $booking_period = intval(get_post_meta($tour, 'tours_booking_period', true)); if (is_array($data_tour) && count($data_tour)) { $full = 0; foreach ($data_tour as $key => $val) { $period = TravelHelper::dateDiff($today, date('Y-m-d', $val->check_in)); if ($val->status != 'available' || $period < $booking_period) { $full += 1; } } if ($full == count($data_tour)) { $results[] = $tour; } } else { if ($type_tour != 'daily_tour') { $results[] = $tour; } } } } if (count($results)) { $cant_book = array_unique(array_merge($cant_book, $results)); } return $cant_book; }
static function _get_disable_date() { $list_date = array(); if (!TravelHelper::checkTableDuplicate('st_rental')) { echo json_encode($list_date); die; } $rental_id = STInput::request('rental_id'); $year = STInput::request('year'); if (empty($year)) { $year = date('Y'); } $month = STInput::request('month'); if (empty($month)) { $month = date('m'); } $result = RentalHelper::_get_full_ordered($rental_id, $month, $month, $year, $year); $number_rental = intval(get_post_meta($rental_id, 'rental_number', true)); $min_max = RentalHelper::_get_min_max_date_ordered($rental_id, $year, $year); if (is_array($min_max) && count($min_max) && is_array($result) && count($result)) { $disable = array(); for ($i = intval($min_max['min_date']); $i <= intval($min_max['max_date']); $i = strtotime('+1 day', $i)) { $num_rental = 0; foreach ($result as $key => $date) { if ($i >= intval($date['check_in_timestamp']) && $i <= intval($date['check_out_timestamp'])) { $num_rental += 1; } } $disable[$i] = $num_rental; } if (count($disable)) { foreach ($disable as $key => $num_rental) { if (intval($num_rental) >= $number_rental) { $list_date[] = date(TravelHelper::getDateFormat(), $key); } } } } $list_date_2 = AvailabilityHelper::_getDisableCustomDateRental($rental_id, $month, $month, $year, $year); if (is_array($list_date_2) && count($list_date_2)) { $list_date = array_merge($list_date, $list_date_2); } echo json_encode($list_date); die; }