From c90577691c5beda549ce9354667bd1ecf4d65bd2 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 3 Feb 2025 11:34:20 +0530 Subject: [PATCH 01/12] Replaced the stayovers kpis with occupied kpi in dashboard and admin orders --- controllers/admin/AdminOrdersController.php | 6 +++--- modules/dashguestcycle/dashguestcycle.php | 9 +++++++-- .../views/templates/hook/dashboard-top.tpl | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 6dfcdaced..4aa84863a 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2587,11 +2587,11 @@ class AdminOrdersControllerCore extends AdminController $helper->id = 'box-today-stay-over'; $helper->icon = 'icon-user'; $helper->color = 'color4'; - $helper->title = $this->l('Stay Overs', null, null, false); + $helper->title = $this->l('Occupied Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d', strtotime('+ 1 days'))).'&orderFilter_hbd!date_to[]='; - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_stay_over'; - $helper->tooltip = $this->l('Total number of stay overs for today.', null, null, false); + $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=occupied_rooms'; + $helper->tooltip = $this->l('The count of rooms that are currently occupied by guests.', null, null, false); $this->kpis[] = $helper; $helper = new HelperKpi(); diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index 601e11704..ade5cd28e 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -79,7 +79,7 @@ class DashGuestCycle extends Module $dataValue['dgc_total_departures'] = sprintf('%02d', rand(100, 1000)); $dataValue['dgc_departed'] = sprintf('%02d', rand(0, $dataValue['dgc_total_departures'])); $dataValue['dgc_new_bookings'] = sprintf('%02d', rand(10, 500)); - $dataValue['dgc_stay_overs'] = sprintf('%02d', rand(10, 500)); + $dataValue['dgc_occupied'] = sprintf('%02d', rand(10, 500)); $dataValue['dgc_new_messages'] = sprintf('%02d', rand(0, 20)); $dataValue['dgc_cancelled_bookings'] = sprintf('%02d', rand(0, 20)); $dataValue['dgc_guests_adults'] = sprintf('%02d', rand(100, 1000)); @@ -94,7 +94,12 @@ class DashGuestCycle extends Module $dataValue['dgc_departed'] = sprintf('%02d', $departuresData['departed']); $dataValue['dgc_total_departures'] = sprintf('%02d', $departuresData['total_departures']); $dataValue['dgc_new_bookings'] = sprintf('%02d', count(AdminStatsController::getNewBookingsInfoByDate($dateToday, $params['id_hotel']))); - $dataValue['dgc_stay_overs'] = sprintf('%02d', AdminStatsController::getStayOversByDate($dateToday, $params['id_hotel'])); + $dataValue['dgc_occupied'] = sprintf('%02d', AdminStatsController::getDistinctRoomBookingsCount( + date('Y-m-d', strtotime('-1 day')), + $dateToday, + $params['id_hotel'], + HotelBookingDetail::STATUS_CHECKED_IN + )); $dataValue['dgc_new_messages'] = sprintf('%02d', CustomerMessage::getMessagesByDate($dateToday)); $dataValue['dgc_cancelled_bookings'] = sprintf('%02d', AdminStatsController::getCancelledBookingsByDate($dateToday, $params['id_hotel'])); $dataValue['dgc_guests_adults'] = sprintf('%02d', $guestsData['adults']); diff --git a/modules/dashguestcycle/views/templates/hook/dashboard-top.tpl b/modules/dashguestcycle/views/templates/hook/dashboard-top.tpl index be28fd58c..8df983b06 100644 --- a/modules/dashguestcycle/views/templates/hook/dashboard-top.tpl +++ b/modules/dashguestcycle/views/templates/hook/dashboard-top.tpl @@ -68,15 +68,15 @@
-
+
-

{l s="Stay Overs" mod='dashguestcycle'}

+

{l s='Occupied Rooms' mod='dashguestcycle'}

- +

From 669b0fa6f4742a9d3d9284289aac90fa7fec8488 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Wed, 19 Feb 2025 17:55:19 +0530 Subject: [PATCH 02/12] fixed Employees with only add access are unable to create the order from the back office. --- controllers/admin/AdminOrdersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 6dfcdaced..672692a9a 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1669,7 +1669,7 @@ class AdminOrdersControllerCore extends AdminController $this->errors[] = Tools::displayError('The invoice for edit note was unable to load. '); } } elseif (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart'))) { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['add'] === '1') { $objCart = new Cart($id_cart); if (Validate::isLoadedObject($objCart)) { $this->context->cart = $objCart; From 1dc1219306c6272bec96404ddb32e6e434a2cf73 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Thu, 20 Feb 2025 12:27:20 +0530 Subject: [PATCH 03/12] update conditions based on add order --- controllers/admin/AdminCartsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 2ce84593f..ced579771 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -349,7 +349,7 @@ class AdminCartsControllerCore extends AdminController ################################################################## public function ajaxPreProcess() { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['edit'] === '1'||$this->tabAccess['add'] === '1') { // prevent cart creation when kpi visibility or kpi view is updated. // @todo: move the below cart creation process required function. if (in_array(Tools::getValue('action'), array('changeKpiVisibility', 'saveKpiView'))) { @@ -598,7 +598,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateCurrency() { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['edit'] === '1'||$this->tabAccess['add'] === '1') { $currency = new Currency((int)Tools::getValue('id_currency')); if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) { $this->context->cart->id_currency = (int)$currency->id; From 72d3ca46555f1117908383b6b032ac47e7b18b73 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Mon, 24 Feb 2025 16:21:46 +0530 Subject: [PATCH 04/12] space added --- controllers/admin/AdminCartsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index ced579771..f8f17476c 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -349,7 +349,7 @@ class AdminCartsControllerCore extends AdminController ################################################################## public function ajaxPreProcess() { - if ($this->tabAccess['edit'] === '1'||$this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1'|| $this->tabAccess['add'] === '1') { // prevent cart creation when kpi visibility or kpi view is updated. // @todo: move the below cart creation process required function. if (in_array(Tools::getValue('action'), array('changeKpiVisibility', 'saveKpiView'))) { @@ -598,7 +598,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateCurrency() { - if ($this->tabAccess['edit'] === '1'||$this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1'|| $this->tabAccess['add'] === '1') { $currency = new Currency((int)Tools::getValue('id_currency')); if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) { $this->context->cart->id_currency = (int)$currency->id; From 7119a2f43fe70700fd8aa00b4b81d278580e4d0e Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Mon, 24 Feb 2025 16:23:51 +0530 Subject: [PATCH 05/12] add missing spaces --- controllers/admin/AdminCartsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f8f17476c..f0ed7d29c 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -349,7 +349,7 @@ class AdminCartsControllerCore extends AdminController ################################################################## public function ajaxPreProcess() { - if ($this->tabAccess['edit'] === '1'|| $this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') { // prevent cart creation when kpi visibility or kpi view is updated. // @todo: move the below cart creation process required function. if (in_array(Tools::getValue('action'), array('changeKpiVisibility', 'saveKpiView'))) { @@ -598,7 +598,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateCurrency() { - if ($this->tabAccess['edit'] === '1'|| $this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') { $currency = new Currency((int)Tools::getValue('id_currency')); if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) { $this->context->cart->id_currency = (int)$currency->id; From 874b0c30dbd0ff19107c17f27bb24abbe42f46cb Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Tue, 25 Feb 2025 11:49:27 +0530 Subject: [PATCH 06/12] update the access conditions --- controllers/admin/AdminCartsController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f0ed7d29c..244468711 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -349,7 +349,7 @@ class AdminCartsControllerCore extends AdminController ################################################################## public function ajaxPreProcess() { - if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') { + if ($this->tabAccess['add'] === '1') { // prevent cart creation when kpi visibility or kpi view is updated. // @todo: move the below cart creation process required function. if (in_array(Tools::getValue('action'), array('changeKpiVisibility', 'saveKpiView'))) { @@ -598,7 +598,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateCurrency() { - if ($this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1') { + if ($this->tabAccess['add'] === '1') { $currency = new Currency((int)Tools::getValue('id_currency')); if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) { $this->context->cart->id_currency = (int)$currency->id; @@ -628,7 +628,7 @@ class AdminCartsControllerCore extends AdminController } public function ajaxProcessUpdateLang() { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['add'] === '1') { $lang = new Language((int)Tools::getValue('id_lang')); if (Validate::isLoadedObject($lang) && $lang->active) { $this->context->cart->id_lang = (int)$lang->id; @@ -699,7 +699,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessAddVoucher() { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['add'] === '1') { $errors = array(); if (!($id_cart_rule = Tools::getValue('id_cart_rule')) || !$cart_rule = new CartRule((int)$id_cart_rule)) { $errors[] = Tools::displayError('Invalid voucher.'); @@ -717,7 +717,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateAddress() { - if ($this->tabAccess['edit'] === '1') { + if ($this->tabAccess['add'] === '1') { echo json_encode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang))); } } From bd8f680484d45d5afeb81e5dc62e33daa0bd9897 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 13 Mar 2025 15:54:56 +0530 Subject: [PATCH 07/12] Fixed: multiple orders are create for the user, if the user clicks on the 'Confirm Order' while validating order from checque and bankwire from the front --- .../views/templates/front/payment_execution.tpl | 14 ++++++++++---- .../views/templates/front/payment_execution.tpl | 16 +++++++++++----- .../views/templates/front/payment_execution.tpl | 8 +++++++- .../views/templates/front/payment_execution.tpl | 8 +++++++- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/modules/bankwire/views/templates/front/payment_execution.tpl b/modules/bankwire/views/templates/front/payment_execution.tpl index 88d9ad4a7..d7c41a2ba 100644 --- a/modules/bankwire/views/templates/front/payment_execution.tpl +++ b/modules/bankwire/views/templates/front/payment_execution.tpl @@ -85,15 +85,21 @@

- -  {l s='Other payment methods' mod='bankwire'} - + + {l s='Other payment methods' mod='bankwire'} + {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if}

+ {/if} diff --git a/modules/cheque/views/templates/front/payment_execution.tpl b/modules/cheque/views/templates/front/payment_execution.tpl index df13864df..a608df34b 100644 --- a/modules/cheque/views/templates/front/payment_execution.tpl +++ b/modules/cheque/views/templates/front/payment_execution.tpl @@ -81,11 +81,17 @@ {l s='Other payment methods' mod='cheque'} {*By webkul To Check Order restrict condition before Payment by the customer*} - {if !$restrict_order} - - {/if} + {if !$restrict_order} + + {/if}

+ {/if} diff --git a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl index b7e6fa42c..d7c41a2ba 100644 --- a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl @@ -90,10 +90,16 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if}

+ {/if} diff --git a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl index efeaa971b..1ff49aed0 100644 --- a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl @@ -82,10 +82,16 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if}

+ {/if} From 3400508adea1fd8ecb2cc30758496e8832f6b0b5 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Wed, 26 Mar 2025 18:33:28 +0530 Subject: [PATCH 08/12] tab Access updated and moved updateserviceproduct --- .../template/controllers/orders/form.tpl | 2 +- controllers/admin/AdminCartsController.php | 71 +++++++++++++++++-- controllers/admin/AdminOrdersController.php | 57 --------------- 3 files changed, 67 insertions(+), 63 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 105e6b608..ef3006c53 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1696,7 +1696,7 @@ headers: { "cache-control": "no-cache" }, - url: "{$link->getAdminLink('AdminOrders')|addslashes}", + url: "{$link->getAdminLink('AdminCarts')|addslashes}", dataType: 'JSON', cache: false, data: { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 244468711..b3ede17b6 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -349,7 +349,7 @@ class AdminCartsControllerCore extends AdminController ################################################################## public function ajaxPreProcess() { - if ($this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1') { // prevent cart creation when kpi visibility or kpi view is updated. // @todo: move the below cart creation process required function. if (in_array(Tools::getValue('action'), array('changeKpiVisibility', 'saveKpiView'))) { @@ -598,7 +598,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateCurrency() { - if ($this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1') { $currency = new Currency((int)Tools::getValue('id_currency')); if (Validate::isLoadedObject($currency) && !$currency->deleted && $currency->active) { $this->context->cart->id_currency = (int)$currency->id; @@ -628,7 +628,7 @@ class AdminCartsControllerCore extends AdminController } public function ajaxProcessUpdateLang() { - if ($this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1') { $lang = new Language((int)Tools::getValue('id_lang')); if (Validate::isLoadedObject($lang) && $lang->active) { $this->context->cart->id_lang = (int)$lang->id; @@ -699,7 +699,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessAddVoucher() { - if ($this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1') { $errors = array(); if (!($id_cart_rule = Tools::getValue('id_cart_rule')) || !$cart_rule = new CartRule((int)$id_cart_rule)) { $errors[] = Tools::displayError('Invalid voucher.'); @@ -717,7 +717,7 @@ class AdminCartsControllerCore extends AdminController public function ajaxProcessUpdateAddress() { - if ($this->tabAccess['add'] === '1') { + if ($this->tabAccess['edit'] === '1') { echo json_encode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang))); } } @@ -1144,6 +1144,7 @@ class AdminCartsControllerCore extends AdminController // Process when admin changes extra demands of any room while order creation process form.tpl public function ajaxProcessChangeRoomDemands() { + if ($this->tabAccess['edit'] === '1') { $response = array('status' => false); if ($idCartBooking = Tools::getValue('id_cart_booking')) { if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) { @@ -1157,6 +1158,66 @@ class AdminCartsControllerCore extends AdminController } } $this->ajaxDie(json_encode($response)); + } + } + + public function ajaxProcessUpdateServiceProduct() + { + if ($this->tabAccess['edit'] === '1') { + $operator = Tools::getValue('operator', 'up'); + $idServiceProduct = Tools::getValue('id_product'); + $idCartBooking = Tools::getValue('id_cart_booking'); + $qty = Tools::getValue('qty'); + + if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + + if ($operator == 'up') { + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) { + // validate quanitity + if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) { + if ($objProduct->allow_multiple_quantity) { + if (!Validate::isUnsignedInt($qty)) { + $this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.'); + // } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { + // $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } + } else { + $qty = 1; + } + } else { + $this->errors[] = Tools::displayError('This Service is not available.'); + } + } else { + $this->errors[] = Tools::displayError('This Service is not available with selected room.'); + } + } + + if (empty($this->errors)) { + if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct( + $idCartBooking, + $idServiceProduct, + $qty, + $objHotelCartBookingData->id_cart, + $operator + )) { + $this->ajaxDie(json_encode(array( + 'hasError' => false + ))); + } else { + $this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.'); + } + + } + } else { + $this->errors[] = Tools::displayError('Room not found. Please try reloading the page.'); + } + $this->ajaxDie(json_encode(array( + 'hasError' => true, + 'errors' => $this->errors + ))); + } } public static function getOrderTotalUsingTaxCalculationMethod($id_cart) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 3a98a34ac..9dfcd25b6 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -7092,63 +7092,6 @@ class AdminOrdersControllerCore extends AdminController die(json_encode($response)); } - public function ajaxProcessUpdateServiceProduct() - { - $operator = Tools::getValue('operator', 'up'); - $idServiceProduct = Tools::getValue('id_product'); - $idCartBooking = Tools::getValue('id_cart_booking'); - $qty = Tools::getValue('qty'); - - if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - - if ($operator == 'up') { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) { - // validate quanitity - if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) { - if ($objProduct->allow_multiple_quantity) { - if (!Validate::isUnsignedInt($qty)) { - $this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.'); - // } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { - // $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); - } - } else { - $qty = 1; - } - } else { - $this->errors[] = Tools::displayError('This Service is not available.'); - } - } else { - $this->errors[] = Tools::displayError('This Service is not available with selected room.'); - } - } - - if (empty($this->errors)) { - if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct( - $idCartBooking, - $idServiceProduct, - $qty, - $objHotelCartBookingData->id_cart, - $operator - )) { - $this->ajaxDie(json_encode(array( - 'hasError' => false - ))); - } else { - $this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.'); - } - - } - } else { - $this->errors[] = Tools::displayError('Room not found. Please try reloading the page.'); - } - $this->ajaxDie(json_encode(array( - 'hasError' => true, - 'errors' => $this->errors - ))); - } - // To change the status of the room public function changeRoomStatus() { From a934de1cb778d0a10b6a2b6a014b892b4d98dcfc Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Wed, 26 Mar 2025 19:36:28 +0530 Subject: [PATCH 09/12] indentation updated --- controllers/admin/AdminCartsController.php | 114 ++++++++++----------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index b3ede17b6..cafb660f6 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1144,80 +1144,80 @@ class AdminCartsControllerCore extends AdminController // Process when admin changes extra demands of any room while order creation process form.tpl public function ajaxProcessChangeRoomDemands() { - if ($this->tabAccess['edit'] === '1') { - $response = array('status' => false); - if ($idCartBooking = Tools::getValue('id_cart_booking')) { - if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) { - $roomDemands = Tools::getValue('room_demands'); - $roomDemands = json_decode($roomDemands, true); - $roomDemands = json_encode($roomDemands); - $objCartbookingCata->extra_demands = $roomDemands; - if ($objCartbookingCata->save()) { - $response['status'] = true; + if ($this->tabAccess['edit'] === '1') { + $response = array('status' => false); + if ($idCartBooking = Tools::getValue('id_cart_booking')) { + if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) { + $roomDemands = Tools::getValue('room_demands'); + $roomDemands = json_decode($roomDemands, true); + $roomDemands = json_encode($roomDemands); + $objCartbookingCata->extra_demands = $roomDemands; + if ($objCartbookingCata->save()) { + $response['status'] = true; + } } } + $this->ajaxDie(json_encode($response)); } - $this->ajaxDie(json_encode($response)); - } } public function ajaxProcessUpdateServiceProduct() { if ($this->tabAccess['edit'] === '1') { - $operator = Tools::getValue('operator', 'up'); - $idServiceProduct = Tools::getValue('id_product'); - $idCartBooking = Tools::getValue('id_cart_booking'); - $qty = Tools::getValue('qty'); - - if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - - if ($operator == 'up') { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) { - // validate quanitity - if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) { - if ($objProduct->allow_multiple_quantity) { - if (!Validate::isUnsignedInt($qty)) { - $this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.'); - // } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { - // $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + $operator = Tools::getValue('operator', 'up'); + $idServiceProduct = Tools::getValue('id_product'); + $idCartBooking = Tools::getValue('id_cart_booking'); + $qty = Tools::getValue('qty'); + + if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + + if ($operator == 'up') { + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) { + // validate quanitity + if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) { + if ($objProduct->allow_multiple_quantity) { + if (!Validate::isUnsignedInt($qty)) { + $this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.'); + // } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { + // $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } + } else { + $qty = 1; } } else { - $qty = 1; + $this->errors[] = Tools::displayError('This Service is not available.'); } } else { - $this->errors[] = Tools::displayError('This Service is not available.'); + $this->errors[] = Tools::displayError('This Service is not available with selected room.'); } - } else { - $this->errors[] = Tools::displayError('This Service is not available with selected room.'); } - } - - if (empty($this->errors)) { - if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct( - $idCartBooking, - $idServiceProduct, - $qty, - $objHotelCartBookingData->id_cart, - $operator - )) { - $this->ajaxDie(json_encode(array( - 'hasError' => false - ))); - } else { - $this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.'); + + if (empty($this->errors)) { + if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct( + $idCartBooking, + $idServiceProduct, + $qty, + $objHotelCartBookingData->id_cart, + $operator + )) { + $this->ajaxDie(json_encode(array( + 'hasError' => false + ))); + } else { + $this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.'); + } + } - + } else { + $this->errors[] = Tools::displayError('Room not found. Please try reloading the page.'); } - } else { - $this->errors[] = Tools::displayError('Room not found. Please try reloading the page.'); + $this->ajaxDie(json_encode(array( + 'hasError' => true, + 'errors' => $this->errors + ))); } - $this->ajaxDie(json_encode(array( - 'hasError' => true, - 'errors' => $this->errors - ))); - } } public static function getOrderTotalUsingTaxCalculationMethod($id_cart) From 5ca2d8ea86d5e9e1498be585976fe4d263a2630a Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 7 Apr 2025 10:30:43 +0530 Subject: [PATCH 10/12] Removed the script from the tpl and added js file for the script --- .../bankwire/controllers/front/payment.php | 6 ++++ modules/bankwire/views/js/front/index.php | 33 +++++++++++++++++++ modules/bankwire/views/js/front/payment.js | 26 +++++++++++++++ modules/bankwire/views/js/index.php | 32 ++++++++++++++++++ .../templates/front/payment_execution.tpl | 6 ---- modules/cheque/controllers/front/payment.php | 6 ++++ modules/cheque/views/js/front/index.php | 32 ++++++++++++++++++ modules/cheque/views/js/front/payment.js | 26 +++++++++++++++ modules/cheque/views/js/index.php | 32 ++++++++++++++++++ .../templates/front/payment_execution.tpl | 6 ---- .../templates/front/payment_execution.tpl | 6 ---- .../templates/front/payment_execution.tpl | 6 ---- 12 files changed, 193 insertions(+), 24 deletions(-) create mode 100644 modules/bankwire/views/js/front/index.php create mode 100644 modules/bankwire/views/js/front/payment.js create mode 100644 modules/bankwire/views/js/index.php create mode 100644 modules/cheque/views/js/front/index.php create mode 100644 modules/cheque/views/js/front/payment.js create mode 100644 modules/cheque/views/js/index.php diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index 59dc5ab17..63c76795f 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -80,4 +80,10 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $this->setTemplate('payment_execution.tpl'); } + + public function setMedia() + { + parent::setMedia(); + $this->addJS($this->module->getLocalPath().'views/js/front/payment.js'); + } } diff --git a/modules/bankwire/views/js/front/index.php b/modules/bankwire/views/js/front/index.php new file mode 100644 index 000000000..e5f2df63f --- /dev/null +++ b/modules/bankwire/views/js/front/index.php @@ -0,0 +1,33 @@ + - {/if} diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index 1d5e0f76b..1eee0a140 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -83,4 +83,10 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $this->setTemplate('payment_execution.tpl'); } + + public function setMedia() + { + parent::setMedia(); + $this->addJS($this->module->getLocalPath().'views/js/front/payment.js'); + } } diff --git a/modules/cheque/views/js/front/index.php b/modules/cheque/views/js/front/index.php new file mode 100644 index 000000000..150f23072 --- /dev/null +++ b/modules/cheque/views/js/front/index.php @@ -0,0 +1,32 @@ + - {/if} diff --git a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl index d7c41a2ba..148c11978 100644 --- a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl @@ -96,10 +96,4 @@ {/if}

- {/if} diff --git a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl index 1ff49aed0..9d373466b 100644 --- a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl @@ -88,10 +88,4 @@ {/if}

- {/if} From 5d92fe50f2284b1a93efe2f387a092ca9d635372 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 22 Apr 2025 12:56:19 +0530 Subject: [PATCH 11/12] optmized the code changes --- modules/bankwire/views/js/front/payment.js | 12 ++++++++---- .../views/templates/front/payment_execution.tpl | 2 +- modules/cheque/views/js/front/payment.js | 11 +++++++---- .../views/templates/front/payment_execution.tpl | 2 +- .../views/templates/front/payment_execution.tpl | 2 +- .../views/templates/front/payment_execution.tpl | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/bankwire/views/js/front/payment.js b/modules/bankwire/views/js/front/payment.js index 7f6b0902e..c9784132d 100644 --- a/modules/bankwire/views/js/front/payment.js +++ b/modules/bankwire/views/js/front/payment.js @@ -20,7 +20,11 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 */ -function disableSubmitButton(button) { - $(button).attr('disabled', 'disabled'); - $(button).closest('form').get(0).submit(); -} \ No newline at end of file + +$(document).ready(function () { + $(document).on('click', '.confirm_order', function(e){ + e.preventDefault(); + $(e.target).attr('disabled', 'disabled'); + $(e.target).closest('form').get(0).submit(); + }); +}); diff --git a/modules/bankwire/views/templates/front/payment_execution.tpl b/modules/bankwire/views/templates/front/payment_execution.tpl index 148c11978..835542afe 100644 --- a/modules/bankwire/views/templates/front/payment_execution.tpl +++ b/modules/bankwire/views/templates/front/payment_execution.tpl @@ -90,7 +90,7 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if} diff --git a/modules/cheque/views/js/front/payment.js b/modules/cheque/views/js/front/payment.js index 7f6b0902e..698fe1a0f 100644 --- a/modules/cheque/views/js/front/payment.js +++ b/modules/cheque/views/js/front/payment.js @@ -20,7 +20,10 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 */ -function disableSubmitButton(button) { - $(button).attr('disabled', 'disabled'); - $(button).closest('form').get(0).submit(); -} \ No newline at end of file +$(document).ready(function () { + $(document).on('click', '.confirm_order', function(e){ + e.preventDefault(); + $(e.target).attr('disabled', 'disabled'); + $(e.target).closest('form').get(0).submit(); + }); +}); diff --git a/modules/cheque/views/templates/front/payment_execution.tpl b/modules/cheque/views/templates/front/payment_execution.tpl index a85bbb48c..a6afee4b8 100644 --- a/modules/cheque/views/templates/front/payment_execution.tpl +++ b/modules/cheque/views/templates/front/payment_execution.tpl @@ -82,7 +82,7 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if} diff --git a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl index 148c11978..835542afe 100644 --- a/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/bankwire/views/templates/front/payment_execution.tpl @@ -90,7 +90,7 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if} diff --git a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl index 9d373466b..8fff68f8e 100644 --- a/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl +++ b/themes/hotel-reservation-theme/modules/cheque/views/templates/front/payment_execution.tpl @@ -82,7 +82,7 @@ {*By webkul To Check Order restrict condition before Payment by the customer*} {if !$restrict_order} - {/if} From 4e22455110213719ffe9368296899bba3fcaa519 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 23 Apr 2025 12:11:19 +0530 Subject: [PATCH 12/12] Added proper event handeling on confirm order button click --- modules/bankwire/views/js/front/payment.js | 4 ++-- modules/cheque/views/js/front/payment.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/bankwire/views/js/front/payment.js b/modules/bankwire/views/js/front/payment.js index c9784132d..4cb1fd20f 100644 --- a/modules/bankwire/views/js/front/payment.js +++ b/modules/bankwire/views/js/front/payment.js @@ -24,7 +24,7 @@ $(document).ready(function () { $(document).on('click', '.confirm_order', function(e){ e.preventDefault(); - $(e.target).attr('disabled', 'disabled'); - $(e.target).closest('form').get(0).submit(); + $(this).attr('disabled', 'disabled'); + $(this).closest('form').get(0).submit(); }); }); diff --git a/modules/cheque/views/js/front/payment.js b/modules/cheque/views/js/front/payment.js index 698fe1a0f..b1a731203 100644 --- a/modules/cheque/views/js/front/payment.js +++ b/modules/cheque/views/js/front/payment.js @@ -23,7 +23,7 @@ $(document).ready(function () { $(document).on('click', '.confirm_order', function(e){ e.preventDefault(); - $(e.target).attr('disabled', 'disabled'); - $(e.target).closest('form').get(0).submit(); + $(this).attr('disabled', 'disabled'); + $(this).closest('form').get(0).submit(); }); });