public function hookDisplayLeftColumn() { if ($this->context->controller->php_self == 'category') { if (Tools::isSubmit('filter_search_btn')) { $hotel_cat_id = Tools::getValue('hotel_cat_id'); $check_in = Tools::getValue('check_in_time'); $check_out = Tools::getValue('check_out_time'); $error = false; if ($hotel_cat_id == '') { $error = 1; } elseif ($check_in == '' || !Validate::isDate($check_in)) { $error = 1; } elseif ($check_out == '' || !Validate::isDate($check_out)) { $error = 1; } elseif ($check_out <= $check_in) { $error = 1; } if (!$error) { if (Configuration::get('PS_REWRITING_SETTINGS')) { $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '?date_from=' . $check_in . '&date_to=' . $check_out; } else { $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '&date_from=' . $check_in . '&date_to=' . $check_out; } } else { if (Configuration::get('PS_REWRITING_SETTINGS')) { $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '?error=' . $error; } else { $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '&error=' . $error; } } Tools::redirect($redirect_link); } if (Tools::getValue('error')) { $this->context->smarty->assign('error', Tools::getValue('error')); } $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE'); $hotel_branch_obj = new HotelBranchInformation(); $htl_id_category = Tools::getValue('id_category'); $category = new Category((int) $htl_id_category); $parent_dtl = $hotel_branch_obj->getCategoryDataByIdCategory((int) $category->id_parent); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime($date_from) + 86400); } if (!($date_to = Tools::getValue('date_to'))) { $date_to = date('Y-m-d', strtotime($date_from) + 86400); } $search_data['parent_data'] = $parent_dtl; $search_data['date_from'] = $date_from; $search_data['date_to'] = $date_to; $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById(HotelBranchInformation::getHotelIdByIdCategory($htl_id_category)); $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo(); $this->context->smarty->assign(array('search_data' => $search_data, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable)); $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfiltersearchblock.css'); return $this->display(__FILE__, 'htlfiltersearchblock.tpl'); } }
public function hookDisplayLeftColumn() { if ($this->context->controller->php_self == 'category') { $this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/wkhotelfilterblock.js'); $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfilterblock.css'); $all_feat = FeatureCore::getFeatures($this->context->language->id); $htl_id_category = Tools::getValue('id_category'); $id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category); $max_adult = HotelRoomType::getMaxAdults($id_hotel); $max_child = HotelRoomType::getMaxChild($id_hotel); $category = new Category($htl_id_category); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime($date_from) + 86400); } if (!($date_to = Tools::getValue('date_to'))) { $date_to = date('Y-m-d', strtotime($date_from) + 86400); } $obj_rm_type = new HotelRoomType(); $room_types = $obj_rm_type->getIdProductByHotelId($id_hotel); $prod_price = array(); if ($room_types) { foreach ($room_types as $key => $value) { $prod_price[] = Product::getPriceStatic($value['id_product']); } } if (Configuration::get('PS_REWRITING_SETTINGS')) { $cat_link = $this->context->link->getCategoryLink($category) . '?date_from=' . $date_from . '&date_to=' . $date_to; } else { $cat_link = $this->context->link->getCategoryLink($category) . '&date_from=' . $date_from . '&date_to=' . $date_to; } $currency = $this->context->currency; $config = $this->getConfigFieldsValues(); $obj_booking_detail = new HotelBookingDetail(); $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to); $ratting_img = _MODULE_DIR_ . $this->name . '/views/img/stars-sprite-image.png'; $this->context->smarty->assign(array('all_feat' => $all_feat, 'max_adult' => $max_adult, 'max_child' => $max_child, 'cat_link' => $cat_link, 'ratting_img' => $ratting_img, 'currency' => $currency, 'date_from' => $date_from, 'date_to' => $date_to, 'num_days' => $num_days, 'config' => $config, 'min_price' => $prod_price ? min($prod_price) : 0, 'max_price' => $prod_price ? max($prod_price) : 0)); return $this->display(__FILE__, 'htlfilterblock.tpl'); } }
public function filterResults() { $this->display_header = false; $this->display_footer = false; $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); $htl_id_category = Tools::getValue('id_category'); $sort_by = Tools::getValue('sort_by'); $sort_value = Tools::getValue('sort_value'); $filter_data = Tools::getValue('filter_data'); // echo "<pre>"; // print_r($filter_data); // die; $adult = 0; $child = 0; $ratting = 0; $amenities = 0; $price = 0; if (!empty($filter_data)) { foreach ($filter_data as $key => $value) { if ($key == 'adult') { $adult = min($value); } elseif ($key == 'children') { $child = min($value); } elseif ($key == 'ratting') { $ratting = min($value); } elseif ($key == 'amenities') { $amenities = array(); foreach ($value as $a_k => $a_v) { $amenities[] = $a_v; } } elseif ($key == 'price') { $price = array(); $price['from'] = $value[0]; $price['to'] = $value[1]; } } } if (Module::isInstalled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php'; $id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category); $id_cart = $this->context->cart->id; $id_guest = $this->context->cookie->id_guest; $obj_booking_dtl = new HotelBookingDetail(); $booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, $ratting, $amenities, $price, $id_cart, $id_guest); if ($sort_by && $sort_value) { $indi_arr = array(); if ($sort_value == 1) { $direction = SORT_ASC; } elseif ($sort_value == 2) { $direction = SORT_DESC; } foreach ($booking_data['rm_data'] as $s_k => $s_v) { if ($sort_by == 1) { $indi_arr[$s_k] = $s_v['ratting']; } elseif ($sort_by == 2) { $indi_arr[$s_k] = $s_v['price']; } } array_multisort($indi_arr, $direction, $booking_data['rm_data']); } die(Tools::jsonEncode($booking_data)); } }