From 4068f9526b29dcac141538e32274e8b0ed2e764b Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 1 Feb 2023 16:09:44 +0530 Subject: [PATCH 01/63] updated location field data in search panel --- .../classes/HotelBookingDetail.php | 3 ++ .../classes/HotelBranchInformation.php | 2 +- .../classes/WkRoomSearchHelper.php | 34 ++++++++++++++----- .../controllers/front/autocompletesearch.php | 14 ++++---- .../views/js/wk-room-search-block.js | 8 ++--- .../views/templates/hook/searchForm.tpl | 3 +- .../wkroomsearchblock/wkroomsearchblock.php | 4 +++ 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index cfb26c1db..968dc3427 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1565,6 +1565,9 @@ class HotelBookingDetail extends ObjectModel if ($occupancy) { $urlData['occupancy'] = $occupancy; } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } if (Configuration::get('PS_REWRITING_SETTINGS')) { $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'?'.http_build_query($urlData); diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 2fc5ed567..1775f8c6c 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -504,7 +504,7 @@ class HotelBranchInformation extends ObjectModel ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)$idLang.') WHERE hbi.`id_category` = '.(int)$cat_id.' AND `active` = 1'; - return Db::getInstance()->executeS($sql); + return Db::getInstance()->getRow($sql); } /** diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index 1a46cb512..2398ee475 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -98,6 +98,7 @@ class WkRoomSearchHelper public function assignSearchPanelVariables() { $smartyVars = array(); + $context = Context::getContext(); // send if page is landing or not $smartyVars['is_index_page'] = 0; if (Tools::getValue('controller') == 'index') { @@ -136,6 +137,8 @@ class WkRoomSearchHelper $smartyVars['date_from'] = $dateFrom; $smartyVars['date_to'] = $dateTo; + $locationCategoryId = Tools::getValue('location'); + if (Validate::isLoadedObject($objCategory = new Category((int) $idHotelCategory))) { $idHotel = HotelBranchInformation::getHotelIdByIdCategory($idHotelCategory); $htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent); @@ -148,11 +151,18 @@ class WkRoomSearchHelper $searchedData['date_to'] = $dateTo; $searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel); - $searchedData['location'] = $searchedData['htl_dtl']['city']; - if (isset($searchedData['htl_dtl']['state_name'])) { - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['state_name']; + if ($locationCategoryId) { + $objLocationCategory = new Category($locationCategoryId, $context->language->id); + $searchedData['location'] = $objLocationCategory->name; + } else { + $locationCategoryId = $objCategory->id_parent; + $searchedData['location'] = $searchedData['htl_dtl']['city']; + if (isset($searchedData['htl_dtl']['state_name'])) { + $searchedData['location'] .= ', '.$searchedData['htl_dtl']['state_name']; + } + $searchedData['location'] .= ', '.$searchedData['htl_dtl']['country_name']; } - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['country_name']; + $searchedData['location_category_id'] = $locationCategoryId; $searchedData['order_date_restrict'] = false; $max_order_date = HotelOrderRestrictDate::getMaxOrderDate($idHotel); @@ -184,16 +194,22 @@ class WkRoomSearchHelper // if location is enabled the send hotels of the selected location only if ($locationEnabled) { - $hotelsInfo = $objHotelInfo->hotelBranchInfoByCategoryId($idHotelCategory); + $hotelsInfo = Category::getAllCategoriesName($locationCategoryId); } } $totalActiveHotels = count($hotelsInfo); // set hotels order restrict date on all hotels - foreach ($hotelsInfo as &$hotel) { - $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel['id']); - $hotel['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate)); - $hotel['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel['id']); + foreach ($hotelsInfo as $key => $hotel) { + if ($hotel_info = $objHotelInfo->hotelBranchInfoByCategoryId($hotel['id_category'])) { + $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']); + $hotelsInfo[$key]['id'] = $hotel_info['id']; + $hotelsInfo[$key]['hotel_name'] = $hotel_info['hotel_name']; + $hotelsInfo[$key]['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate)); + $hotelsInfo[$key]['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel_info['id']); + } else { + unset($hotelsInfo[$key]); + } } $smartyVars['location_enabled'] = $locationEnabled; $smartyVars['total_active_hotels'] = $totalActiveHotels; diff --git a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php index d8aa6ad59..4a051c103 100644 --- a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php +++ b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php @@ -26,7 +26,7 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro $this->display_column_left = false; $this->display_column_right = false; $search_data = Tools::getValue('to_search_data'); - $city_cat_id = Tools::getValue('hotel_city_cat_id'); + $location_category_id = Tools::getValue('location_category_id'); $obj_htl_info = new HotelBranchInformation(); if (isset($search_data) && $search_data) { $return_data = $obj_htl_info->getHotelCategoryTree($search_data); @@ -39,17 +39,17 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro $result['status'] = 'success'; $result['data'] = $html; } - } elseif (isset($city_cat_id) && $city_cat_id) { - $cat_ids = Category::getAllCategoriesName($city_cat_id); + } elseif (isset($location_category_id) && $location_category_id) { + $cat_ids = Category::getAllCategoriesName($location_category_id); if ($cat_ids) { $html = ''; foreach ($cat_ids as $value) { if ($hotel_info = $obj_htl_info->hotelBranchInfoByCategoryId($value['id_category'])) { - $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info[0]['id']); + $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']); $maxOrderDate = date('Y-m-d', strtotime($maxOrderDate)); - $html .= '
  • '. - $hotel_info[0]['hotel_name'].'
  • '; + $html .= '
  • '. + $hotel_info['hotel_name'].'
  • '; } } $result['status'] = 'success'; diff --git a/modules/wkroomsearchblock/views/js/wk-room-search-block.js b/modules/wkroomsearchblock/views/js/wk-room-search-block.js index b60e3a77b..960416064 100644 --- a/modules/wkroomsearchblock/views/js/wk-room-search-block.js +++ b/modules/wkroomsearchblock/views/js/wk-room-search-block.js @@ -184,14 +184,14 @@ $(document).ready(function() { // set data on clicking the searched location on dropdown $(document).on('click', '.location_search_results_ul li', function(e) { $('#hotel_location').attr('value', $(this).html()); - $('#hotel_location').attr('city_cat_id', $(this).val()); + $('#location_category_id').val($(this).val()); $('.location_search_results_ul').empty().hide(); $.ajax({ url: autocomplete_search_url, data: { - hotel_city_cat_id: $('#hotel_location').attr('city_cat_id'), + location_category_id: $('#location_category_id').val(), }, method: 'POST', dataType: 'json', @@ -280,12 +280,12 @@ $(document).ready(function() { var max_order_date = $("#max_order_date").val(); var error = false; - var locationCatId = $('#hotel_location').attr('city_cat_id'); + var location_category_id = $('#location_category_id').val(); var hotelCatId = $('#hotel_cat_id').val(); $('.header-rmsearch-input').removeClass("error_border"); if (hotelCatId == '') { - if (typeof(locationCatId) == 'undefined' || locationCatId == '') { + if (typeof(location_category_id) == 'undefined' || location_category_id == '') { $("#hotel_location").addClass("error_border"); error = true; } diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index 6f5dae6c9..0f8a337de 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -1,7 +1,8 @@
    {if isset($location_enabled) && $location_enabled}
    - + + diff --git a/modules/wkroomsearchblock/wkroomsearchblock.php b/modules/wkroomsearchblock/wkroomsearchblock.php index c30f04129..6bb730efc 100644 --- a/modules/wkroomsearchblock/wkroomsearchblock.php +++ b/modules/wkroomsearchblock/wkroomsearchblock.php @@ -169,6 +169,10 @@ class WkRoomSearchBlock extends Module } } + if ($locationCategoryId = Tools::getValue('location_category_id')) { + $urlData['location'] = $locationCategoryId; + } + $objSearchHelper = new WkRoomSearchHelper(); $this->context->controller->errors = array_merge( $this->context->controller->errors, From 7f62962e4748de4464e4ba4fcaf63db25543ba02 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 23 Feb 2023 17:17:52 +0530 Subject: [PATCH 02/63] Fix disable dates --- .../controllers/products/configuration.tpl | 113 ++++++++++++------ controllers/admin/AdminProductsController.php | 63 ++++++++++ 2 files changed, 142 insertions(+), 34 deletions(-) diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index 386114df0..9372e0bf5 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -95,7 +95,7 @@ - {if $room_info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }{l s='Add Dates'}{else}{l s='View Dates'}{/if} + {if $room_info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }{l s='Add Dates'}{else}{l s='View Dates'}{/if} @@ -184,6 +184,7 @@
    -
    - -
    -
    - {l s='unit'} - -
    -
    -
    @@ -51,8 +46,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { - font-size: 14px;} + /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ + /* font-size: 14px;} */ #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..1b96dba9b 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} -
    - - {if isset($orderEdit) && $orderEdit} -

    - - -

    +
    + + {if isset($orderEdit) && $orderEdit} +

    + + +

    - {* Already selected room demands *} -
    - - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - - {/foreach} + {* Already selected room demands *} +
    +
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    + + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + {/foreach} - {else} - - - - {/if} - -
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    - {l s='No facilities added yet.'} -
    -
    + {/foreach} + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
    - {* Room demands available for the current editing room*} -
    -
    - {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
    -
    -
    -
    - -
    -
    -

    {$demand['name']|escape:'html':'UTF-8'}

    - {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} -
    + {* Room demands available for the current editing room*} +
    +
    + {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
    +
    +
    +
    + +
    +
    +

    {$demand['name']|escape:'html':'UTF-8'}

    + {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/if}
    -
    -

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    -
    - {/foreach} - {/if} -
    - -
    - {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
    - {foreach $roomDemand['extra_demands'] as $demand} -
    -

    - {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

    +
    +

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    +
    {/foreach} -
    - {/foreach} - {/if} -
    -{/if} \ No newline at end of file + {/if} +
    + +
    + {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
    + {foreach $roomDemand['extra_demands'] as $demand} +
    +

    + {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

    +
    + {/foreach} +
    + {/foreach} + {else} + {l s='No facilities available!'} + {/if} +
    \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 66c2e5b21..7566f1e5b 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,114 +17,114 @@ * @license https://store.webkul.com/license.html *} -{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} -
    - {if isset($orderEdit) && $orderEdit} +
    + {if isset($orderEdit) && $orderEdit} -

    - - -

    +

    + + +

    - {* Already selected room services *} -
    - - - {if isset($additionalServices) && $additionalServices} - {foreach $additionalServices['additional_services'] as $service} - - - + + + + {/foreach} + {else} + + + + {/if} + +
    -
    {$service['name']|escape:'html':'UTF-8'}
    - {if $service['allow_multiple_quantity']} -
    - -
    - {/if} -
    - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} - {l s='Convenience fee'} + {* Already selected room services *} +
    + + + {if isset($additionalServices) && $additionalServices} + {foreach $additionalServices['additional_services'] as $service} + + - - - - {/foreach} - {else} - - - - {/if} - -
    +
    {$service['name']|escape:'html':'UTF-8'}
    + {if $service['allow_multiple_quantity']} +
    + +
    {/if} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} - {l s='Auto added'} - {/if} -
    {displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
    - {l s='No services added yet.'}
    -
    - -
    - {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {foreach $roomTypeServiceProducts as $product} -
    -
    -
    -
    - -
    -
    -

    {$product['name']|escape:'html':'UTF-8'}

    - {if $product.allow_multiple_quantity} -
    - -
    - {/if} -
    -
    -
    -
    -

    - {convertPrice price=$product.price_tax_incl} -

    -
    -
    - {/foreach} - {else} - {l s='No services available to select, All services already added.'} - {/if} -
    - - - - - {elseif isset($additionalServices) && $additionalServices} -
    - {foreach $additionalServices['additional_services'] as $service} -
    -
    -
    - +
    {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} {/if} {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'} {/if} - -
    {$service['name']|escape:'html':'UTF-8'}
    - {if $service['allow_multiple_quantity']} -
    {l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
    - {/if} - +
    {displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
    + {l s='No services added yet.'} +
    +
    +
    +
    + {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} + {foreach $roomTypeServiceProducts as $product} +
    +
    +
    +
    + +
    +
    +

    {$product['name']|escape:'html':'UTF-8'}

    + {if $product.allow_multiple_quantity} +
    + +
    + {/if} +
    +
    -
    - {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
    +

    + {convertPrice price=$product.price_tax_incl} +

    -
    - {/foreach} + {/foreach} + {else} + {l s='No services available to select, All services already added.'} + {/if}
    - {/if} -
    -{/if} + + + + + {elseif isset($additionalServices) && $additionalServices} +
    + {foreach $additionalServices['additional_services'] as $service} +
    +
    +
    + + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} + {l s='Convenience fee'} + {/if} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} + {l s='Auto added'} + {/if} + +
    {$service['name']|escape:'html':'UTF-8'}
    + {if $service['allow_multiple_quantity']} +
    {l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
    + {/if} + +
    +
    + {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
    +
    +
    + {/foreach} +
    + {else} + {l s='No services available!'} + {/if} +
    diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 8a2b5b313..5dd42117e 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,14 +1717,21 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { $(this).val(1); } updateServiceProducts($(this)); }); + $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { + var qty_wntd = $(this).val(); + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + $(this).val(1); + } + }); + function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..574459920 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -568,10 +568,6 @@ class CartCore extends ObjectModel $sql->where('cp.`id_product` = '.(int)$id_product); } $sql->where('p.`id_product` IS NOT NULL'); - // hide invisible products - // if ($front) { - // $sql->where('p.`is_invisible` = 0'); - // } // Build ORDER BY $sql->orderBy('cp.`date_add`, cp.`id_product`, cp.`id_product_attribute` ASC'); diff --git a/classes/Product.php b/classes/Product.php index 33d169e23..5664c139b 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -240,7 +240,6 @@ class ProductCore extends ObjectModel public $cache_has_attachments; public $is_virtual; public $booking_product; - public $is_invisible; public $id_pack_product_attribute; public $cache_default_attribute; @@ -297,7 +296,6 @@ class ProductCore extends ObjectModel 'cache_has_attachments' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'booking_product' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'is_invisible' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'service_product_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), /* Shop fields */ @@ -992,7 +990,7 @@ class ProductCore extends ObjectModel public function deleteServiceInfo() { if (!RoomTypeServiceProduct::deleteRoomProductLink($this->id) - ||RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) + || !RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) ) { return false; } @@ -1339,7 +1337,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -1384,7 +1381,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); @@ -1429,7 +1425,6 @@ class ProductCore extends ObjectModel AND p.`service_product_type` = '.(int)self::SERVICE_PRODUCT_WITH_ROOMTYPE. ' AND product_shop.`id_shop` = '.(int)$context->shop->id .($front ? ' AND product_shop.`auto_add_to_cart` = 0 AND product_shop.`show_at_front` = 1':'') - .($front ? ' AND p.`is_invisible` = 0':'') .($active ? ' AND product_shop.`active` = 1' : ''); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 139b392ab..2794311ff 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -145,8 +145,7 @@ class SpecificPriceCore extends ObjectModel FROM `'._DB_PREFIX_.'specific_price` WHERE 1 '.self::filterOutField('id_product', $id_product). ($id_product_attribute ? ' AND id_product_attribute = '.(int) $id_product_attribute : '').' - AND id_cart = '.(int) $id_cart.' - GROUP BY `id_specific_price_rule`' + AND id_cart = '.(int) $id_cart ); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..5210546c9 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -99,7 +99,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs_lang = array( 'Informations' => $this->l('Information'), 'Prices' => $this->l('Prices'), - 'Seo' => $this->l('SEO'), + // 'Seo' => $this->l('SEO'), 'Images' => $this->l('Images'), 'Associations' => $this->l('Associations'), ); @@ -108,7 +108,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs = array_merge($this->available_tabs, array( 'Informations' => 0, 'Prices' => 1, - 'Seo' => 2, + // 'Seo' => 2, 'Associations' => 3, 'Images' => 4, )); @@ -948,7 +948,7 @@ class AdminNormalProductsControllerCore extends AdminController $id_groups = Tools::getValue('spm_id_group'); $id_customers = Tools::getValue('spm_id_customer'); $prices = Tools::getValue('spm_price'); - $from_quantities = Tools::getValue('spm_from_quantity'); + $from_quantities = 1; $reductions = Tools::getValue('spm_reduction'); $reduction_types = Tools::getValue('spm_reduction_type'); $froms = Tools::getValue('spm_from'); @@ -1939,7 +1939,7 @@ class AdminNormalProductsControllerCore extends AdminController if ($this->isTabSubmitted('Prices')) { // $this->processAdvancedPayment(); $this->processPriceAddition(); - // $this->processSpecificPricePriorities(); + $this->processSpecificPricePriorities(); } if ($this->isTabSubmitted('Images')) { $this->processImageLegends(); @@ -2016,6 +2016,22 @@ class AdminNormalProductsControllerCore extends AdminController $default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); + + // we have removed seo tab as it is currently not required, but in product object requires link_rewrite + // so adding link_rewrite in $_POST + if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { + $link_rewrite = $_POST['name_'.$default_language->id]; + if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { + $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + } + $link_rewrite = str_replace(' ', '-', $link_rewrite); + $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); + $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; + } else { + $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + } + // end + // Check required fields foreach ($rules['required'] as $field) { if (!$this->isProductFieldUpdated($field)) { @@ -2855,13 +2871,12 @@ class AdminNormalProductsControllerCore extends AdminController $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setTemplate('tree_associated_categories.tpl') ->setHeaderTemplate('tree_associated_header.tpl') - ->setRootCategory((int)Configuration::get('PS_PRODUCTS_CATEGORY')) + ->setRootCategory((int)Configuration::get('PS_SERVICE_CATEGORY')) ->setUseCheckBox(true) ->setUseSearch(false) ->setFullTree(0) ->setSelectedCategories($categories) ->setUseBulkActions(false); - // ->setDisablAllCategories(true); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..ca9b99ff1 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,6 +4738,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } + $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d49a74365..cb73e6fa6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2081,7 +2081,6 @@ class AdminProductsControllerCore extends AdminController } } - // shreesh check if product is virtual, then set categories according to hotel // if (Tools::getValue('is_virtual')) { $id_hotel = Tools::getValue('id_hotel'); if (!$id_hotel || !Validate::isUnsignedInt($id_hotel)) { diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f5a5bec2b..cc11fa369 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + parent::initContent(); // check ORDER RESTRICT condition before payment by the customer @@ -452,7 +455,6 @@ class OrderOpcControllerCore extends ParentOrderController $this->context->smarty->assign('checkout_process_steps', $this->checkoutProcess->getSteps()); - // @todo shreesh get this checked with sumit sir // set room type demands // $objGlobalDemand = new HotelRoomTypeGlobalDemand(); // $allDemands = $objGlobalDemand->getAllDemands(); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..054555062 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,12 +1318,13 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'status' => false + 'success' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); + $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1334,7 +1335,22 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - $response['status'] = true; + if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { + $response['success'] = true; + if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { + if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } else { + $response['msg'] = 'Service already added.'; + } + } else { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } + } else { + $response['error'] = Tools::displayError('Service not Found'); + } } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 5bc961640..8d5607c38 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1554,7 +1554,6 @@ CREATE TABLE `PREFIX_product` ( `cache_has_attachments` tinyint(1) NOT NULL DEFAULT '0', `is_virtual` tinyint(1) NOT NULL DEFAULT '0', `booking_product` tinyint(1) NOT NULL DEFAULT '1', - `is_invisible` tinyint(1) NOT NULL DEFAULT '0', `cache_default_attribute` int(10) unsigned DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index a0187a2f0..902335903 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index cee1fe886..59dc5ab17 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,6 +50,9 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index c96ff78ec..5df9b7411 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,6 +49,9 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index e1415337d..1d5e0f76b 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,6 +50,9 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index 6f75120a9..f280abd3f 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,6 +48,9 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 199d3a178..6a16c420d 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,6 +182,8 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); + + $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..f9446f9f9 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,4 +341,20 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } + + public static function validateServiceProductsInCart() + { + $context = Context::getContext(); + if ($cartProducts = $context->cart->getProducts()) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + foreach ($cartProducts as $product) { + if (!$product['active'] && !$product['booking_product']) { + $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); + foreach ($serviceProducts as $serviceProduct) { + $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); + } + } + } + } + } } \ No newline at end of file diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index f700c7720..08e3c1b8e 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,9 +20,15 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} + {foreach $product.images as $image} + {if $image['cover'] == 0} + + {/if} + {/foreach}
    @@ -36,7 +42,7 @@ {/if}
    - {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} @@ -46,20 +52,21 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if} {/if} {/if} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} +
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 2b3565520..370f10de9 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..57a0add94 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,6 +1201,15 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } + var added_service_product = []; + + $('#additional_products input.service_product').each(function () { + added_service_product.push({ + 'id_product': $(this).data('id_product'), + 'quantity':$(this).val(), + }); + }); + $.ajax({ type: 'POST', headers: { @@ -1215,31 +1224,36 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, + added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.status) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); + if (result.success) { + if (result.add) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); + } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - showSuccessMessage(cart_extra_service_add); + if (result.msg) { + showSuccessMessage(result.msg); + } BookingForm.refresh(); } else { if (result.error) { From 71322e0548507b7a7aee96b2b6af2a9df3fb1e38 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 11:20:57 +0530 Subject: [PATCH 06/63] added max guest info --- controllers/front/ProductController.php | 4 ---- themes/hotel-reservation-theme/_partials/room_type_list.tpl | 4 ++-- themes/hotel-reservation-theme/css/category.css | 6 ------ themes/hotel-reservation-theme/product.tpl | 4 ++-- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..93e39a86b 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -307,10 +307,6 @@ class ProductControllerCore extends FrontController $htl_features = array(); $obj_hotel_room_type = new HotelRoomType(); $room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id); - $productCapacity = array(); - $productCapacity['adults'] = $room_info_by_product_id['adults']; - $productCapacity['children'] = $room_info_by_product_id['children']; - $this->product->capacity = $productCapacity; if ($hotel_id = $room_info_by_product_id['id_hotel']) { $obj_hotel_branch = new HotelBranchInformation(); $hotel_info_by_id = $obj_hotel_branch->hotelBranchesInfo(false, 2, 1, $hotel_id); diff --git a/themes/hotel-reservation-theme/_partials/room_type_list.tpl b/themes/hotel-reservation-theme/_partials/room_type_list.tpl index 22d408949..f47e7e041 100644 --- a/themes/hotel-reservation-theme/_partials/room_type_list.tpl +++ b/themes/hotel-reservation-theme/_partials/room_type_list.tpl @@ -49,7 +49,7 @@ {/if}
    {if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} @@ -70,7 +70,7 @@ {/if}
    -
    {l s='Max Capacity:'}
    {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {l s='child'}
    +
    {$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}
    {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}
    diff --git a/themes/hotel-reservation-theme/css/category.css b/themes/hotel-reservation-theme/css/category.css index faaa81fa2..d79ba9ddb 100644 --- a/themes/hotel-reservation-theme/css/category.css +++ b/themes/hotel-reservation-theme/css/category.css @@ -109,12 +109,6 @@ p.capa_txt { margin-bottom: 15px; } -.capa_data -{ - color: #555555; - font-weight: 600; -} - .rm_review_cont { margin-bottom: 15px; diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index ac13fb574..9f3591739 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -199,13 +199,13 @@ {$product->description}
    - {if isset($product->capacity['adults']) && isset($product->capacity['children']) } + {if isset($room_type_info['adults']) && isset($room_type_info['children']) }
    {l s='Max Capacity'}
    -

    {$product->capacity['adults']} {l s='Adults'}, {$product->capacity['children']} {l s='child'}

    +

    {$room_type_info['adults']} {l s='Adults'}, {$room_type_info['children']} {if $room_type_info['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if} ({l s='Max guests'}: {$room_type_info['max_guests']|escape:'htmlall':'UTF-8'})

    {/if} From f34b8a4b67c05cf2fae8f6239eb00ba9a9e8c7c2 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:43:40 +0530 Subject: [PATCH 07/63] updated link_rewrite field of service product --- controllers/admin/AdminNormalProductsController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 5210546c9..1ffa75ae4 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2020,15 +2020,13 @@ class AdminNormalProductsControllerCore extends AdminController // we have removed seo tab as it is currently not required, but in product object requires link_rewrite // so adding link_rewrite in $_POST if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { - $link_rewrite = $_POST['name_'.$default_language->id]; - if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { - $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); } - $link_rewrite = str_replace(' ', '-', $link_rewrite); - $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); - $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; } else { - $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']]; + } } // end From 103d2ccfd863eeefad7029471573c4a2156bba5e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:53:45 +0530 Subject: [PATCH 08/63] fixed undefined index issue when booking multiple rooms --- controllers/front/OrderDetailController.php | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 2a898f8b6..20ed72474 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); } - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); // calculate averages now foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); From 49da8574d7e1af3ca1ee33cd26fa1dcacbc84b47 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 5 Mar 2023 12:24:35 +0530 Subject: [PATCH 09/63] resolve export issue --- controllers/admin/AdminCartsController.php | 1 + controllers/admin/AdminNormalProductsController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index db54f518c..fd7802f8b 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -135,6 +135,7 @@ class AdminCartsControllerCore extends AdminController $smartyVars['type'] = 'non_orderd'; } } + $smartyVars['link'] = $this->context->link; $tpl = $this->createTemplate('_orders.tpl'); $tpl->assign($smartyVars); diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..e14345a50 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -90,7 +90,7 @@ class AdminNormalProductsControllerCore extends AdminController parent::__construct(); $this->imageType = 'jpg'; - $this->_defaultOrderBy = 'position'; + $this->_defaultOrderBy = 'id_product'; $this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000); $this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'); $this->allow_export = true; From 700559461c4b4370620314129d24ead4b6c694db Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 12:57:17 +0530 Subject: [PATCH 10/63] Add cancellation policy section on admin order view page --- .../controllers/orders/helpers/view/view.tpl | 24 +++++++++++++ controllers/admin/AdminOrdersController.php | 4 +++ .../classes/HotelOrderRefundRules.php | 34 +++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 8a2b5b313..26a716bbd 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1114,6 +1114,30 @@
    {/if} +
    +
    + {l s='Cancellation Policies'} +
    + {if is_array($applicable_refund_policies) && count($applicable_refund_policies)} + + {else} +

    + + {l s='No cancellation policies applicable.'} +

    + {/if} +
    {hook h="displayAdminOrderRight" id_order=$order->id}
  • diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..1518fe160 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1661,9 +1661,13 @@ class AdminOrdersControllerCore extends AdminController // hotel booking statuses $htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus(); + + // applicable refund policies + $applicableRefundPolicies = HotelOrderRefundRules::getApplicableRefundRules($order->id); $this->tpl_view_vars = array( // refund info 'refund_allowed' => (int) $order->isReturnable(), + 'applicable_refund_policies' => $applicableRefundPolicies, 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'refundReqBookings' => $refundReqBookings, 'hasCompletelyRefunded' => $order->hasCompletelyRefunded(), diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index d49354299..1a8b021d9 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -222,4 +222,38 @@ class HotelOrderRefundRules extends ObjectModel return $totalCancelationCharges; } + + public static function getApplicableRefundRules($idOrder) + { + $idLang = Context::getContext()->language->id; + + $minDate = Db::getInstance()->getValue( + 'SELECT MIN(DATE(hbd.`date_from`)) + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_order` = '.(int) $idOrder + ); + + if (!$minDate) { + return array(); + } + + $dateToday = date('Y-m-d'); + + if (strtotime($minDate) < strtotime($dateToday)) { // same day cancellation rules are allowed + $minDate = $dateToday; + } + + $days = HotelBookingDetail::getDays($dateToday, $minDate); + + $sql = 'SELECT * + FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hrr + LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` orr + ON (orr.`id_refund_rule` = hrr.`id_refund_rule`) + LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` orrl + ON (orrl.`id_refund_rule` = orr.`id_refund_rule` AND orrl.`id_lang` = '.(int) $idLang.') + WHERE orr.`days` <= '.(int) $days.' + ORDER BY orr.`days` DESC'; + + return Db::getInstance()->executeS($sql); + } } From 12c0f7ef093fd2cd0742e5bf63c562365201e3e3 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 13:22:46 +0530 Subject: [PATCH 11/63] Update Refunds section on admin order view page --- .../template/controllers/orders/helpers/view/view.tpl | 8 ++++++++ classes/order/OrderReturn.php | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 26a716bbd..f7b698329 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1065,7 +1065,9 @@ {l s='Refund ID'} + {l s='Total Rooms'} {l s='Status'} + {l s='Requested Date'} @@ -1074,6 +1076,9 @@ #{$return_info.id_order_return} + + {$return_info.total_rooms|escape:'html':'UTF-8'} + {capture name=refund_status} {if isset($return_info.payment_mode) && $return_info.payment_mode != ''}{l s='Payment Mode: '}{$return_info.payment_mode}
    {/if} @@ -1108,6 +1113,9 @@ {$return_info.state_name} {/if} + + {$return_info.date_add} + {/foreach} diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 41623a56e..8a4cf796c 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -260,7 +260,12 @@ class OrderReturnCore extends ObjectModel if (!$context) { $context = Context::getContext(); } - $sql = 'SELECT * + $sql = 'SELECT *, orr.`date_add`, orr.`date_upd`, + ( + SELECT COUNT(ord.`id_order_return_detail`) + FROM `'._DB_PREFIX_.'order_return_detail` ord + WHERE ord.`id_order_return` = orr.`id_order_return` + ) AS total_rooms FROM `'._DB_PREFIX_.'order_return` orr LEFT JOIN `'._DB_PREFIX_.'order_slip` ors ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') From 6e7ce9e58a1113c45ba50e3612b7f36d55965d6a Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 5 Mar 2023 14:32:42 +0530 Subject: [PATCH 12/63] resolves incorrect adv payment when when discount is greater than adv amount --- classes/Cart.php | 4 +- themes/hotel-reservation-theme/order-opc.tpl | 52 ++++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..0d60ad758 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1991,7 +1991,9 @@ class CartCore extends ObjectModel } } } - $order_total_discount = min(Tools::ps_round($order_total_discount, 2), (float)$order_total_products) + (float)$order_shipping_discount; + if ($type != Cart::ADVANCE_PAYMENT) { + $order_total_discount = min(Tools::ps_round($order_total_discount, 2), (float)$order_total_products) + (float)$order_shipping_discount; + } if ($type == Cart::ADVANCE_PAYMENT) { // get order total without discount $total_without_discount = $this->getOrderTotal() + $order_total_discount; diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 788a01395..645981948 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -274,35 +274,33 @@ {displayPrice price=$total_discounts_negative}

    - {if $use_taxes && $show_taxes && $total_tax != 0 } - {* {if $priceDisplay != 0} *} -

    - - {l s='Total'} - {if $display_tax_label} - {if $use_taxes && $priceDisplay == 0} - {l s='(tax incl)'} - {else} - {l s='(tax excl)'} - {/if} - {/if} - - - {if $use_taxes && $priceDisplay == 0} - {displayPrice price=$total_price - $convenience_fee_wt} + {* {if $priceDisplay != 0} *} +

    + + {l s='Total'} + {if $display_tax_label} + {if $use_taxes && $priceDisplay == 0} + {l s='(tax incl)'} {else} - {displayPrice price=$total_price_without_tax - $convenience_fee} + {l s='(tax excl)'} {/if} - -

    - {* {/if} *} - {* {if $total_rooms_wt != 0} -

    - {l s='Tax on rooms'} - {displayPrice price=($total_rooms_wt - $total_rooms)} -

    - {/if} *} - {/if} + {/if} + + + {if $use_taxes && $priceDisplay == 0} + {displayPrice price=$total_price - $convenience_fee_wt} + {else} + {displayPrice price=$total_price_without_tax - $convenience_fee} + {/if} + +

    + {* {/if} *} + {* {if $total_rooms_wt != 0} +

    + {l s='Tax on rooms'} + {displayPrice price=($total_rooms_wt - $total_rooms)} +

    + {/if} *} {if $convenience_fee_wt}

    {l s='Convenience Fees'} From 15d794f32ed4947031c39622e7d0cf4e584f64cd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 5 Mar 2023 16:14:03 +0530 Subject: [PATCH 13/63] Remove refund ID column on refunds list page --- classes/order/OrderReturn.php | 5 ++++- themes/hotel-reservation-theme/order-follow.tpl | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 41623a56e..009bf6f4f 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -260,14 +260,17 @@ class OrderReturnCore extends ObjectModel if (!$context) { $context = Context::getContext(); } - $sql = 'SELECT * + $sql = 'SELECT *, orr.*, COUNT(ord.`id_order_return_detail`) AS total_rooms FROM `'._DB_PREFIX_.'order_return` orr + LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord + ON (ord.`id_order_return` = orr.`id_order_return`) LEFT JOIN `'._DB_PREFIX_.'order_slip` ors ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') WHERE orr.`id_customer` = '.(int)$customer_id. ($only_customer ? ' AND orr.`by_admin` = 0' : ''). ($order_id ? ' AND orr.`id_order` = '.(int)$order_id : ''). ($no_denied ? ' AND orr.`state` != 4' : '').' + GROUP BY orr.`id_order_return` ORDER BY orr.`date_add` DESC'; $data = Db::getInstance()->executeS($sql); foreach ($data as $k => $or) { diff --git a/themes/hotel-reservation-theme/order-follow.tpl b/themes/hotel-reservation-theme/order-follow.tpl index 0f0bed50d..9d8b2e0f8 100644 --- a/themes/hotel-reservation-theme/order-follow.tpl +++ b/themes/hotel-reservation-theme/order-follow.tpl @@ -44,21 +44,21 @@ - + - + {foreach from=$ordersReturns item=return} - - + + + + + + - {foreach from=$products item='product'} - - - - - - + {foreach from=$cart_htl_data item='room'} + + + + + + + + + + {/foreach} - + {if $total_discounts != 0} - + {/if} {if $total_wrapping > 0} - + {/if} {if $cart->getOrderTotal(true, Cart::ONLY_SHIPPING) > 0} - + {/if} - + diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index 55c886ccd..3533a52dd 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -141,9 +141,9 @@ {displayPrice price=$data.amt_with_qty} *} + + + {/if} + +
    {l s='Refund Id'} {l s='Order'}{l s='Total rooms'} {l s='Refund status'} {l s='Date requested'}{l s='Actions'}
    - {l s='#'}{$return.id_order_return|escape:'html':'UTF-8'} + #{$return.reference|escape:'html':'UTF-8'} - #{$return.reference|escape:'html':'UTF-8'} + {$return.total_rooms|escape:'html':'UTF-8'} {$return.state_name|escape:'html':'UTF-8'} From d66745e4ddf10faaefc53bae73028877b6cf0d2e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 09:32:42 +0000 Subject: [PATCH 14/63] fix errors not visible on clicking book now --- .../hotel-reservation-theme/js/occupancy.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/themes/hotel-reservation-theme/js/occupancy.js b/themes/hotel-reservation-theme/js/occupancy.js index f3679b234..af1b3fca6 100644 --- a/themes/hotel-reservation-theme/js/occupancy.js +++ b/themes/hotel-reservation-theme/js/occupancy.js @@ -123,8 +123,12 @@ $(document).ready(function(){ }); $(document).on('click', '.booking_guest_occupancy', function(e) { - $('.booking_guest_occupancy_conatiner .dropdown').removeClass('open'); - $(this).parent().toggleClass('open'); + if ($(this).parent().hasClass('open')) { + $('.booking_guest_occupancy_conatiner .dropdown').removeClass('open'); + } else { + $('.booking_guest_occupancy_conatiner .dropdown').removeClass('open'); + $(this).parent().toggleClass('open'); + } }); $(document).on('click', function(e) { @@ -132,7 +136,10 @@ $(document).ready(function(){ var occupancy_wrapper = $('.booking_occupancy_wrapper:visible'); $(occupancy_wrapper).find(".occupancy_info_block").addClass('selected'); setRoomTypeGuestOccupancy(occupancy_wrapper); - if (!($(e.target).closest(".booking_occupancy_wrapper").length || $(e.target).closest(".booking_guest_occupancy").length || $(e.target).closest(".ajax_add_to_cart_button").length || $(e.target).closest(".exclusive.book_now_submit").length || $(e.target).closest(".remove-room-link").length)) { + if (!($(e.target).closest(".booking_occupancy_wrapper").length + || $(e.target).closest(".booking_guest_occupancy").length + || $(e.target).closest(".remove-room-link").length + )) { let hasErrors = 0; let adults = $(occupancy_wrapper).find(".num_adults").map(function(){return $(this).val();}).get(); @@ -169,9 +176,12 @@ $(document).ready(function(){ }); } if (hasErrors == 0) { - $(occupancy_wrapper).parent().removeClass('open'); - $(occupancy_wrapper).siblings(".booking_guest_occupancy").removeClass('error_border'); - + if (!($(e.target).closest(".ajax_add_to_cart_button").length + || $(e.target).closest(".exclusive.book_now_submit").length + )) { + $(occupancy_wrapper).parent().removeClass('open'); + $(occupancy_wrapper).siblings(".booking_guest_occupancy").removeClass('error_border'); + } $(document).trigger( "QloApps:updateRoomOccupancy", [occupancy_wrapper]); } else { $(occupancy_wrapper).siblings(".booking_guest_occupancy").addClass('error_border'); From fd728e90117cc4c1e791d98d955c1983068d9ef5 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 16:21:46 +0530 Subject: [PATCH 15/63] update booking carts controller --- .../controllers/carts/helpers/view/view.tpl | 62 +++++++++++++------ .../orders/_current_cart_details_data.tpl | 4 +- controllers/admin/AdminCartsController.php | 37 ++++------- .../classes/HotelCartBookingData.php | 3 +- 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl index 7f8a5e8d1..2962f9e3e 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -87,52 +87,74 @@
    {l s='Image'}{l s='Room Type'}{l s='Unit Price'}{l s='Room Type'}{l s='Hotel'}{l s='Duration'}{l s='occupancy'}{l s='Room price'}{l s='Extra services'} {l s='Total'}
    {$product.image} - - {$product.name}{if isset($product.attributes)}
    {$product.attributes}{/if}
    - {if $product.reference}{l s='Ref:'} {$product.reference}{/if} - {if $product.reference && $product.supplier_reference} / {$product.supplier_reference}{/if} -
    -
    {displayWtPriceWithCurrency price=$product.product_price currency=$currency}{displayWtPriceWithCurrency price=$product.product_total currency=$currency}
    + + {$room.room_type} + + {$room.room_type_info.hotel_name}{dateFormat date=$room.date_from} - {dateFormat date=$room.date_to} + + {if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} + + {displayWtPriceWithCurrency price=$room.feature_price_tax_excl currency=$currency} + {if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)} + {displayWtPriceWithCurrency price=($room.demand_price + $room.additional_service_price + $room.additional_services_auto_add_price)|escape:'html':'UTF-8' currency=$currency} + {else} + {displayWtPriceWithCurrency price=0 currency=$currency} + {/if} + + {if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)} + {displayWtPriceWithCurrency price=($room.amt_with_qty + $room.additional_services_auto_add_price + $room.demand_price + $room.additional_service_price)|escape:'html':'UTF-8' currency=$currency} + {else} + {displayWtPriceWithCurrency price=$room.amt_with_qty|escape:'html':'UTF-8' currency=$currency} + {/if} +
    {l s='Total cost of room types:'}{l s='Total cost of room types:'} {displayWtPriceWithCurrency price=$total_products currency=$currency}
    {l s='Total value of vouchers:'}{l s='Total value of vouchers:'} {displayWtPriceWithCurrency price=$total_discounts currency=$currency}
    {l s='Total cost of gift wrapping:'}{l s='Total cost of gift wrapping:'} {displayWtPriceWithCurrency price=$total_wrapping currency=$currency}
    {l s='Total cost of shipping:'}{l s='Total cost of shipping:'} {displayWtPriceWithCurrency price=$total_shipping currency=$currency}
    {l s='Total:'}{l s='Total:'} {displayWtPriceWithCurrency price=$total_price currency=$currency}
    {if (isset($data.extra_demands) && $data.extra_demands) || (isset($data.additional_service) && $data.additional_service)} - {displayPrice price=($data.feature_price_tax_excl + $data.additional_services_auto_add_price + $data.demand_price + $data.additional_service_price)|escape:'html':'UTF-8'} + {displayPrice price=($data.amt_with_qty + $data.additional_services_auto_add_price + $data.demand_price + $data.additional_service_price)|escape:'html':'UTF-8'} {else} - {displayPrice price=$data.feature_price_tax_excl|escape:'html':'UTF-8'} + {displayPrice price=$data.amt_with_qty|escape:'html':'UTF-8'} {/if} diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index db54f518c..d4c0d592d 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -270,7 +270,9 @@ class AdminCartsControllerCore extends AdminController $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int)$id_shop); - $image_product = new Image($image['id_image']); + if (isset($image['id_image'])) { + $image_product = new Image($image['id_image']); + } $product['image'] = (isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$image_product->getExistingImgPath().'.jpg', 'product_mini_'.(int)$product['id_product'].(isset($product['id_product_attribute']) ? '_'.(int)$product['id_product_attribute'] : '').'.jpg', 45, 'jpg') : '--'); } @@ -283,34 +285,19 @@ class AdminCartsControllerCore extends AdminController $helper->value = Tools::displayPrice($total_price, $currency); $kpi = $helper->generate(); // by webkul to show rooms available in the cart - $cart_id = $cart->id; - $cart_detail_data = array(); - $cart_detail_data_obj = new HotelCartBookingData(); - $cart_detail_data = $cart_detail_data_obj->getCartCurrentDataByCartId((int) $cart_id); - if ($cart_detail_data) { - foreach ($cart_detail_data as $key => $value) { - $product_image_id = Product::getCover($value['id_product']); - $obj_product = new Product((int) $value['id_product'], Configuration::get('PS_LANG_DEFAULT')); - $link_rewrite = $obj_product->link_rewrite[Configuration::get('PS_LANG_DEFAULT')]; - - if ($product_image_id) { - $cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $product_image_id['id_image'], 'small_default'); - } else { - $cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $this->context->language->iso_code."-default", 'small_default'); - } - - $cart_detail_data[$key]['room_type'] = $obj_product->name; - $obj_room_info = new HotelRoomInformation((int) $value['id_room']); - $cart_detail_data[$key]['room_num'] = $obj_room_info->room_num; - $obj_date_time_from = new DateTime($value['date_from']); - $cart_detail_data[$key]['date_from'] = $obj_date_time_from->format('d-M Y'); - $obj_date_time_to = new DateTime($value['date_to']); - $cart_detail_data[$key]['date_to'] = $obj_date_time_to->format('d-M Y'); + $cartHtlData = array(); + $objHotelCartBookingData = new HotelCartBookingData(); + $objHotelRoomType = new HotelRoomType(); + $cartHtlData = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart((int) $cart->id); + if ($cartHtlData) { + foreach ($cartHtlData as $key => $value) { + $cartHtlData[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']); } } //end + ddd($cartHtlData); $this->tpl_view_vars = array( - 'cart_detail_data' => $cart_detail_data,//by webkul hotel rooms in order data + 'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data 'kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 3afd75fac..e5806d008 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1009,7 +1009,8 @@ class HotelCartBookingData extends ObjectModel 0, $id_cart, $value['id_guest'], - $value['id_room'] + $value['id_room'], + 0 ); $cart_detail_data[$key]['amt_with_qty'] = $roomTypeDateRangePrice['total_price_tax_excl']; From f447b4fc8d789b309b0efe3494d446962f6eae48 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:26:12 +0000 Subject: [PATCH 16/63] show all images of service products --- .../classes/RoomTypeServiceProduct.php | 1 + .../_partials/service-products-list-row.tpl | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 199d3a178..b3e70609c 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -183,6 +183,7 @@ class RoomTypeServiceProduct extends ObjectModel $useTax ); } + $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } return $serviceProducts; diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index f700c7720..700910a25 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,9 +20,15 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} + {foreach $product.images as $image} + {if $image['cover'] == 0} + + {/if} + {/foreach}
    From 0752edcad586bba34ea788be7598edd75e587dc3 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:33:05 +0000 Subject: [PATCH 17/63] hide service product price in catalog mode --- .../_partials/service-products-list-row.tpl | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index f700c7720..5858d1328 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -36,7 +36,7 @@ {/if}
    - {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} @@ -46,22 +46,21 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if} {/if} {/if} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if}
    -
  • From efdfbe99abb9a3296e744c316a356efb1507e860 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:46:17 +0000 Subject: [PATCH 18/63] update services modal in admin view order --- .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++-------- .../orders/_room_services_block.tpl | 194 +++++++++--------- controllers/admin/AdminOrdersController.php | 1 + 4 files changed, 182 insertions(+), 186 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl index 2e0cd1415..4714a077b 100644 --- a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl +++ b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl @@ -22,12 +22,8 @@ @@ -51,8 +46,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { - font-size: 14px;} + /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ + /* font-size: 14px;} */ #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..1b96dba9b 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} -
    - - {if isset($orderEdit) && $orderEdit} -

    - - -

    +
    + + {if isset($orderEdit) && $orderEdit} +

    + + +

    - {* Already selected room demands *} -
    - - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - - {/foreach} + {* Already selected room demands *} +
    +
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    + + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + {/foreach} - {else} - - - - {/if} - -
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    - {l s='No facilities added yet.'} -
    -
    + {/foreach} + {else} +
    + {l s='No facilities added yet.'} +
    +

    - {* Room demands available for the current editing room*} -
    -
    - {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
    -
    -
    -
    - -
    -
    -

    {$demand['name']|escape:'html':'UTF-8'}

    - {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} -
    + {* Room demands available for the current editing room*} +
    +
    + {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
    +
    +
    +
    + +
    +
    +

    {$demand['name']|escape:'html':'UTF-8'}

    + {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/if}
    -
    -

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    -
    - {/foreach} - {/if} -
    - -
    - {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
    - {foreach $roomDemand['extra_demands'] as $demand} -
    -

    - {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

    +
    +

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    +
    {/foreach} -
    - {/foreach} - {/if} -
    -{/if} \ No newline at end of file + {/if} +
    + +
    + {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
    + {foreach $roomDemand['extra_demands'] as $demand} +
    +

    + {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

    +
    + {/foreach} +
    + {/foreach} + {else} + {l s='No facilities available!'} + {/if} +
    \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 66c2e5b21..7566f1e5b 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,114 +17,114 @@ * @license https://store.webkul.com/license.html *} -{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} -
    - {if isset($orderEdit) && $orderEdit} +
    + {if isset($orderEdit) && $orderEdit} -

    - - -

    +

    + + +

    - {* Already selected room services *} -
    - - - {if isset($additionalServices) && $additionalServices} - {foreach $additionalServices['additional_services'] as $service} - - - + + + + {/foreach} + {else} + + + + {/if} + +
    -
    {$service['name']|escape:'html':'UTF-8'}
    - {if $service['allow_multiple_quantity']} -
    - -
    - {/if} -
    - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} - {l s='Convenience fee'} + {* Already selected room services *} +
    + + + {if isset($additionalServices) && $additionalServices} + {foreach $additionalServices['additional_services'] as $service} + + - - - - {/foreach} - {else} - - - - {/if} - -
    +
    {$service['name']|escape:'html':'UTF-8'}
    + {if $service['allow_multiple_quantity']} +
    + +
    {/if} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} - {l s='Auto added'} - {/if} -
    {displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
    - {l s='No services added yet.'}
    -
    -
    -
    - {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {foreach $roomTypeServiceProducts as $product} -
    -
    -
    -
    - -
    -
    -

    {$product['name']|escape:'html':'UTF-8'}

    - {if $product.allow_multiple_quantity} -
    - -
    - {/if} -
    -
    -
    -
    -

    - {convertPrice price=$product.price_tax_incl} -

    -
    -
    - {/foreach} - {else} - {l s='No services available to select, All services already added.'} - {/if} -
    - - -
    - - {elseif isset($additionalServices) && $additionalServices} -
    - {foreach $additionalServices['additional_services'] as $service} -
    -
    -
    - +
    {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} {/if} {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'} {/if} - -
    {$service['name']|escape:'html':'UTF-8'}
    - {if $service['allow_multiple_quantity']} -
    {l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
    - {/if} - +
    {displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
    + {l s='No services added yet.'} +
    +
    +
    +
    + {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} + {foreach $roomTypeServiceProducts as $product} +
    +
    +
    +
    + +
    +
    +

    {$product['name']|escape:'html':'UTF-8'}

    + {if $product.allow_multiple_quantity} +
    + +
    + {/if} +
    +
    -
    - {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
    +

    + {convertPrice price=$product.price_tax_incl} +

    -
    - {/foreach} + {/foreach} + {else} + {l s='No services available to select, All services already added.'} + {/if}
    - {/if} -
    -{/if} + + + + + {elseif isset($additionalServices) && $additionalServices} +
    + {foreach $additionalServices['additional_services'] as $service} +
    +
    +
    + + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} + {l s='Convenience fee'} + {/if} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} + {l s='Auto added'} + {/if} + +
    {$service['name']|escape:'html':'UTF-8'}
    + {if $service['allow_multiple_quantity']} +
    {l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
    + {/if} + +
    +
    + {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
    +
    +
    + {/foreach} +
    + {else} + {l s='No services available!'} + {/if} +
    diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index f928ddfc8..d4a73c139 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4742,6 +4742,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } + $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( From ec81c1de16aa5baf9715918e1c8d06d713496f9e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 11:52:26 +0000 Subject: [PATCH 19/63] fix service not found error in service modal --- .../template/controllers/orders/helpers/view/view.tpl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 8a2b5b313..5dd42117e 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,14 +1717,21 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { $(this).val(1); } updateServiceProducts($(this)); }); + $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { + var qty_wntd = $(this).val(); + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + $(this).val(1); + } + }); + function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); From 29bc2aeb90835da533c0ba531a507f413d9cc7af Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 12:03:17 +0000 Subject: [PATCH 20/63] fix service products category group --- install/data/xml/category_group.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index a0187a2f0..902335903 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + From b5b1022bf89bca3c14e7118b1fa8bd86b38fb3ae Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 18:12:58 +0530 Subject: [PATCH 21/63] removed addition changes --- .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++++--------- .../orders/_room_services_block.tpl | 10 +- .../controllers/orders/helpers/view/view.tpl | 11 +- controllers/admin/AdminOrdersController.php | 1 - controllers/front/OrderDetailController.php | 66 ++++---- controllers/front/OrderOpcController.php | 3 - controllers/front/ProductController.php | 20 +-- install/data/xml/category_group.xml | 6 +- .../bankwire/controllers/front/payment.php | 3 - .../bankwire/controllers/front/validation.php | 3 - modules/cheque/controllers/front/payment.php | 3 - .../cheque/controllers/front/validation.php | 3 - .../classes/RoomTypeServiceProduct.php | 2 - .../RoomTypeServiceProductCartDetail.php | 16 -- .../_partials/service-products-list-row.tpl | 35 ++-- .../_partials/service-products.tpl | 2 +- themes/hotel-reservation-theme/js/product.js | 44 ++--- 18 files changed, 164 insertions(+), 237 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl index 4714a077b..2e0cd1415 100644 --- a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl +++ b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl @@ -22,8 +22,12 @@
    @@ -46,8 +51,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ - /* font-size: 14px;} */ + #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { + font-size: 14px;} #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index 1b96dba9b..abc426f8d 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -
    - - {if isset($orderEdit) && $orderEdit} -

    - - -

    +{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} +
    + + {if isset($orderEdit) && $orderEdit} +

    + + +

    - {* Already selected room demands *} -
    - - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - + {* Already selected room demands *} +
    +
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    + + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + + {/foreach} {/foreach} - {/foreach} - {else} - - - - {/if} - -
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    - {l s='No facilities added yet.'} -
    -
    + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
    - {* Room demands available for the current editing room*} -
    -
    - {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
    -
    -
    -
    - -
    -
    -

    {$demand['name']|escape:'html':'UTF-8'}

    - {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} + {* Room demands available for the current editing room*} +
    +
    + {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
    +
    +
    +
    + +
    +
    +

    {$demand['name']|escape:'html':'UTF-8'}

    + {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/if} +
    +
    +

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    +
    -
    -

    {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}

    -
    + {/foreach} + {/if} +
    + +
    + {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
    + {foreach $roomDemand['extra_demands'] as $demand} +
    +

    + {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

    {/foreach} - {/if} -
    - -
    - {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
    - {foreach $roomDemand['extra_demands'] as $demand} -
    -

    - {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

    -
    - {/foreach} -
    - {/foreach} - {else} - {l s='No facilities available!'} - {/if} -
    \ No newline at end of file +
    + {/foreach} + {/if} +
    +{/if} \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 7566f1e5b..1bbf2ad64 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,7 +17,8 @@ * @license https://store.webkul.com/license.html *} -
    +{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} +
    {if isset($orderEdit) && $orderEdit}

    @@ -36,7 +37,7 @@

    {$service['name']|escape:'html':'UTF-8'}
    {if $service['allow_multiple_quantity']}
    - +
    {/if} @@ -76,7 +77,7 @@

    {$product['name']|escape:'html':'UTF-8'}

    {if $product.allow_multiple_quantity}
    - +
    {/if}
    @@ -124,7 +125,6 @@
    {/foreach}
    - {else} - {l s='No services available!'} {/if}
    +{/if} diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 5dd42117e..8a2b5b313 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,21 +1717,14 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { $(this).val(1); } updateServiceProducts($(this)); }); - $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { - var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { - $(this).val(1); - } - }); - function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ca9b99ff1..df4af2e8d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,7 +4738,6 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } - $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 20ed72474..2a898f8b6 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); } + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); // calculate averages now foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index cc11fa369..347e82f96 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,9 +389,6 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - parent::initContent(); // check ORDER RESTRICT condition before payment by the customer diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 054555062..a97a90577 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,13 +1318,12 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'success' => false + 'status' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); - $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1335,22 +1334,7 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { - $response['success'] = true; - if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { - if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } else { - $response['msg'] = 'Service already added.'; - } - } else { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } - } else { - $response['error'] = Tools::displayError('Service not Found'); - } + $response['status'] = true; } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index 902335903..a0187a2f0 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index 59dc5ab17..cee1fe886 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,9 +50,6 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index 5df9b7411..c96ff78ec 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,9 +49,6 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index 1d5e0f76b..e1415337d 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,9 +50,6 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index f280abd3f..6f75120a9 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,9 +48,6 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 6a16c420d..199d3a178 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,8 +182,6 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); - - $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index f9446f9f9..eafa043bb 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,20 +341,4 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } - - public static function validateServiceProductsInCart() - { - $context = Context::getContext(); - if ($cartProducts = $context->cart->getProducts()) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - foreach ($cartProducts as $product) { - if (!$product['active'] && !$product['booking_product']) { - $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); - foreach ($serviceProducts as $serviceProduct) { - $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); - } - } - } - } - } } \ No newline at end of file diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 08e3c1b8e..f700c7720 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,15 +20,9 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} - {foreach $product.images as $image} - {if $image['cover'] == 0} - - {/if} - {/foreach}
    @@ -42,7 +36,7 @@ {/if}
    - {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} @@ -52,21 +46,20 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} {/if} {/if} - + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if}
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 370f10de9..2b3565520 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 57a0add94..96ae9a806 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,15 +1201,6 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } - var added_service_product = []; - - $('#additional_products input.service_product').each(function () { - added_service_product.push({ - 'id_product': $(this).data('id_product'), - 'quantity':$(this).val(), - }); - }); - $.ajax({ type: 'POST', headers: { @@ -1224,36 +1215,31 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, - added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.success) { - if (result.add) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); - } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); + if (result.status) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - if (result.msg) { - showSuccessMessage(result.msg); - } + showSuccessMessage(cart_extra_service_add); BookingForm.refresh(); } else { if (result.error) { From 4ed261bdef388215cff95623623b21c6842c8b0b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 7 Mar 2023 19:17:15 +0530 Subject: [PATCH 22/63] Add module Dashboard Insights to admin dashboard --- controllers/admin/AdminStatsController.php | 202 +++++++++++++++ controllers/admin/AdminThemesController.php | 1 + install/models/install.php | 1 + modules/dashinsights/CHANGELOG.txt | 4 + modules/dashinsights/LICENSE.md | 223 +++++++++++++++++ modules/dashinsights/dashinsights.php | 232 ++++++++++++++++++ modules/dashinsights/index.php | 29 +++ .../dashinsights/views/css/dashinsights.css | 44 ++++ modules/dashinsights/views/css/index.php | 29 +++ modules/dashinsights/views/index.php | 29 +++ modules/dashinsights/views/js/dashinsights.js | 146 +++++++++++ modules/dashinsights/views/js/index.php | 29 +++ .../templates/hook/dashboard-zone-one.tpl | 40 +++ .../templates/hook/dashboard-zone-two.tpl | 49 ++++ .../views/templates/hook/index.php | 29 +++ .../dashinsights/views/templates/index.php | 29 +++ 16 files changed, 1116 insertions(+) create mode 100644 modules/dashinsights/CHANGELOG.txt create mode 100644 modules/dashinsights/LICENSE.md create mode 100644 modules/dashinsights/dashinsights.php create mode 100644 modules/dashinsights/index.php create mode 100644 modules/dashinsights/views/css/dashinsights.css create mode 100644 modules/dashinsights/views/css/index.php create mode 100644 modules/dashinsights/views/index.php create mode 100644 modules/dashinsights/views/js/dashinsights.js create mode 100644 modules/dashinsights/views/js/index.php create mode 100644 modules/dashinsights/views/templates/hook/dashboard-zone-one.tpl create mode 100644 modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl create mode 100644 modules/dashinsights/views/templates/hook/index.php create mode 100644 modules/dashinsights/views/templates/index.php diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 77bb9bcb5..93547e337 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1797,4 +1797,206 @@ class AdminStatsControllerCore extends AdminStatsTabController return $countGrossOpProfitPars ? $sumGrossOpProfitPars / $countGrossOpProfitPars : 0; } + + public static function getRoomNightsData($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + { + $dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo; + + $idsHotel = array(); + if (!$idHotel) { + $idsHotel = HotelBranchInformation::getProfileAccessedHotels( + Context::getContext()->employee->id_profile, + 1, + 1 + ); + } else { + $idsHotel[] = $idHotel; + } + + $result = array(); + foreach ($idsHotel as $idHotel) { + $result[$idHotel] = self::getOccupiedRoomsForDiscreteDates( + $dateFrom, + $dateTo, + $idHotel, + $useCache + ); + } + + return $result; + } + + /** + * $dow: day of week, 1 = SUN + */ + public static function getOccupiedRoomsForDayOfTheWeek($dow, $dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + { + $dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo; + + $result = 0; + $cacheKey = 'AdminStats::getOccupiedRoomsForDayOfTheWeek'.'_'.(int) $dow.(int) strtotime($dateFrom). + (int) strtotime($dateTo).(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel)); + if (!Cache::isStored($cacheKey) || !$useCache) { + // (los/7) + {if(los%7 has $dow) + 1 else + 0)} + // dow(start_of(remaining_days)) = dow_date_from && dow(end_of(remaining_days)) = dow_date_to + $sql = 'SELECT SUM((full_weeks + IF(('.(int) $dow.' >= dow_date_from AND '.(int) $dow.' < dow_date_to), 1, 0))) + AS total_occupied + FROM ( + SELECT hbd.`id`, hbd.`date_from`, hbd.`date_to`, DAYOFWEEK(hbd.`date_from`) AS dow_date_from, + DAYOFWEEK(hbd.`date_to`) AS dow_date_to, + DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los, + ROUND(DATEDIFF(hbd.`date_to`, hbd.`date_from`) / 7) AS full_weeks, + DATEDIFF(hbd.`date_to`, hbd.`date_from`) % 7 AS remaining_days + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`is_refunded` = 0 + AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').' + ) AS t'; + + $value = (int) Db::getInstance()->getValue($sql); + Cache::store($cacheKey, $value); + + $result = Cache::retrieve($cacheKey); + } + + return $result; + } + + public static function getOccupiedRoomsForDaysOfTheWeek($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + { + $dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo; + + $idsHotel = array(); + if (!$idHotel) { + $idsHotel = HotelBranchInformation::getProfileAccessedHotels( + Context::getContext()->employee->id_profile, + 1, + 1 + ); + } else { + $idsHotel[] = $idHotel; + } + + $result = array(); + foreach ($idsHotel as $idHotel) { + $result[$idHotel] = array(); + // 1 = SUN + for ($i = 1; $i <= 7; $i++) { + $result[$idHotel][$i] = self::getOccupiedRoomsForDayOfTheWeek( + $i, + $dateFrom, + $dateTo, + $idHotel, + $useCache + ); + } + } + + return $result; + } + + public static function getDaysOfTheWeekData($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + { + $dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo; + + $idsHotel = array(); + if (!$idHotel) { + $idsHotel = HotelBranchInformation::getProfileAccessedHotels( + Context::getContext()->employee->id_profile, + 1, + 1 + ); + } else { + $idsHotel[] = $idHotel; + } + + $result = array(); + foreach ($idsHotel as $idHotel) { + $result[$idHotel] = self::getOccupiedRoomsForDiscreteDates( + $dateFrom, + $dateTo, + $idHotel, + $useCache + ); + } + + return $result; + } + + public static function getLengthOfStayPercentage($losMinimum, $dateFrom, $dateTo, $idHotel = null, $useCache = true, $losMaximum = 0) + { + $result = 0; + $cacheKey = 'AdminStats::getLengthOfStayPercentage'.'_'.(int) $losMinimum.(int) $losMaximum. + (int) strtotime($dateFrom).(int) strtotime($dateTo).(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel)); + if (!Cache::isStored($cacheKey) || !$useCache) { + if ($dateFrom == $dateTo) { + $dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo))); + } + + $sql = 'SELECT COUNT(hbd.`id`) AS total + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'product` p + ON (p.`id_product` = hbd.`id_product`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); + + $total = Db::getInstance()->getValue($sql); + + $sql = 'SELECT COUNT(*) + FROM ( + SELECT DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'product` p + ON (p.`id_product` = hbd.`id_product`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').' + ) AS t + WHERE los >= '.(int) $losMinimum.' AND los <= '.(int) ($losMaximum ? $losMaximum : $losMinimum); + + $fraction = Db::getInstance()->getValue($sql); + + $value = (float) $total ? ($fraction / $total) : 0; + Cache::store($cacheKey, $value); + + $result = Cache::retrieve($cacheKey); + } + + return $result; + } + + public static function getLengthOfStayPercentages($days, $dateFrom, $dateTo, $idHotel = null, $useCache = true) + { + $idsHotel = array(); + if (!$idHotel) { + $idsHotel = HotelBranchInformation::getProfileAccessedHotels( + Context::getContext()->employee->id_profile, + 1, + 1 + ); + } else { + $idsHotel[] = $idHotel; + } + + $result = array(); + foreach ($idsHotel as $idHotel) { + $result[$idHotel] = array(); + foreach ($days as $key => $day) { + $result[$idHotel][$key] = self::getLengthOfStayPercentage( + $day[0], + $dateFrom, + $dateTo, + $idHotel, + $useCache, + $day[1] + ); + } + + } + + return $result; + } } diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 53c8b11c1..7dbd73476 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -2109,6 +2109,7 @@ class AdminThemesControllerCore extends AdminController 'dashgoals', 'dashproducts', 'dashtrends', + 'dashinsights', 'dateofdelivery', 'editorial', 'favoriteproducts', diff --git a/install/models/install.php b/install/models/install.php index 613fc0c6f..3e166f2ee 100644 --- a/install/models/install.php +++ b/install/models/install.php @@ -677,6 +677,7 @@ class InstallModelInstall extends InstallAbstractModel 'dashperformance', 'dashproducts', 'dashgoals', + 'dashinsights', 'graphnvd3', 'statsdata', 'statsvisits', diff --git a/modules/dashinsights/CHANGELOG.txt b/modules/dashinsights/CHANGELOG.txt new file mode 100644 index 000000000..4f29acabf --- /dev/null +++ b/modules/dashinsights/CHANGELOG.txt @@ -0,0 +1,4 @@ +Changelog + +v1.0.0 +- first release diff --git a/modules/dashinsights/LICENSE.md b/modules/dashinsights/LICENSE.md new file mode 100644 index 000000000..44b1b399c --- /dev/null +++ b/modules/dashinsights/LICENSE.md @@ -0,0 +1,223 @@ +SOFTWARE LICENCE AGREEMENT +=============================== + +This AGREEMENT is made effective on the date of the purchase of the software between Webkul Software Pvt. Ltd.,Company incorporated under the Companies Act, 1956 (hereinafter referred to as “Licensor"), and the purchaser of the software/ product (hereinafter referred to as "Licensee"). + +Preamble +================== +Licensor is a web and mobile product based organization engaged in the business of developing and marketing software for enterprise level e-commerce businesses. It is an ISO and NSR (NASSCOM) certified organization having a team of more than 150 creative engineers which come from different backgrounds. It has developed more than 700 web extensions and apps in the past few years for open source platforms which are used and trusted globally. Licensee now wishes to obtain license, and Licensor wishes to grant a license, to allow use of the software so purchased in developing the e-commerce business website/ mobile app of the Licensee, subject to the terms and conditions set forth herein. + + +THEREFORE, with the intent to be legally bound, the parties hereby agree as follows: + + +Agreement +================ + +1.Definitions : +------------------ +As used in this Agreement, the following capitalized terms shall have the definitions set forth below: + + +"Derivative Works" are works developed by Licensee, its officers, agents, contractors or employees, which are based upon, in whole or in part, the Source Code and/or the Documentation and may also be based upon and/or incorporate one or more other preexisting works of the Licensor. Derivative Works may be any improvement, revision, modification, translation (including compilation or recapitulation by computer), abridgment, condensation, expansion, or any other form in which such a preexisting work may be recast, transformed, or adapted. For purposes hereof, a Derivative Work shall also include any compilation that incorporates such a preexisting work. + + +"Documentation" is written, printed or otherwise recorded or stored (digital or paper) material relating to the Software and/or Source Code, including technical specifications and instructions for its use including Software/ Source Code annotations and other descriptions of the principles of its operation and instructions for its use. + + +"Improvements" shall mean, with respect to the Software, all modifications and changes made, developed, acquired or conceived after the date hereof and during the entire term of this Agreement. + + +"Source Code" is the computer programming source code form of the Software in the form maintained by the Licensor, and includes all non-third-party executables, libraries, components, and Documentation created or used in the creation, development, maintenance, and support of the Software as well as all updates, error corrections and revisions thereto provided by Licensor, in whole or in part. + + +2. Software License. +------------------------- + +(a)Grant of License. For the consideration set forth below, Licensor hereby grants to Licensee, and Licensee hereby accepts the worldwide, non-exclusive, perpetual, royalty-free rights and licenses set forth below: + + +(i)The right and license to use and incorporate the software, in whole or in part, to develop its website/ mobile app (including the integration of all or part of the Licensor’s software into Licensee's own software) on one domain ( Except Joomla modules , listed on store are entitled to be used on unlimited domain as per the standard guidelines ) only, solely for the own personal or business use of the Licensee. However, the License does not authorize the Licensee to compile, copy or distribute the said Software or its Derivative Works. + + +(ii)The right and license does not authorize the Licensee to make any backup or archival copies of the Software and / or the Source Code and Documentation. + +(iii)The right and license does not authorize the Licensee to migrate the domain license to another domain. + + +(b)Scope; Rights and Responsibilities. + + +(i)Licensor shall enable the Licensee to download one complete copy of the Software. + + +(ii)The Software is intended for the sole use of the Licensee in development of its own website/ mobile app. + + +(iii)Licensee does not have the right to hand over, sell, distribute, sub-license, rent, lease or lend any portion of the Software or Documentation, whether modified or unmodified, to anyone. Licensee should not place the Software on a server so that it becomes accessible via a public network such as the Internet for distribution purposes. In case the Licensee is using any source code management system like github, it can use the code there only when it has paid subscription from such management system. + + +(iv)Licensee is not authorized to appoint, or work with, third parties to perform any development services using the Source Code, the source code to Derivative Works and/or the Documentation on behalf of, or working with, the Licensee. Release of Source Code, Derivative Work source code and/or Documentation to any third party shall be considered as violation of the Agreement, inter-alia entailing forthwith termination and legal action. + + + +(c)Ownership. + + +(i)Software and Source Code. All right, title, copyright, and interest in the Software, Source Code, Software Modifications and Error corrections will be and remain the property of Licensor. + + +(ii)Derivative Works. As creation of Derivative Works by the Licensee is prohibited, thus, all right, title, copyright, and interest in any and/or all Derivative Works and Improvements created by, or on behalf of, Licensee will also be deemed to the property of Licensor. Licensor shall be entitled to protect copyright / intellectual property in all such Derivative Works and Improvements also in any country as it may deem fit including without limitation seeking copyright and/or patent protection. + + +3.Consideration. +-------------------- + +(a)Licensee shall pay to Licensor the amount as mentioned on the website from where the order is placed, as one-time, upfront fees in consideration for the licenses and rights granted hereunder (hereinafter referred to as the "License Fee"). The License Fee to be paid by Licensee shall be paid upfront at the time of placing the order, and no credit will be allowed under any circumstances. + + +(b)Once paid, the License Fees shall be non-refundable. The Licensee has fully satisfied itself about the Software and has seen the demonstration, and only thereafter has placed the order. Thus, the License Fees or any part thereof is non-refundable. No claim for refund of the Licence Fees shall be entertained under any circumstances. + + + +4.Representations and Warranties. +------------------------------------- + +(a)Mutual. Each of the parties represents and warrants to the other as follows. + + +(i)such party is a legal entity duly organized, validly existing and in good standing; + + +(ii)such party has the power and authority to conduct its business as presently conducted and to enter into, execute, deliver and perform this Agreement. + + +(iii)This Agreement has been duly and validly accepted by such party and constitutes the legal, valid and binding obligations of such party respectively, enforceable against such party in accordance with their respective terms; + + +(iv)the acceptance, execution, delivery and performance of this Agreement does not and will not violate such party's charter or by-laws; nor require any consent, authorization, approval, exemption or other action by any third party or governmental entity. + + +(b)Licensor warrants that, at the time of purchase of the Software: + + +the Software will function materially as set forth in the website or published functionality provided by Licensor to customers and potential customers describing the Software; and + + +Software add-ons, if purchased by the Licensee from the Licensor, will not materially diminish the features or functions of or the specifications of the Software as they existed as of the execution of this Agreement. + + + +(c)Title. Licensor represents and warrants that it is the exclusive owner of all copyright/ intellectual property in the Software (including the Source Code) and has good and marketable title to the Software (including the Source Code) free and clear of all liens, claims and encumbrances of any nature whatsoever (collectively, "Liens"). Licensor's grant of license and rights to Licensee hereunder does not, and will not infringe any third party's property, intellectual property or personal rights. + + + +5.Term. +------------- + +(a)Subject to Licensee's payment obligations, this Agreement shall commence as on the date of making payment of the Software by the Licensee to the Licensor, and shall continue until terminated by either party. + + +(b)The Licensor retains the right to terminate the license at any time, if the Licensee is not abiding by any of the terms of the Agreement. The Licensee may terminate the Agreement at any time at its own discretion by uninstalling the Software and /or by destroying the said Software (or any copies thereof). However, the Licensee shall not be entitled to seek any refund of the amount paid by it to the Licensor, under any circumstances. + + +(c)Survival. In the event this Agreement is terminated for any reason, the provisions set forth in Sections 2(a), 2(b), and 2(c) shall survive. + + + + +6. Indemnification +---------------------- + +The Licensee release the Licensor from, and agree to indemnify, defend and hold harmless the Licensor (and its officers, directors, employees, agents and Affiliates) against, any claim, loss, damage, settlement, cost, taxes, expense or other liability (including, without limitation, attorneys' fees) (each, a "Claim") arising from or related to: (a) any actual or alleged breach of any obligations in this Agreement; (b) any refund, adjustment, or return of Software,(c) any claim for actual or alleged infringement of any Intellectual Property Rights made by any third party or damages related thereto; or (d) Taxes. + + +7. Limitation of Liability +------------------------------ + +The Licensor will not be liable for any direct, indirect, incidental, special, consequential or exemplary damages, including but not limited to, damages for loss of profits, goodwill, use, data or other intangible losses arising out of or in connection with the Software, whether in contract, warranty, tort etc. (including negligence, software liability, any type of civil responsibility or other theory or otherwise) to the Licensee or any other person for cost of software, cover, recovery or recoupment of any investment made by the Licensee or its affiliates in connection with this Agreement, or for any other loss of profit, revenue, business, or data or punitive or consequential damages arising out of or relating to this Agreement. Further, the aggregate liability of the Licensor, arising out of or in connection with this Agreement or the transactions contemplated hereby will not exceed at any time, or under any circumstances, the total amounts received by the Licensor from the Licensee in connection with the particular software giving rise to the claim. + + +8. Force Majeure +--------------------- + +The Licensor will not be liable for any delay or failure to perform any of its obligations under this Agreement by reasons, events or other matters beyond its reasonable control. + + +9. Relationship of Parties +------------------------------ + +The Licensor and Licensee are independent legal entities, and nothing in this Agreement will be construed to create a partnership, joint venture, association of persons, agency, franchise, sales representative, or employment relationship between the parties. The Licensee will have no authority to make or accept any offers or representations on behalf of the Licensor. The relationship between the parties is that of Licensor and Licensee only, and the rights, duties, liabilities of each party shall be governed by this Agreement. + + +10. Modification +------------------------ + +The Licensor may amend any of the terms and conditions contained in this Agreement at any time and solely at its discretion. Any changes will be effective upon the posting of such changes on the Portal/ website, and the Licensee is responsible for reviewing these changes and informing itself of all applicable changes or notices. The continued use of a software by the Licensee after posting of any changes by the Licensor, will constitute the acceptance of such changes or modifications by the Licensee. + + + +11.Miscellaneous. +----------------------- + +(a)General Provisions. This Agreement: (i) may be amended only by a writing signed by each of the parties; (ii) may be executed in several counterparts, each of which shall be deemed an original but all of which shall constitute one and the same instrument; (iii) contains the entire agreement of the parties with respect to the transactions contemplated hereby and supersedes all prior written and oral agreements, and all contemporaneous oral agreements, relating to such transactions; (iv) shall be governed by, and construed and enforced in accordance with, the laws of India; and (v) shall be binding upon, and inure to the benefit of, the parties and their respective successors and permitted assigns. Each of the parties hereby irrevocably submits to the jurisdiction of the Courts at Delhi, India, for the purposes of any action or proceeding arising out of or relating to this Agreement or the subject matter hereof and brought by any other party. + + +(b)Assignment. Licensee cannot assign, pledge or otherwise transfer, whether by operation of law or otherwise, this Agreement, or any of its obligations hereunder, without the prior written consent of Licensor, which consent shall not be unreasonably withheld. + + +(c)Notices. Unless otherwise specifically provided herein, all notices, consents, requests, demands and other communications required or permitted hereunder: + + +(i)shall be in writing; + + +(ii)shall be sent by messenger, certified or registered mail/email, or reliable express delivery service, to the appropriate address(es) set forth below; and + + +(iii)shall be deemed to have been given on the date of receipt by the addressee, as evidenced by a receipt executed by the addressee (or a responsible person in his or her office), the records of the Party delivering such communication or a notice to the effect that such addressee refused to claim or accept such communication, if sent by messenger, mail or express delivery service. + + +All such communications shall be sent to the following addresses or numbers, or to such other addresses or numbers as any party may inform the others by giving five days' prior notice: + + +If to Webkul Software Pvt. Ltd.: + + + +Webkul Software Pvt. Ltd. + +H-28, ARV Park, Sector 63, NOIDA – 201301, + +Uttar Pradesh, India + + +If to Licensee: + +At the address mentioned by the Licensee + +(at the time of placing order of generating Invoice) + + +(d)Severability. It is the intent of the parties that the provisions of this Agreement be enforced to the fullest extent permissible under the laws and public policies of India in which enforcement hereof is sought. In furtherance of the foregoing, each provision hereof shall be severable from each other provision, and any provision hereof which is/ becomes unenforceable shall be subject to the following: (i) if such provision is contrary to or conflicts with any requirement of any statute, rule or regulation in effect, then such requirement shall be incorporated into, or substituted for, such unenforceable provision to the minimum extent necessary to make such provision enforceable; (ii) the court, agency or arbitrator considering the matter is hereby authorized to (or, if such court, agency or arbitrator is unwilling or fails to do so, then the parties shall) amend such provision to the minimum extent necessary to make such provision enforceable, and the parties hereby consent to the entry of an order so amending such provision; and (iii) if any such provision cannot be or is not reformed and made enforceable pursuant to clause (i) or (ii) above, then such provision shall be ineffective to the minimum extent necessary to make the remainder of this Agreement enforceable. Any application of the foregoing provisions to any provision hereof shall not effect the validity or enforceability of any other provision hereof. + + +(e)By purchasing the Software, the Licensee acknowledge that it has read this Agreement, and that it agrees to the content of the Agreement, its terms and agree to use the Software in compliance with this Agreement. + + +(f)The Licensor holds the sole copyright of the Software. The Software or any portion thereof is a copyrightable matter and is liable to be protected by the applicable laws. Copyright infringement in any manner can lead to prosecution according to the current law. The Licensor reserves the right to revoke the license of any user who is not holding any license or is holding an invalid license. + + +(g)This Agreement gives the right to use only one copy of the Software on one domain solely for the own personal or business use of the Licensee, subject to all the terms and conditions of this Agreement. A separate License has to be purchased for each new Software installation. Any distribution of the Software without the written consent of the Licensor (including non-commercial distribution) is regarded as violation of this Agreement, and will entail immediate termination of the Agreement and may invite liability, both civil and criminal, as per applicable laws. + + +(h)The Licensor reserves the rights to publish a selected list of users/ Licensees of its Software, and no permission of any Licensee is needed in this regard. The Licensee agrees that the Licensor may, in its sole discretion, disclose or make available any information provided or submitted by the Licensee or related to it under this Agreement to any judicial, quasi-judicial, governmental, regulatory or any other authority as may be required by the Licensor to co-operate and / or comply with any of their orders, instructions or directions or to fulfill any requirements under applicable Laws. + + +(i)If the Licensee continues to use the Software even after the sending of the notice by the Licensor for termination, the Licensee agree to accept an injunction to restrain itself from its further use, and to pay all costs (including but not limited to reasonable attorney fees) to enforce injunction or to revoke the License, and any damages suffered by the Licensor because of the misuse of the Software by the Licensee. + + +12. Arbitration +----------------------- + +If any dispute arises between the Licensor and the Licensee at any time, in connection with the validity, interpretation, implementation or alleged breach of any provision of this Agreement, the same shall be referred to a sole Arbitrator who shall be an independent and neutral third party appointed exclusively by the Licensor. The Licensee shall not object to the appointment of the Arbitrator so appointed by the Licensor. The place of arbitration shall be Delhi, India. The Arbitration & Conciliation Act, 1996 as amended by The Arbitration & Conciliation (Amendment) Act, 2015, shall govern the arbitration proceedings. The arbitration proceedings shall be held in the English language. diff --git a/modules/dashinsights/dashinsights.php b/modules/dashinsights/dashinsights.php new file mode 100644 index 000000000..79ddfd87a --- /dev/null +++ b/modules/dashinsights/dashinsights.php @@ -0,0 +1,232 @@ +name = 'dashinsights'; + $this->tab = 'dashboard'; + $this->version = '1.0.0'; + $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.6'); + $this->author = 'Webkul'; + $this->bootstrap = true; + parent::__construct(); + $this->displayName = $this->l('Dashboard Booking Insights'); + $this->description = $this->l('Adds a block with a graphical representation of booking insights.'); + $this->confirmUnsinstall = $this->l('Are you sure you want to uninstall?'); + + $this->allow_push = true; + } + + public function install() + { + return (parent::install() + && $this->registerHook('dashboardZoneOne') + && $this->registerHook('dashboardZoneTwo') + && $this->registerHook('dashboardData') + && $this->registerHook('actionAdminControllerSetMedia') + ); + } + + public function hookActionAdminControllerSetMedia() + { + if (Tools::getValue('controller') == 'AdminDashboard') { + $this->context->controller->addCSS($this->_path.'views/css/'.$this->name.'.css'); + $this->context->controller->addJS($this->_path.'views/js/'.$this->name.'.js'); + } + } + + public function hookDashboardZoneOne() + { + return $this->display(__FILE__, 'dashboard-zone-one.tpl'); + } + + public function hookDashboardZoneTwo() + { + return $this->display(__FILE__, 'dashboard-zone-two.tpl'); + } + + public function hookDashboardData($params) + { + $dateFrom = $params['date_from']; + $dateTo = $params['date_to']; + $idHotel = $params['id_hotel']; + + $idsHotel = array(); + if (!$idHotel) { + $idsHotel = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1); + } else { + $idsHotel[] = $idHotel; + } + + $hotelWiseRoomNights = array(); + $hotelWiseDaysOfTheWeek = array(); + $hotelWiseLengthOfStay = array(); + if (Configuration::get('PS_DASHBOARD_SIMULATION')) { + if ($dateFrom == $dateTo) { + $dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo))); + } + + // prepare dates + $discreteDates = array(); + $dateTemp = $dateFrom; + while ($dateTemp <= $dateTo) { + $dateNext = date('Y-m-d', strtotime('+1 day', strtotime($dateTemp))); + $discreteDates[] = array( + 'timestamp_from' => strtotime($dateTemp), + ); + $dateTemp = $dateNext; + }; + + // set room nights demo data + foreach ($idsHotel as $idHotel) { + foreach ($discreteDates as $discreteDate) { + $hotelWiseRoomNights[$idHotel][$discreteDate['timestamp_from']] = round(rand(0, 100)); + } + } + + // set days of the week demo data + foreach ($idsHotel as $idHotel) { + for ($i = 1; $i <= 7; $i++) { + $hotelWiseDaysOfTheWeek[$idHotel][$i] = round(rand(0, 100)); + } + } + + // set length of stay demo data + foreach ($idsHotel as $idHotel) { + for ($i = 1; $i <= 7; $i++) { + $hotelWiseLengthOfStay[$idHotel][$i] = round(rand(0, 15)); + } + } + } else { + $hotelWiseRoomNights = AdminStatsController::getRoomNightsData($dateFrom, $dateTo, $idHotel); + $hotelWiseDaysOfTheWeek = AdminStatsController::getOccupiedRoomsForDaysOfTheWeek($dateFrom, $dateTo, $idHotel); + + $days = array( + 1 => array(1, 1), + 2 => array(2, 2), + 3 => array(3, 3), + 4 => array(4, 4), + 5 => array(5, 5), + 6 => array(6, 6), + 7 => array(7, 100), + ); + + $hotelWiseLengthOfStay = AdminStatsController::getLengthOfStayPercentages($days, $dateFrom, $dateTo, $idHotel); + } + + // format room nights data + $roomNightsFormattedData = array(); + foreach ($hotelWiseRoomNights as $idHotel => &$hotelRoomNights) { + $hotelData = array(); + foreach ($hotelRoomNights as $timestamp => $hotelRoomNight) { + $hotelData[] = array($timestamp, $hotelRoomNight); + } + + $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); + $roomNightsFormattedData[] = array( + 'key' => $objHotelBranchInformation->hotel_name, + 'values' => $hotelData, + ); + } + + // format days of the week data + $daysOfTheWeekFormattedData = array(); + $weekDays = array( + $this->l('SUN'), + $this->l('MON'), + $this->l('TUE'), + $this->l('WED'), + $this->l('THU'), + $this->l('FRI'), + $this->l('SAT'), + ); + foreach ($hotelWiseDaysOfTheWeek as $idHotel => &$hotelDaysOfTheWeek) { + $hotelData = array(); + foreach ($hotelDaysOfTheWeek as $dayOfWeek => $hotelDayOfTheWeek) { + $hotelData[] = array( + 'x' => $weekDays[$dayOfWeek - 1], + 'y' => $hotelDayOfTheWeek, + ); + } + + $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); + $daysOfTheWeekFormattedData[] = array( + 'key' => $objHotelBranchInformation->hotel_name, + 'values' => $hotelData, + ); + } + + // format length of stay data + $lengthOfStayFormattedData = array(); + $losInfos = array( + array('days' => 1, 'label' => $this->l('1')), + array('days' => 2, 'label' => $this->l('2')), + array('days' => 3, 'label' => $this->l('3')), + array('days' => 4, 'label' => $this->l('4')), + array('days' => 5, 'label' => $this->l('5')), + array('days' => 6, 'label' => $this->l('6')), + array('days' => 7, 'label' => $this->l('7+')), + ); + foreach ($hotelWiseLengthOfStay as $idHotel => &$hotelLengthOfStay) { + $hotelData = array(); + foreach ($hotelLengthOfStay as $numDays => $hotelLengthOfStay) { + $hotelData[] = array( + 'x' => $losInfos[$numDays - 1]['label'], + 'y' => $hotelLengthOfStay, + ); + } + + $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); + $lengthOfStayFormattedData[] = array( + 'key' => $objHotelBranchInformation->hotel_name, + 'values' => $hotelData, + ); + } + + $return = array( + 'data_chart' => array( + 'dashinsights_line_chart1' => array( + 'chart_type' => 'line_chart_dashinsights', + 'data' => $roomNightsFormattedData, + 'date_format' => $this->context->language->date_format_lite, + ), + 'dashinsights_multibar_chart1' => array( + 'chart_type' => 'multibar_chart_dotw_dashinsights', + 'data' => $daysOfTheWeekFormattedData, + 'date_format' => $this->context->language->date_format_lite, + ), + 'dashinsights_multibar_chart2' => array( + 'chart_type' => 'multibar_chart_los_dashinsights', + 'data' => $lengthOfStayFormattedData, + 'date_format' => $this->context->language->date_format_lite, + 'axis_labels' => array('x' => $this->l('Days')), + ), + ), + ); + + return $return; + } +} diff --git a/modules/dashinsights/index.php b/modules/dashinsights/index.php new file mode 100644 index 000000000..1ad696d30 --- /dev/null +++ b/modules/dashinsights/index.php @@ -0,0 +1,29 @@ + +
    +
    + {l s="Insights" mod="dashinsights"} + + + + + +
    + +
    +
    +

    {l s='Length of Stay'}

    +
    + +
    +
    +
    +
    + diff --git a/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl b/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl new file mode 100644 index 000000000..343089e5c --- /dev/null +++ b/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl @@ -0,0 +1,49 @@ +{** +* 2010-2023 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through LICENSE.txt file inside our module +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to CustomizationPolicy.txt file inside our module for more information. +* +* @author Webkul IN +* @copyright 2010-2023 Webkul IN +* @license LICENSE.txt +*} + +
    +
    +
    + {l s='Insights' mod='dashinsights'} + + + + + +
    + +
    +
    +
    +

    {l s='Room Nights'}

    +
    + +
    +
    +
    +

    {l s='Days of the Week'}

    +
    + +
    +
    +
    +
    +
    +
    +
    diff --git a/modules/dashinsights/views/templates/hook/index.php b/modules/dashinsights/views/templates/hook/index.php new file mode 100644 index 000000000..1ad696d30 --- /dev/null +++ b/modules/dashinsights/views/templates/hook/index.php @@ -0,0 +1,29 @@ + Date: Thu, 9 Mar 2023 15:30:05 +0530 Subject: [PATCH 23/63] added services popup in admin booking carts page --- .../controllers/carts/helpers/view/view.tpl | 163 +++++++++-- .../orders/_cart_booking_demands.tpl | 91 +++--- classes/Cart.php | 8 +- classes/Customer.php | 2 +- controllers/admin/AdminCartsController.php | 51 ++-- controllers/front/OrderOpcController.php | 38 +-- .../classes/HotelCartBookingData.php | 22 +- .../RoomTypeServiceProductCartDetail.php | 266 +++++++++++++++--- .../_partials/cart_booking_demands.tpl | 6 +- 9 files changed, 459 insertions(+), 188 deletions(-) diff --git a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl index 2962f9e3e..7b8f5d90e 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -98,36 +98,141 @@ {foreach from=$cart_htl_data item='room'} - - - - - {$room.room_type} + + + + + {$room['room_type']} + + + {$room['room_type_info'].hotel_name} + {dateFormat date=$room['date_from']} - {dateFormat date=$room['date_to']} + + + {if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} + + + {displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency} + + {if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])} + + {displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency} - - {$room.room_type_info.hotel_name} - {dateFormat date=$room.date_from} - {dateFormat date=$room.date_to} - - - {if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} - - - {displayWtPriceWithCurrency price=$room.feature_price_tax_excl currency=$currency} - - {if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)} - {displayWtPriceWithCurrency price=($room.demand_price + $room.additional_service_price + $room.additional_services_auto_add_price)|escape:'html':'UTF-8' currency=$currency} - {else} - {displayWtPriceWithCurrency price=0 currency=$currency} - {/if} - - - {if (isset($room.extra_demands) && $room.extra_demands) || (isset($room.additional_service) && $room.additional_service)} - {displayWtPriceWithCurrency price=($room.amt_with_qty + $room.additional_services_auto_add_price + $room.demand_price + $room.additional_service_price)|escape:'html':'UTF-8' currency=$currency} - {else} - {displayWtPriceWithCurrency price=$room.amt_with_qty|escape:'html':'UTF-8' currency=$currency} - {/if} - - + {else} + {displayWtPriceWithCurrency price=0 currency=$currency} + {/if} + + + {if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])} + {displayWtPriceWithCurrency price=($room['amt_with_qty'] + $room['additional_services_auto_add_price'] + $room['demand_price'] + $room['additional_service_price'])|escape:'html':'UTF-8' currency=$currency} + {else} + {displayWtPriceWithCurrency price=$room['amt_with_qty']|escape:'html':'UTF-8' currency=$currency} + {/if} + + + {/foreach} diff --git a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl index 240b54e55..51dab43c8 100644 --- a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl +++ b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl @@ -103,57 +103,54 @@
    {assign var=roomCount value=1} - {foreach $selectedRoomServiceProduct as $cartRoom} -
    -
    - - - {if isset($cartRoom['room_num']) && $cartRoom['room_num']} - {l s='Room'} {$cartRoom['room_num']|escape:'html':'UTF-8'} - {else} - {l s='Room'} {$roomCount|escape:'html':'UTF-8'} - {/if} - -
    -
    - {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {foreach $roomTypeServiceProducts as $product} -
    -
    -
    -
    - -
    -
    -

    {$product['name']|escape:'html':'UTF-8'}

    - {if $product.allow_multiple_quantity} -
    - -
    - {/if} -
    +
    +
    + + + {if isset($selectedRoomServiceProduct['room_num']) && $selectedRoomServiceProduct['room_num']} + {l s='Room'} {$selectedRoomServiceProduct['room_num']|escape:'html':'UTF-8'} + {else} + {l s='Room'} {$roomCount|escape:'html':'UTF-8'} + {/if} + +
    +
    + {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} + {foreach $roomTypeServiceProducts as $product} +
    +
    +
    +
    + +
    +
    +

    {$product['name']|escape:'html':'UTF-8'}

    + {if $product.allow_multiple_quantity} +
    + +
    + {/if}
    -
    - {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} - {l s='Convenience fee'} - {/if} - {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} - {l s='Auto added'} - {/if} -
    -
    - {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} - {convertPrice price=$product.price_tax_exc} - {/if} -
    - {/foreach} - {/if} -
    +
    + {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} + {l s='Convenience fee'} + {/if} + {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} + {l s='Auto added'} + {/if} +
    +
    + {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {convertPrice price=$product.price_tax_exc} + {/if} +
    +
    + {/foreach} + {/if}
    - {assign var=roomCount value=1} - {/foreach} +
    {/if} diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..b80b8fbaf 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -792,8 +792,9 @@ class CartCore extends ObjectModel } } else if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $row['service_product_type']) { $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - $totalPriceByProductTaxIncl = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, 1, true, null); - $totalPriceByProductTaxExcl = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, 1, false, null); + $totalPriceByProductTaxIncl = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, true, null); + $totalPriceByProductTaxExcl = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart($this->id, (int)$row['id_product'], 0, 0, 0, 0, 0, false, null); + switch (Configuration::get('PS_ROUND_TYPE')) { case Order::ROUND_TOTAL: @@ -1795,7 +1796,7 @@ class CartCore extends ObjectModel } else if (!$product['booking_product'] && Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) { $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - $totalPriceByProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( + $totalPriceByProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart( $this->id, (int)$product['id_product'], isset($product['id_hotel']) ? $product['id_hotel'] : 0, @@ -1803,7 +1804,6 @@ class CartCore extends ObjectModel 0, 0, 0, - 1, $with_taxes, null ); diff --git a/classes/Customer.php b/classes/Customer.php index 519b96b23..663f28bbc 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -585,7 +585,7 @@ class CustomerCore extends ObjectModel WHERE c.`id_customer` = '.(int)$this->id); $result['last_visit'] = $result2['last_visit']; - $result['age'] = ($result3['age'] != date('Y') ? $result3['age'] : '--'); + $result['age'] = isset($result3['age']) && ($result3['age'] != date('Y') ? $result3['age'] : '--'); return $result; } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index d4c0d592d..c08254aa4 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -295,7 +295,6 @@ class AdminCartsControllerCore extends AdminController } } //end - ddd($cartHtlData); $this->tpl_view_vars = array( 'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data 'kpi' => $kpi, @@ -1054,6 +1053,27 @@ class AdminCartsControllerCore extends AdminController $this->context->smarty->assign('selectedRoomDemands', $selectedRoomDemands); } } + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + $roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); + if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( + $idCart, + $idProduct, + $dateFrom, + $dateTo, + $idRoom + )) { + $selectedRoomServiceProduct['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts( + $selectedRoomServiceProduct['id'], + 0, + null, + null + ); + } + $this->context->smarty->assign(array( + 'roomTypeServiceProducts' => $roomTypeServiceProducts, + 'selectedRoomServiceProduct' => $selectedRoomServiceProduct + )); $htlCartBoookingata = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( $idCart, $idProduct, @@ -1061,35 +1081,6 @@ class AdminCartsControllerCore extends AdminController $dateTo, $idRoom ); - - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - if ($selectedRoomServiceProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( - $idCart, - 0, - 0, - $idProduct, - $dateFrom, - $dateTo, - $htlCartBoookingata['id'], - 0, - null, - null - )) { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); - foreach ($selectedRoomServiceProduct as $key => $selectedProducts) { - $objRoom = new HotelRoomInformation($selectedProducts['id_room']); - $selectedRoomServiceProduct[$key]['room_num'] = $objRoom->room_num; - foreach ($selectedProducts['selected_products_info'] as $product) { - $selectedRoomServiceProduct[$key]['selected_products'][] = $product['id_product']; - } - } - - $this->context->smarty->assign(array( - 'roomTypeServiceProducts' => $roomTypeServiceProducts, - 'selectedRoomServiceProduct' => $selectedRoomServiceProduct - )); - } } } $response['status'] = true; diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f5a5bec2b..3e9fa4a73 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -985,31 +985,21 @@ class OrderOpcControllerCore extends ParentOrderController } } $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - if ($selectedRoomServiceProduct = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( - $this->context->cart->id, - 0, - 0, - $idProduct, - $dateFrom, - $dateTo, - 0, - 0, - null, - null - )) { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, true, 1); - foreach ($selectedRoomServiceProduct as $key => $selectedProducts) { - foreach ($selectedProducts['selected_products_info'] as $product) { - $selectedRoomServiceProduct[$key]['selected_products'][] = $product['id_product']; - } - } - $this->context->smarty->assign(array( - 'roomTypeServiceProducts' => $roomTypeServiceProducts, - 'selectedRoomServiceProduct' => $selectedRoomServiceProduct - )); + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + $roomTypeServiceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, true, 1); + $cartRooms = $objCartBookingData->getHotelCartRoomsInfoByRoomType($this->context->cart->id, $idProduct,$dateFrom, $dateTo); + foreach($cartRooms as &$room) { + $room['selected_service'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts( + $room['id'], + 0, + null, + null + ); } - + $this->context->smarty->assign(array( + 'roomTypeServiceProducts' => $roomTypeServiceProducts, + 'cartRooms' => $cartRooms + )); } } $response['extra_demands'] = $this->context->smarty->fetch( diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index e5806d008..b49665deb 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -968,16 +968,13 @@ class HotelCartBookingData extends ObjectModel ); $cart_detail_data[$key]['additional_service'] = $objRoomTypeServiceProduct->getServiceProductsData($value['id_product']); - $cart_detail_data[$key]['selected_additional_service'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( - $id_cart, + $cart_detail_data[$key]['selected_services'] = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts( + $value['id'], 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id'] + null, + null ); - $cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( + $cart_detail_data[$key]['additional_service_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart( $id_cart, 0, 0, @@ -985,10 +982,9 @@ class HotelCartBookingData extends ObjectModel $value['date_from'], $value['date_to'], $value['id'], - true, false ); - $cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( + $cart_detail_data[$key]['additional_services_auto_add_price'] = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart( $id_cart, 0, 0, @@ -996,7 +992,6 @@ class HotelCartBookingData extends ObjectModel $value['date_from'], $value['date_to'], $value['id'], - true, false, 1 ); @@ -1304,15 +1299,14 @@ class HotelCartBookingData extends ObjectModel $data_v['date_to'], 1 ); - $serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart( + $serviceProductPrice = $objRoomTypeServiceProductCartDetail->getServiceProductsTotalInCart( $context->cart->id, 0, $data_v['id_hotel'], $data_v['id_product'], $data_v['date_from'], $data_v['date_to'], - $data_v['id'], - true + $data_v['id'] ); $totalAdditionalServicePrice = $demandPrice + $serviceProductPrice; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..d3b3a4a8e 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -90,6 +90,189 @@ class RoomTypeServiceProductCartDetail extends ObjectModel return true; } + public function getServiceProductsTotalInCart( + $idCart, + $idProduct = 0, + $idHotel = 0, + $roomTypeIdProduct = 0, + $dateFrom = 0, + $dateTo = 0, + $htlCartBookingId = 0, + $useTax = null, + $autoAddToCart = 0, + $id_address = null, + $priceAdditionType = null + ) { + if ($useTax === null) + $useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true; + + $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_product` as `room_type_id_product` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd + LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`) + WHERE 1'; + + if (!is_null($autoAddToCart)) { + $sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart; + if ($autoAddToCart == 1 && !is_null($priceAdditionType)) { + $sql .= ' AND p.`price_addition_type` = '.$priceAdditionType; + } + } + if ($idCart) { + $sql .= ' AND cbd.`id_cart`='.(int) $idCart; + } + if ($idProduct) { + $sql .= ' AND rscd.`id_product`='.(int) $idProduct; + } + if ($idHotel) { + $sql .= ' AND cbd.`id_hotel`='.(int) $idHotel; + } + if ($roomTypeIdProduct) { + $sql .= ' AND cbd.`id_product`='.(int) $roomTypeIdProduct; + } + if ($dateFrom && $dateTo) { + $sql .= ' AND cbd.`date_from` = \''.pSQL($dateFrom).'\' AND cbd.`date_to` = \''.pSQL($dateTo).'\''; + } + if ($htlCartBookingId) { + $sql .= ' AND cbd.`id`='.(int) $htlCartBookingId; + } + $sql .= ' ORDER BY cbd.`id`'; + $totalPrice = 0; + + $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); + if ($serviceProducts = Db::getInstance()->executeS($sql)) { + foreach ($serviceProducts as $product) { + $qty = $product['quantity'] ? (int)$product['quantity'] : 1; + $totalPrice += $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + $useTax, + false, + $id_address + ); + } + } + return $totalPrice; + } + + public function getRoomServiceProducts( + $htlCartBookingId, + $idLang = 0, + $useTax = null, + $autoAddToCart = 0, + $id_address = null, + $priceAdditionType = null + ) { + if ($useTax === null) + $useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true; + + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, p.`auto_add_to_cart`, p.`allow_multiple_quantity`, cbd.`id` as `htl_cart_booking_id`, + p.`price_addition_type`, cbd.`id_product` as `room_type_id_product`, pl.`name` + FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd + LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.') + WHERE 1'; + + if (!is_null($autoAddToCart)) { + $sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart; + if ($autoAddToCart == 1 && !is_null($priceAdditionType)) { + $sql .= ' AND p.`price_addition_type` = '.$priceAdditionType; + } + } + if ($htlCartBookingId) { + $sql .= ' AND cbd.`id`='.(int) $htlCartBookingId; + } + $sql .= ' ORDER BY cbd.`id`'; + + $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); + $selectedServiceProducts = array(); + + if ($serviceProducts = Db::getInstance()->executeS($sql)) { + foreach ($serviceProducts as $product) { + $qty = $product['quantity'] ? (int)$product['quantity'] : 1; + if (isset($selectedServiceProducts[$product['id_product']])) { + $selectedServiceProducts[$product['id_product']]['quantity'] += $product['quantity']; + $selectedServiceProducts[$product['id_product']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + $useTax, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + false, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + true, + false, + $id_address + ); + } else { + $selectedServiceProducts[$product['id_product']] = $product; + + $selectedServiceProducts[$product['id_product']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + false, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + true, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + $useTax, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + false, + false, + $id_address + ); + $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + $qty, + true, + false, + $id_address + ); + } + } + + } + + return $selectedServiceProducts; + } + public function getServiceProductsInCart( $idCart, $idProduct = 0, @@ -168,18 +351,31 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['room_type_id_product']); $qty = $product['quantity'] ? (int)$product['quantity'] : 1; if (isset($selectedServiceProducts[$product['htl_cart_booking_id']])) { - if ($product['id_product']) { - if ($idProduct) { - $selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] += $product['quantity']; - - } else { - $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array( - 'id_product' => $product['id_product'], - 'auto_add_to_cart' => $product['auto_add_to_cart'], - 'price_addition_type' => $product['price_addition_type'], - 'quantity' => $product['quantity'], - ); - } + if ($idProduct) { + $selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] += $product['quantity']; + } else { + $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array( + 'id_product' => $product['id_product'], + 'quantity' => $product['quantity'], + 'auto_add_to_cart' => $product['auto_add_to_cart'], + 'price_addition_type' => $product['price_addition_type'], + 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + false, + false, + $id_address + ), + 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + true, + false, + $id_address + ), + ); } $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice( (int)$product['id_product'], @@ -240,30 +436,28 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $id_address ); } else { - $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'] = ($product['id_product']) ? array( - $product['id_product'] => array( - 'id_product' => $product['id_product'], - 'quantity' => $product['quantity'], - 'auto_add_to_cart' => $product['auto_add_to_cart'], - 'price_addition_type' => $product['price_addition_type'], - 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice( - (int)$product['id_product'], - (int)$product['room_type_id_product'], - 1, - false, - false, - $id_address - ), - 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice( - (int)$product['id_product'], - (int)$product['room_type_id_product'], - 1, - true, - false, - $id_address - ), - ) - ): array(); + $selectedServiceProducts[$product['htl_cart_booking_id']]['selected_products_info'][$product['id_product']] = array( + 'id_product' => $product['id_product'], + 'quantity' => $product['quantity'], + 'auto_add_to_cart' => $product['auto_add_to_cart'], + 'price_addition_type' => $product['price_addition_type'], + 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + false, + false, + $id_address + ), + 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice( + (int)$product['id_product'], + (int)$product['room_type_id_product'], + 1, + true, + false, + $id_address + ), + ); } $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice( diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 788ef2cb0..2fd403f43 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -92,7 +92,7 @@

    {l s='Add below services to the rooms for better hotel experience'}

    {assign var=roomCount value=1} - {foreach $selectedRoomServiceProduct as $key => $cartRoom} + {foreach $cartRooms as $key => $cartRoom}
    @@ -110,7 +110,7 @@
    {if $product.available_for_order}

    - +

    {/if}
    @@ -118,7 +118,7 @@

    {$product['name']|escape:'html':'UTF-8'}

    {if $product.allow_multiple_quantity}
    - +
    From 667c680ea0f84a4035cc38ba852336d53c5616c7 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Thu, 9 Mar 2023 16:14:27 +0530 Subject: [PATCH 24/63] formatted hotel tagline and hotel short description --- modules/hotelreservationsystem/classes/HotelHelper.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 7234b8370..6eac1fd63 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -195,8 +195,7 @@ class HotelHelper { //from setting tab $home_banner_default_title = 'Four Lessons Hotel Greshon Palace'; - $home_banner_default_content = 'Tofu helvetica leggings tattooed. Skateboard blue bottle green juice, - brooklyn cardigan kitsch fap narwhal organic flexitarian.'; + $home_banner_default_content = 'Tofu helvetica leggings tattooed. Skateboard blue bottle green juice, brooklyn cardigan kitsch fap narwhal organic flexitarian.'; Configuration::updateValue('WK_HOTEL_LOCATION_ENABLE', 1); Configuration::updateValue('WK_HOTEL_NAME_ENABLE', 1); @@ -244,10 +243,8 @@ class HotelHelper $WK_HTL_SHORT_DESC = array(); foreach ($languages as $lang) { $WK_HTL_CHAIN_NAME[$lang['id_lang']] = 'Hotel Dominic Parks'; - $WK_HTL_TAG_LINE[$lang['id_lang']] = 'Tofu helvetica leggings tattooed. Skateboard blue - bottle green juice, brooklyn cardigan kitsch fap narwhal organic flexitarian.'; - $WK_HTL_SHORT_DESC[$lang['id_lang']] = 'Tofu helvetica leggings tattooed. Skateboard blue bottle green - juice, brooklyn cardigan kitsch fap narwhal organic flexitarian.'; + $WK_HTL_TAG_LINE[$lang['id_lang']] = 'Tofu helvetica leggings tattooed. Skateboard blue bottle green juice, brooklyn cardigan kitsch fap narwhal organic flexitarian.'; + $WK_HTL_SHORT_DESC[$lang['id_lang']] = 'Tofu helvetica leggings tattooed. Skateboard blue bottle green juice, brooklyn cardigan kitsch fap narwhal organic flexitarian.'; } Configuration::updateValue('WK_HTL_CHAIN_NAME', $WK_HTL_CHAIN_NAME); Configuration::updateValue('WK_HTL_TAG_LINE', $WK_HTL_TAG_LINE); From 10c69e6f760237f0773842dfcd8bb1b33ce5d88f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 9 Mar 2023 20:48:19 +0530 Subject: [PATCH 25/63] added primary hotel for price calculation --- classes/Cart.php | 3 ++ classes/Product.php | 31 +++++++++++----- .../classes/HotelHelper.php | 2 + .../admin/AdminAddHotelController.php | 37 +++++++++++++++++++ .../AdminHotelGeneralSettingsController.php | 10 +++++ .../views/js/HotelReservationAdmin.js | 24 ++++++++++++ 6 files changed, 98 insertions(+), 9 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..9c2c1051d 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3036,6 +3036,9 @@ class CartCore extends ObjectModel } else if ($id_hotel) { $addressInfo = HotelBranchInformation::getAddress($id_hotel); return $addressInfo['id_address']; + } else { + // provide an address for service product. + // for now we do not have an address associated with the service product } return false; } diff --git a/classes/Product.php b/classes/Product.php index 33d169e23..4c712e970 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3041,17 +3041,30 @@ class ProductCore extends ObjectModel $id_state = 0; $zipcode = 0; - if ($id_address) { - $address_infos = Address::getCountryAndState($id_address); - } else { - // if ($id_roomtype) { - // $address_infos = Address::getCountryAndState(Cart::getIdAddressForTaxCalculation($id_roomtype)); - // } else { - $address_infos = Address::getCountryAndState(Cart::getIdAddressForTaxCalculation($id_product)); - // } + if (!$id_address) { + if (!Product::isBookingProduct($id_product)) { + if ($id_roomtype) { + // if room type is provided with product then we know that the service product price should be calculated accroding to roomt type + $id_address = Cart::getIdAddressForTaxCalculation($id_roomtype); + } + } else { + $id_address = Cart::getIdAddressForTaxCalculation($id_product); + } } - if ($address_infos['id_country']) { + if (!$id_address) { + if ($primaryHotel = ConfigurationCore::get('WK_PRIMARY_HOTEL')) { + if ($address = HotelBranchInformation::getAddress($primaryHotel)) { + $address_infos['id_country'] = $address['id_country']; + $address_infos['id_state'] = $address['id_state']; + $address_infos['postcode'] = $address['postcode']; + } + } + } elseif ($id_address) { + $address_infos = Address::getCountryAndState($id_address); + } + + if (isset($address_infos['id_country'])) { $id_country = (int)$address_infos['id_country']; $id_state = (int)$address_infos['id_state']; $zipcode = $address_infos['postcode']; diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 7234b8370..b1f5fba4f 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -401,6 +401,8 @@ class HotelHelper $obj_hotel_info->id_category = $cat_hotel; $obj_hotel_info->save(); } + // save dummy hotel as primary hotel + Configuration::updateValue('WK_PRIMARY_HOTEL', $htl_id); return $htl_id; } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 57e616fce..698330cc3 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -422,6 +422,18 @@ class AdminAddHotelController extends ModuleAdminController if ($newIdHotel = $objHotelBranch->id) { + if ($primaryHotelId = Configuration::get('WK_PRIMARY_HOTEL')) { + if ($primaryHotelId == $objHotelBranch->id && !$objHotelBranch->active) { + $hotels = $objHotelBranch->hotelBranchesInfo(false, 1); + if (!empty($hotel = array_shift($hotels))) { + Configuration::updateValue('WK_PRIMARY_HOTEL', $objHotelBranch['id']); + } else { + $newPrimaryHotelId = Configuration::updateValue('WK_PRIMARY_HOTEL', 0); + } + } + } else if ($objHotelBranch->active) { + Configuration::updateValue('WK_PRIMARY_HOTEL', $objHotelBranch->id); + } // getHotel address if ($idHotelAddress = $objHotelBranch->getHotelIdAddress()) { $objAddress = new Address($idHotelAddress); @@ -559,6 +571,29 @@ class AdminAddHotelController extends ModuleAdminController $this->display = 'add'; } } + public function processStatus() + { + parent::processStatus(); + if (empty($this->errors)) { + if (Validate::isLoadedObject($objHotelBranch = new HotelBranchInformation(Tools::getValue('id')))) { + if ($primaryHotelId = Configuration::get('WK_PRIMARY_HOTEL')) { + if ($primaryHotelId == $objHotelBranch->id && !$objHotelBranch->active) { + $hotels = $objHotelBranch->hotelBranchesInfo(false, 1); + if (!empty($hotel = array_shift($hotels))) { + Configuration::updateValue('WK_PRIMARY_HOTEL', $hotel['id']); + } else { + $newPrimaryHotelId = Configuration::updateValue('WK_PRIMARY_HOTEL', 0); + } + } + } else { + $hotels = $objHotelBranch->hotelBranchesInfo(false, 1); + if (!empty($hotel = array_shift($hotels))) { + Configuration::updateValue('WK_PRIMARY_HOTEL', $hotel['id']); + } + } + } + } + } public function ajaxProcessStateByCountryId() { @@ -686,6 +721,8 @@ class AdminAddHotelController extends ModuleAdminController 'filesizeError' => $this->l('File exceeds maximum size.'), 'maxSizeAllowed' => Tools::getMaxUploadSize(), 'sortRowsUrl' => $this->context->link->getAdminLink('AdminAddHotel'), + 'primaryHotelId' => Configuration::get('WK_PRIMARY_HOTEL'), + 'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.'), ) ); // GOOGLE MAP diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index 96280681b..e51f9911f 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -35,6 +35,9 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController if (!$hotelsInfo = $objHotelInfo->hotelBranchesInfo(false, 1)) { $hotelsInfo = array(); } + foreach ($hotelsInfo as &$hotel) { + $hotel['name'] = $hotel['hotel_name']; + } $hotelNameDisable = (count($hotelsInfo) > 1 ? true : false); $locationDisable = ((count($hotelsInfo) < 2) && !Configuration::get('WK_HOTEL_NAME_ENABLE')) ? true : false; $this->fields_options = array( @@ -142,6 +145,13 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'hint' => $this->l('The year when your hotel site was launched.'), 'type' => 'text', ), + 'WK_PRIMARY_HOTEL' => array( + 'title' => $this->l('Primary hotel'), + 'hint' => $this->l('Primary hotel is used to default address for your business. The hotel address will be considered as your registered business address.'), + 'type' => 'select', + 'identifier' => 'id', + 'list' => $hotelsInfo, + ), 'WK_HTL_CHAIN_NAME' => array( 'title' => $this->l('Hotel Name'), 'type' => 'textLang', diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index 0c60a8389..b7e41a498 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -227,6 +227,30 @@ function initGoogleMaps() { $(document).ready(function() { //For Add Hotels + + // hotel status change + $("#form-htl_branch_info a.list-action-enable.action-enabled").on('click', function(e) { + let id_hotel = $(this).closest('tr').find('.row-selector input').val(); + if (id_hotel == primaryHotelId) { + if (!confirm(disableHotelMsg)) { + e.preventDefault(); + e.stopImmediatePropagation(); + return false; + } + } + }); + $("form#htl_branch_info_form").on('submit', function(e) { + let id_hotel = $(this).find('#id-hotel').val(); + let enable = $(this).find('[name="ENABLE_HOTEL"]:checked').val(); + if (id_hotel == primaryHotelId && !parseInt(enable)) { + if (!confirm(disableHotelMsg)) { + e.preventDefault(); + e.stopImmediatePropagation(); + return false; + } + } + }); + // delete hotel image $('.deleteHtlImage').on('click', function(){ var imgId = $(this).attr('id_htl_img'); From 0fb92ee32bc20adc83a65f0aa246c6dc76acdeaa Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 10 Mar 2023 14:26:47 +0530 Subject: [PATCH 26/63] updated getOrdersReturn function query --- classes/order/OrderReturn.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 009bf6f4f..c452f7cd8 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -260,18 +260,20 @@ class OrderReturnCore extends ObjectModel if (!$context) { $context = Context::getContext(); } - $sql = 'SELECT *, orr.*, COUNT(ord.`id_order_return_detail`) AS total_rooms - FROM `'._DB_PREFIX_.'order_return` orr - LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord - ON (ord.`id_order_return` = orr.`id_order_return`) - LEFT JOIN `'._DB_PREFIX_.'order_slip` ors - ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') - WHERE orr.`id_customer` = '.(int)$customer_id. - ($only_customer ? ' AND orr.`by_admin` = 0' : ''). - ($order_id ? ' AND orr.`id_order` = '.(int)$order_id : ''). - ($no_denied ? ' AND orr.`state` != 4' : '').' - GROUP BY orr.`id_order_return` - ORDER BY orr.`date_add` DESC'; + $sql = 'SELECT orr.`id_order`, orr.`state`, orr.`id_order_return`, orr.`payment_mode`, orr.`id_transaction`, + orr.`id_return_type`, orr.`return_type`, ors.`id_cart_rule`, orr.`date_add`, orr.`date_upd`, + COUNT(ord.`id_order_return_detail`) AS total_rooms + FROM `'._DB_PREFIX_.'order_return` orr + LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord + ON (ord.`id_order_return` = orr.`id_order_return`) + LEFT JOIN `'._DB_PREFIX_.'order_slip` ors + ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') + WHERE orr.`id_customer` = '.(int)$customer_id. + ($only_customer ? ' AND orr.`by_admin` = 0' : ''). + ($order_id ? ' AND orr.`id_order` = '.(int)$order_id : ''). + ($no_denied ? ' AND orr.`state` != 4' : '').' + GROUP BY orr.`id_order_return` + ORDER BY orr.`date_add` DESC'; $data = Db::getInstance()->executeS($sql); foreach ($data as $k => $or) { $state = new OrderReturnState($or['state']); From 4a24510a04f977b503c0e8334671fac264446a3f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 10 Mar 2023 14:36:16 +0530 Subject: [PATCH 27/63] updated getOrdersReturn function query --- classes/order/OrderReturn.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 8a4cf796c..c452f7cd8 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -260,20 +260,20 @@ class OrderReturnCore extends ObjectModel if (!$context) { $context = Context::getContext(); } - $sql = 'SELECT *, orr.`date_add`, orr.`date_upd`, - ( - SELECT COUNT(ord.`id_order_return_detail`) - FROM `'._DB_PREFIX_.'order_return_detail` ord - WHERE ord.`id_order_return` = orr.`id_order_return` - ) AS total_rooms - FROM `'._DB_PREFIX_.'order_return` orr - LEFT JOIN `'._DB_PREFIX_.'order_slip` ors - ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') - WHERE orr.`id_customer` = '.(int)$customer_id. - ($only_customer ? ' AND orr.`by_admin` = 0' : ''). - ($order_id ? ' AND orr.`id_order` = '.(int)$order_id : ''). - ($no_denied ? ' AND orr.`state` != 4' : '').' - ORDER BY orr.`date_add` DESC'; + $sql = 'SELECT orr.`id_order`, orr.`state`, orr.`id_order_return`, orr.`payment_mode`, orr.`id_transaction`, + orr.`id_return_type`, orr.`return_type`, ors.`id_cart_rule`, orr.`date_add`, orr.`date_upd`, + COUNT(ord.`id_order_return_detail`) AS total_rooms + FROM `'._DB_PREFIX_.'order_return` orr + LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord + ON (ord.`id_order_return` = orr.`id_order_return`) + LEFT JOIN `'._DB_PREFIX_.'order_slip` ors + ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.') + WHERE orr.`id_customer` = '.(int)$customer_id. + ($only_customer ? ' AND orr.`by_admin` = 0' : ''). + ($order_id ? ' AND orr.`id_order` = '.(int)$order_id : ''). + ($no_denied ? ' AND orr.`state` != 4' : '').' + GROUP BY orr.`id_order_return` + ORDER BY orr.`date_add` DESC'; $data = Db::getInstance()->executeS($sql); foreach ($data as $k => $or) { $state = new OrderReturnState($or['state']); From 223c306d4ab0f3b5601f5efe7978b234c34023d4 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Fri, 10 Mar 2023 19:29:57 +0530 Subject: [PATCH 28/63] remove unused mcrypt extension validation text --- install/controllers/http/system.php | 1 - 1 file changed, 1 deletion(-) diff --git a/install/controllers/http/system.php b/install/controllers/http/system.php index ca3b4606a..950f93247 100644 --- a/install/controllers/http/system.php +++ b/install/controllers/http/system.php @@ -136,7 +136,6 @@ class InstallControllerHttpSystem extends InstallControllerHttp 'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by QloApps will be PHP 5.6. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.6 now!'), phpversion()), 'register_globals' => $this->l('PHP register_globals option is enabled'), 'gz' => $this->l('GZIP compression is not activated'), - 'mcrypt' => $this->l('Mcrypt extension is not enabled'), 'mbstring' => $this->l('Mbstring extension is not enabled'), 'magicquotes' => $this->l('PHP magic quotes option is enabled'), 'dom' => $this->l('Dom extension is not loaded'), From a1a70e391ea83e9b4b286cefda94cba4470de6fc Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 13 Mar 2023 11:24:40 +0530 Subject: [PATCH 29/63] show auto add to cart info in room type servies tab --- .../controllers/products/serviceproduct.tpl | 18 +++++++++--------- controllers/admin/AdminProductsController.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/themes/default/template/controllers/products/serviceproduct.tpl b/admin/themes/default/template/controllers/products/serviceproduct.tpl index d0a725ee1..b8baf530a 100644 --- a/admin/themes/default/template/controllers/products/serviceproduct.tpl +++ b/admin/themes/default/template/controllers/products/serviceproduct.tpl @@ -8,21 +8,21 @@ - {l s='Id Product'} + {l s='Id Service'} - {l s='name'} + {l s='Name'} - - {l s='Category'} + + {l s='Auto Added'} {l s='Position'} - + {l s='Price'} - + {l s='Tax'} @@ -35,8 +35,8 @@ {foreach from=$service_products key=key item=service_product} {$service_product.id_product|escape:'html':'UTF-8'} - {$service_product.name} - {$service_product.category} + {$service_product.name} + {if $service_product.auto_add_to_cart}{l s='Yes'}{else}{l s='No'}{/if}
    @@ -44,7 +44,7 @@
    - + {if isset($service_product.custom_price) && $service_product.custom_price}{displayPrice price=$service_product.custom_price currency=$id_currency}{else}{displayPrice price=$service_product.default_price currency=$id_currency}{/if} -
    +
    +
    +
    {$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}
    {$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}
    diff --git a/themes/hotel-reservation-theme/css/category.css b/themes/hotel-reservation-theme/css/category.css index d79ba9ddb..a99abc8ee 100644 --- a/themes/hotel-reservation-theme/css/category.css +++ b/themes/hotel-reservation-theme/css/category.css @@ -108,6 +108,9 @@ p.capa_txt { margin-bottom: 15px; } +.visible-md .capa_txt { + padding-left: 15px; +} .rm_review_cont { @@ -254,7 +257,8 @@ p.capa_txt { .room_features_cont > div { display: flex; flex-wrap: wrap; - align-items: flex-end; + align-items: center; + justify-content: space-between; gap: 10px 0; } .booking_room_fields { From afc32d28bc79d418a6dec8f6e28be3fb70582d0c Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 15 Mar 2023 16:32:34 +0530 Subject: [PATCH 39/63] update datepicker highlited date --- js/daterangepicker/jquery.daterangepicker.js | 2 -- themes/hotel-reservation-theme/css/daterangepicker.css | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/js/daterangepicker/jquery.daterangepicker.js b/js/daterangepicker/jquery.daterangepicker.js index c104e536b..e9338be38 100755 --- a/js/daterangepicker/jquery.daterangepicker.js +++ b/js/daterangepicker/jquery.daterangepicker.js @@ -2579,11 +2579,9 @@ */ function translate(translationKey) { var translationKeyLowerCase = translationKey.toLowerCase(); - console.log(languages); var result = (translationKey in languages) ? languages[translationKey] : (translationKeyLowerCase in languages) ? languages[translationKeyLowerCase] : null; var defaultLanguage = $.dateRangePickerLanguages['default']; if (result == null) result = (translationKey in defaultLanguage) ? defaultLanguage[translationKey] : (translationKeyLowerCase in defaultLanguage) ? defaultLanguage[translationKeyLowerCase] : ''; - console.log(result); return result; } diff --git a/themes/hotel-reservation-theme/css/daterangepicker.css b/themes/hotel-reservation-theme/css/daterangepicker.css index 10de7405f..5d07270cd 100644 --- a/themes/hotel-reservation-theme/css/daterangepicker.css +++ b/themes/hotel-reservation-theme/css/daterangepicker.css @@ -75,10 +75,10 @@ background: #dadada; } .date-picker-wrapper .month-wrapper table .day.checked { - background-color: #f2f2f2; + background-color: #E6E6E6; } .date-picker-wrapper .month-wrapper table .day.toMonth.hovering { - background-color: #f2f2f2; + background-color: #E6E6E6; } .date-picker-wrapper .first-date-selected, .date-picker-wrapper .last-date-selected { background-color: #1292ff !important; From cedc565f31f5b1e2fc6d01a0d22023c5d4327d5c Mon Sep 17 00:00:00 2001 From: abhishek-webkul <84142535+abhishek-webkul@users.noreply.github.com> Date: Thu, 16 Mar 2023 11:22:49 +0530 Subject: [PATCH 40/63] Update htlnevigationmenu.js --- modules/blocknavigationmenu/views/js/htlnevigationmenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/blocknavigationmenu/views/js/htlnevigationmenu.js b/modules/blocknavigationmenu/views/js/htlnevigationmenu.js index 9f7c2e322..8348de716 100644 --- a/modules/blocknavigationmenu/views/js/htlnevigationmenu.js +++ b/modules/blocknavigationmenu/views/js/htlnevigationmenu.js @@ -52,7 +52,7 @@ $(document).ready(function() const navigationMenu = $('#menu_cont'); if (navigationMenu.length) { if (!($(e.target).closest('#menu_cont').length - || $(e.target).closest('.nav_toggle').length + || $(e.target).closest('.header-top .header-top-menu .nav_toggle').length )) { if (navigationMenu.hasClass('menu_cont_left')) { navigationMenu.removeClass('menu_cont_left').addClass('menu_cont_right'); @@ -60,4 +60,4 @@ $(document).ready(function() } } }); -}); \ No newline at end of file +}); From e617ff233eec14837e13b9a092d50ab31b404ad7 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 16 Mar 2023 06:21:39 +0000 Subject: [PATCH 41/63] fix syntax error --- modules/wkroomsearchblock/classes/WkRoomSearchHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index 381d2a625..ea14b1bca 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -147,8 +147,8 @@ class WkRoomSearchHelper $htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent); $objBookingDetail = new HotelBookingDetail(); - $searchedData['num_days'] = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo);\ - + $searchedData['num_days'] = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo); + $searchedData['parent_data'] = $htlCategoryInfo; $searchedData['date_from'] = $dateFrom; $searchedData['date_to'] = $dateTo; From cf8ebe79b2da12736acfa65b15c34892e4399f09 Mon Sep 17 00:00:00 2001 From: abhishek-webkul <84142535+abhishek-webkul@users.noreply.github.com> Date: Thu, 16 Mar 2023 11:51:53 +0530 Subject: [PATCH 42/63] Update HotelOrderRefundRules.php --- .../classes/HotelOrderRefundRules.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index 1a8b021d9..e0efe08d8 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -227,32 +227,35 @@ class HotelOrderRefundRules extends ObjectModel { $idLang = Context::getContext()->language->id; - $minDate = Db::getInstance()->getValue( - 'SELECT MIN(DATE(hbd.`date_from`)) + $maxDate = Db::getInstance()->getValue( + 'SELECT MAX(DATE(hbd.`date_from`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = '.(int) $idOrder ); - if (!$minDate) { + if (!$maxDate) { return array(); } $dateToday = date('Y-m-d'); - if (strtotime($minDate) < strtotime($dateToday)) { // same day cancellation rules are allowed - $minDate = $dateToday; + if (strtotime($maxDate) < strtotime($dateToday)) { // same day cancellation rules are allowed + $maxDate = $dateToday; } - $days = HotelBookingDetail::getDays($dateToday, $minDate); + $days = HotelBookingDetail::getDays($dateToday, $maxDate); + $idHotel = HotelBookingDetail::getIdHotelByIdOrder($idOrder); - $sql = 'SELECT * + $sql = 'SELECT hrr.`id_hotel_refund_rule`, hrr.`id_refund_rule`, hrr.`id_hotel`, hrr.`position`, + orrl.`name`, orrl.`description`, orr.`payment_type`, orr.`deduction_value_full_pay`, orr.`deduction_value_adv_pay`, + orr.`days` FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hrr LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` orr ON (orr.`id_refund_rule` = hrr.`id_refund_rule`) LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` orrl ON (orrl.`id_refund_rule` = orr.`id_refund_rule` AND orrl.`id_lang` = '.(int) $idLang.') - WHERE orr.`days` <= '.(int) $days.' - ORDER BY orr.`days` DESC'; + WHERE orr.`days` <= '.(int) $days.' AND hrr.`id_hotel` = '.(int) $idHotel.' + ORDER BY hrr.`position`'; return Db::getInstance()->executeS($sql); } From 3493cb40ef7e75c97426288d4f478147f2873564 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 16 Mar 2023 09:21:06 +0000 Subject: [PATCH 43/63] close occupancy dropdown on clicking book now button --- .../js/modules/blockcart/ajax-cart.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index ef9b485eb..75676a4d5 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -1303,7 +1303,6 @@ function getBookingOccupancyDetails(bookingform) if (child_ages.length != $(element).find('.num_children').val()) { $(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open') occupancy = false; - return false; } } occupancy.push({ @@ -1311,10 +1310,12 @@ function getBookingOccupancyDetails(bookingform) 'children': $(element).find('.num_children').val(), 'child_ages': child_ages }); + if ($(bookingform).find('.booking_occupancy_wrapper').parent().hasClass('open')) { + $('.booking_guest_occupancy_conatiner .dropdown').removeClass('open'); + } } else { $(bookingform).find('.booking_occupancy_wrapper').parent().addClass('open') occupancy = false; - return false; } }); } else { From 7707a9e5e449f21b2a6b1f1c9151473b028cce69 Mon Sep 17 00:00:00 2001 From: "lakshya.chauhan193" Date: Mon, 27 Feb 2023 17:26:29 +0530 Subject: [PATCH 44/63] resolved impact way issue on advance price --- .../controllers/admin/AdminHotelFeaturePricesSettings.php | 4 ++++ .../hotel_feature_prices_settings/helpers/form/form.tpl | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index 3d4e7aae8..7b80a8ec3 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -257,6 +257,10 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $objFeaturePricing = new HotelRoomTypeFeaturePricing(); + if ($priceImpactWay == HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE) { + $priceImpactType = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE; + } + $languages = Language::getLanguages(false); $objDefaultLang = new language($defaultLangId); $isPlanTypeExists = 0; diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl index 9587d2bf5..517a23438 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl @@ -207,7 +207,7 @@ {l s='Increase Price' mod='hotelreservationsystem'}
    @@ -223,10 +223,9 @@ {l s='Percentage' mod='hotelreservationsystem'} -
    From 9a3e566dcd97f69f62771a9092dc44359daa6fd7 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 19 Mar 2023 15:24:29 +0530 Subject: [PATCH 45/63] fix city not available in location search --- .../hotelreservationsystem/classes/HotelBranchInformation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 60da88cb3..4482606ae 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -537,7 +537,7 @@ class HotelBranchInformation extends ObjectModel FROM `'._DB_PREFIX_.'category_lang` AS cl INNER JOIN `'._DB_PREFIX_.'category` AS c ON (cl.`id_category` = c.`id_category`) WHERE cl.`name` LIKE \'%'.pSQL($searchData).'%\' - AND c.`level_depth` NOT IN (0, 1, 5) and cl.`id_lang`='.(int)$context->language->id.' + AND c.`level_depth` NOT IN (0, 1, 6) and cl.`id_lang`='.(int)$context->language->id.' AND c.`nleft` > '.(int)$locationCategory->nleft.' AND c.`nright` < '.(int)$locationCategory->nright.' GROUP BY cl.`name`' ); From fd04ab1d8868f7887719f6ae4df7423739ef249f Mon Sep 17 00:00:00 2001 From: abhishek-webkul <84142535+abhishek-webkul@users.noreply.github.com> Date: Mon, 20 Mar 2023 11:34:42 +0530 Subject: [PATCH 46/63] Update AdminProductsController.php --- controllers/admin/AdminProductsController.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 8702bf86d..521c134fd 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3143,15 +3143,14 @@ class AdminProductsControllerCore extends AdminController $index ); } - - // check if room has booking for current date range - if ($objHotelBookingDetail->chechRoomBooked($idRoom, $disDate['date_from'], $disDate['date_to'])) { - $this->errors[] = sprintf( - Tools::displayError('The %s room already has bookings for selected disable dates. Please reselect disable dates.'), - $index - ); - } } + // check if room has booking for current date range + if ($objHotelBookingDetail->chechRoomBooked($idRoom, $disDate['date_from'], $disDate['date_to'])) { + $this->errors[] = sprintf( + Tools::displayError('The %s room already has bookings for selected disable dates. Please reselect disable dates.'), + $index + ); + } } } } @@ -4742,4 +4741,4 @@ class AdminProductsControllerCore extends AdminController return $tpl->fetch(); } -} \ No newline at end of file +} From 66bc212ad46a2176266c7b0127c9c55e307b8c29 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 20 Mar 2023 11:30:59 +0530 Subject: [PATCH 47/63] fix services showing multiple times in order view page --- .../classes/RoomTypeServiceProductOrderDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php index 2f66c2711..3d1291110 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php @@ -204,7 +204,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel } $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)'; - $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`product_id` = rsod.`id_product` AND od.`id_order` = '.(int)$idOrder.')'; + $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = hbd.`id_order_detail`)'; $sql .= ' WHERE rsod.`id_order` = '.(int)$idOrder.' AND hbd.`id_product`='.(int) $roomTypeIdProduct .' AND hbd.`date_from` = \''.pSQL($dateFrom).'\' AND hbd.`date_to` = \''.pSQL($dateTo).'\' AND hbd.`id_room`='.(int) $idRoom; if ($getTotalPrice) { From 993764a19c3e6ec48a469ac70678d9eba9e0d8cb Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 20 Mar 2023 12:21:31 +0530 Subject: [PATCH 48/63] Update HotelOrderRefundRules.php query --- .../classes/HotelOrderRefundRules.php | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index dbc191ce5..491c82c29 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -247,30 +247,33 @@ class HotelOrderRefundRules extends ObjectModel WHERE hbd.`id_order` = '.(int) $idOrder ); - if (!$maxDate) { - return array(); + if ($maxDate) { + $dateToday = date('Y-m-d'); + + if (strtotime($maxDate) >= strtotime($dateToday)) { + $days = HotelBookingDetail::getDays($dateToday, $maxDate); // always returns positive + + $sql = 'SELECT hbrr.`id_hotel_refund_rule`, hbrr.`id_refund_rule`, hbrr.`id_hotel`, hbrr.`position`, + horrl.`name`, horrl.`description`, horr.`payment_type`, horr.`deduction_value_full_pay`, + horr.`deduction_value_adv_pay`, horr.`days` + FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hbrr + LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` horr + ON (horr.`id_refund_rule` = hbrr.`id_refund_rule`) + LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` horrl + ON (horrl.`id_refund_rule` = horr.`id_refund_rule` AND horrl.`id_lang` = '.(int) $idLang.') + LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd + ON (hbd.`id_hotel` = hbrr.`id_hotel` AND hbd.`id_order` = '.(int) $idOrder.') + WHERE horr.`days` <= '.(int) $days.' + GROUP BY hbrr.`id_refund_rule` + ORDER BY hbrr.`position`'; + + if ($result = Db::getInstance()->executeS($sql)) { + return $result; + } + } } - $dateToday = date('Y-m-d'); + return array(); - if (strtotime($maxDate) < strtotime($dateToday)) { // same day cancellation rules are allowed - $maxDate = $dateToday; - } - - $days = HotelBookingDetail::getDays($dateToday, $maxDate); - $idHotel = HotelBookingDetail::getIdHotelByIdOrder($idOrder); - - $sql = 'SELECT hrr.`id_hotel_refund_rule`, hrr.`id_refund_rule`, hrr.`id_hotel`, hrr.`position`, - orrl.`name`, orrl.`description`, orr.`payment_type`, orr.`deduction_value_full_pay`, orr.`deduction_value_adv_pay`, - orr.`days` - FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hrr - LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` orr - ON (orr.`id_refund_rule` = hrr.`id_refund_rule`) - LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` orrl - ON (orrl.`id_refund_rule` = orr.`id_refund_rule` AND orrl.`id_lang` = '.(int) $idLang.') - WHERE orr.`days` <= '.(int) $days.' AND hrr.`id_hotel` = '.(int) $idHotel.' - ORDER BY hrr.`position`'; - - return Db::getInstance()->executeS($sql); } } From 2e034cc40285e63beb84ba67fc6325388baa45ab Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 20 Mar 2023 12:40:18 +0530 Subject: [PATCH 49/63] updated services modal design and fixed product line price issue --- .../controllers/orders/_product_line.tpl | 8 +- .../orders/_room_extra_services_modal.tpl | 8 -- .../orders/_room_facilities_block.tpl | 78 +++++++---- .../orders/_room_services_block.tpl | 128 +++++++++++------- controllers/admin/AdminOrdersController.php | 1 + .../RoomTypeServiceProductOrderDetail.php | 4 +- 6 files changed, 138 insertions(+), 89 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_product_line.tpl b/admin/themes/default/template/controllers/orders/_product_line.tpl index 5f0af8220..0cdb71e44 100644 --- a/admin/themes/default/template/controllers/orders/_product_line.tpl +++ b/admin/themes/default/template/controllers/orders/_product_line.tpl @@ -182,9 +182,11 @@ {convertPriceWithCurrency price=($data['extra_demands_price_te'] + $data['additional_services_price_te'] + $data['convenience_fee_te'] + $data['additional_services_price_auto_add_te']) currency=$currency->id} - - - + {if (isset($data['extra_demands']) && $data['extra_demands']) || (isset($data['additional_services']) && $data['additional_services'])} + + + + {/if}
    - - - {* Css for handling extra demands changes *}