static function _hotelValidate($check_in, $check_out, $adult_num, $child_num, $number_room) { $cant_book = array(); $hotels = HotelHelper::_getAllHotelID(); if (is_array($hotels) && count($hotels)) { foreach ($hotels as $hotel) { $total_room = HotelHelper::_getTotalRoom($hotel); $room_cant_book = HotelHelper::_hotelValidateByID($hotel, strtotime($check_in), strtotime($check_out), $adult_num, $child_num, $number_room); $total_room_cant_book = count($room_cant_book); if ($total_room <= $total_room_cant_book) { $cant_book[] = $hotel; } } } return $cant_book; }
public function _alter_search_query_ajax($where) { global $wpdb; $hotel_id = get_the_ID(); $check_in = date('Y-m-d', strtotime(TravelHelper::convertDateFormat(STInput::request('start')))); $check_out = date('Y-m-d', strtotime(TravelHelper::convertDateFormat(STInput::request('end')))); $adult_num = STInput::request('adult_number', 0); $child_num = STInput::request('child_number', 0); $number_room = STInput::request('room_num_search', 0); $list = HotelHelper::_hotelValidateByID($hotel_id, strtotime($check_in), strtotime($check_out), $adult_num, $child_num, $number_room); if (!is_array($list) || count($list) <= 0) { $list = "''"; } else { $list = implode(',', $list); } $where .= " AND {$wpdb->prefix}posts.ID NOT IN ({$list})"; return $where; }