Use hotelBranchesInfo() to get active hotels

This commit is contained in:
Abhishek Kumar
2024-01-23 16:41:54 +05:30
parent b7fcf7a675
commit fbe60ad0f1
3 changed files with 21 additions and 23 deletions

View File

@@ -569,11 +569,9 @@ class HotelBranchInformation extends ObjectModel
return Db::getInstance()->executeS($sql);
}
public function getAllHotels($activeOnly = false)
public function getAllHotels()
{
return Db::getInstance()->executeS(
'SELECT * FROM `'._DB_PREFIX_.'htl_branch_info` hbi'.($activeOnly ? ' WHERE hbi.`active` = 1' : '')
);
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_branch_info`');
}
//Overrided ObjectModet::update() to update all the dependencies of the hotel

View File

@@ -29,6 +29,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
$this->context = Context::getContext();
parent::__construct();
$objHotelBranchInformation = new HotelBranchInformation();
$hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1);
// filter hotels as per accessed hotels
$hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1);
if ($hotelBranchesInfo) {
$this->initCart();
}
}
public function initCart()
@@ -82,24 +91,14 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
return $objCart;
}
public function initProcess()
{
parent::initProcess();
$objHotelBranchInformation = new HotelBranchInformation();
$activeHotels = $objHotelBranchInformation->getAllHotels(true);
if ($activeHotels) {
$this->initCart();
}
}
public function postProcess()
{
$objHotelBranchInformation = new HotelBranchInformation();
$activeHotels = $objHotelBranchInformation->getAllHotels(true);
$hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1);
// filter hotels as per accessed hotels
$hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1);
if ($activeHotels) {
if ($hotelBranchesInfo) {
if (Tools::getValue('date_from')) {
$date_from = Tools::getValue('date_from');
} else {
@@ -292,14 +291,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
public function renderView()
{
$objHotelBranchInformation = new HotelBranchInformation();
$activeHotels = $objHotelBranchInformation->getAllHotels(true);
$hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1);
// filter hotels as per accessed hotels
$hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1);
$this->tpl_view_vars['has_active_hotels'] = $activeHotels;
if ($activeHotels) {
if ($hotelBranchesInfo) {
$this->tpl_view_vars['id_cart'] = $this->context->cart->id;
$this->tpl_view_vars['id_guest'] = $this->context->cookie->id_guest;
$this->initSearchFormData();
if (count($this->tpl_view_vars['hotel_list'])) {
if (count($hotelBranchesInfo)) {
if ($this->booking_product) {
$this->assignRoomBookingForm();
} else {

View File

@@ -1,5 +1,5 @@
<div class="row">
{if isset($has_active_hotels) && $has_active_hotels && $hotel_list|count > 0}
{if $hotel_list|count > 0}
<div class="col-sm-4">
<div class="panel">
<div class="panel-heading">