From eb75515c8795ef65e413edcb2ac1a142d0663e07 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Thu, 5 Feb 2026 13:29:32 +0530 Subject: [PATCH 01/20] Update the text of the add new button --- controllers/admin/AdminSlipController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminSlipController.php b/controllers/admin/AdminSlipController.php index 1b767a2f5..d75766580 100644 --- a/controllers/admin/AdminSlipController.php +++ b/controllers/admin/AdminSlipController.php @@ -118,7 +118,7 @@ class AdminSlipControllerCore extends AdminController if (empty($this->display)) { $this->page_header_toolbar_btn['new_credit_slip'] = array( 'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token, - 'desc' => $this->l('Add new credit slip', null, null, false), + 'desc' => $this->l('Add Credit Slip', null, null, false), 'icon' => 'process-icon-new' ); } @@ -148,7 +148,7 @@ class AdminSlipControllerCore extends AdminController 'label' => $this->l('Order id'), 'name' => 'id_order', 'required' => true, - 'hint' => $this->l('Select id order'), + 'hint' => $this->l('Select an Order ID to generate the credit slip'), 'class' => 'chosen', 'options' => array( 'query' => $orderList, From 0e8f60f426357db5468dc966072b6b1b444d99ed Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Mon, 25 May 2026 12:46:21 +0530 Subject: [PATCH 02/20] Update the Admin slip controller input field type Co-authored-by: Name --- .../controllers/slip/_booking_amount_desc.tpl | 23 ++++ .../controllers/slip/_order_info_desc.tpl | 26 ++++ controllers/admin/AdminSlipController.php | 84 ++++++++++-- js/admin/slips.js | 123 +++++++++++++++--- 4 files changed, 230 insertions(+), 26 deletions(-) create mode 100644 admin/themes/default/template/controllers/slip/_booking_amount_desc.tpl create mode 100644 admin/themes/default/template/controllers/slip/_order_info_desc.tpl diff --git a/admin/themes/default/template/controllers/slip/_booking_amount_desc.tpl b/admin/themes/default/template/controllers/slip/_booking_amount_desc.tpl new file mode 100644 index 000000000..4e7b9d568 --- /dev/null +++ b/admin/themes/default/template/controllers/slip/_booking_amount_desc.tpl @@ -0,0 +1,23 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +{l s='Total cost of room and service:'} - diff --git a/admin/themes/default/template/controllers/slip/_order_info_desc.tpl b/admin/themes/default/template/controllers/slip/_order_info_desc.tpl new file mode 100644 index 000000000..c7fd0a15e --- /dev/null +++ b/admin/themes/default/template/controllers/slip/_order_info_desc.tpl @@ -0,0 +1,26 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + + + diff --git a/controllers/admin/AdminSlipController.php b/controllers/admin/AdminSlipController.php index d75766580..3fdf9cca2 100644 --- a/controllers/admin/AdminSlipController.php +++ b/controllers/admin/AdminSlipController.php @@ -141,7 +141,7 @@ class AdminSlipControllerCore extends AdminController 'title' => $this->l('Credit slip'), 'icon' => 'icon-print' ), - 'description' => $this->l('Kindly check the credit slip again before saving it, as it cannot be changed once created.'), + 'description' => '' . $this->l('Note: Before generating the credit slip, please review all details carefully. Once the credit slip is generated, it cannot be modified.') . '', 'input' => array( array( 'type' => 'select', @@ -150,6 +150,10 @@ class AdminSlipControllerCore extends AdminController 'required' => true, 'hint' => $this->l('Select an Order ID to generate the credit slip'), 'class' => 'chosen', + 'col' => 3, + 'desc' => $this->context->smarty->fetch( + _PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_order_info_desc.tpl' + ), 'options' => array( 'query' => $orderList, 'id' => 'id_order', @@ -158,13 +162,28 @@ class AdminSlipControllerCore extends AdminController ), array( 'type' => 'select', - 'label' => $this->l('Booking Detail'), - 'name' => 'id_booking_detail', + 'label' => $this->l('Room Type'), + 'name' => 'id_room_type', 'required' => true, + 'hint' => $this->l('Select a room type'), + 'col' => 3, 'options' => array( 'query' => array(), 'id' => 'id', - 'name' => 'booking_label' + 'name' => 'name' + ) + ), + array( + 'type' => 'select', + 'label' => $this->l('Room'), + 'name' => 'id_booking_detail', + 'required' => true, + 'hint' => $this->l('Select a room to generate the credit slip for'), + 'col' => 3, + 'options' => array( + 'query' => array(), + 'id' => 'id', + 'name' => 'room_label' ) ), array( @@ -175,10 +194,13 @@ class AdminSlipControllerCore extends AdminController 'required' => true, 'col' => 2, 'suffix' => $this->context->currency->sign, + 'desc' => $this->context->smarty->fetch( + _PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_booking_amount_desc.tpl' + ), ), ), 'submit' => array( - 'title' => $this->l('Save'), + 'title' => $this->l('Generate'), 'name' => 'submitCreditSlip', ) ); @@ -226,12 +248,18 @@ class AdminSlipControllerCore extends AdminController public function postProcess() { if (Tools::getValue('submitCreditSlip')) { - if (empty(trim(Tools::getValue('credit_slip_amount')))) { - $this->errors[] = $this->l('Amount is required for the generate credit slip'); + $creditSlipAmount = trim(Tools::getValue('credit_slip_amount')); + if (empty($creditSlipAmount)) { + $this->errors[] = $this->l('Credit slip Amount is required for the generate credit slip'); + } elseif (!is_numeric($creditSlipAmount)) { + $this->errors[] = $this->l('Credit slip Amount must be a valid number'); + } elseif ((float) $creditSlipAmount <= 0) { + $this->errors[] = $this->l('Credit slip Amount must be greater than 0'); } + if (!count($this->errors)) { $objOrder = new Order(Tools::getValue('id_order')); - $creditAmount = Tools::getValue('credit_slip_amount'); + $creditAmount = $creditSlipAmount; $idBookingDetail = Tools::getValue('id_booking_detail'); $customer = new Customer($objOrder->id_customer); $bookingList = array(); @@ -283,7 +311,8 @@ class AdminSlipControllerCore extends AdminController } Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=3'); } else { - return parent::postProcess(); + $this->display = 'add'; + return; } } else if (Tools::getValue('submitAddorder_slip')) { if (!Validate::isDate(Tools::getValue('date_from'))) { @@ -478,6 +507,40 @@ class AdminSlipControllerCore extends AdminController $objHotelBookingDetail = new HotelBookingDetail(); $bookingDetails = $objHotelBookingDetail->getBookingDataByOrderId($idOrder); + $objBookingDemands = new HotelBookingDemands(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + + foreach ($bookingDetails as &$booking) { + $booking['extra_service_total_price_tax_incl'] = 0; + + $extraDemands = $objBookingDemands->getRoomTypeBookingExtraDemands( + $idOrder, + $booking['id_product'], + $booking['id_room'], + $booking['date_from'], + $booking['date_to'], + 0, + 0, + 1, + $booking['id'] + ); + if ($extraDemands) { + foreach ($extraDemands as $demand) { + $booking['extra_service_total_price_tax_incl'] += (float) $demand['total_price_tax_incl']; + } + } + + $roomServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, 0, $booking['id'] + ); + if ($roomServices && isset($roomServices[$booking['id']]['additional_services'])) { + foreach ($roomServices[$booking['id']]['additional_services'] as $service) { + $booking['extra_service_total_price_tax_incl'] += (float) $service['total_price_tax_incl']; + } + } + } + unset($booking); + die(Tools::jsonEncode(array( 'bookings' => $bookingDetails, 'currency' => $currency @@ -491,6 +554,9 @@ class AdminSlipControllerCore extends AdminController array( 'admin_order_slip_tab_link' => $this->context->link->getAdminLink('AdminSlip'), 'ajax_booking_url' => $this->context->link->getAdminLink('AdminSlip', true), + 'admin_order_view_link' => $this->context->link->getAdminLink('AdminOrders'), + 'prevRoomType' => (int) Tools::getValue('id_room_type'), + 'prevBookingDetail' => (int) Tools::getValue('id_booking_detail'), ) ); $this->addJS(_PS_JS_DIR_.'admin/slips.js'); diff --git a/js/admin/slips.js b/js/admin/slips.js index 7d5c10e79..4b1dea78e 100644 --- a/js/admin/slips.js +++ b/js/admin/slips.js @@ -104,11 +104,45 @@ $(document).ready(function() { }); } + var allBookings = []; + var currencySign = ''; + + if (typeof $.fn.chosen !== 'undefined') { + $('select[name="id_order"]').chosen('destroy').chosen({ + width: '100%', + search_contains: true + }); + $('select[name="id_room_type"]').chosen({ + width: '100%', + search_contains: true + }); + $('select[name="id_booking_detail"]').chosen({ + width: '100%', + search_contains: true + }); + } + $('select[name="id_order"]').on('change', function () { - var idOrder = $(this).val(); + var $roomTypeSelect = $('select[name="id_room_type"]'); + var $bookingSelect = $('select[name="id_booking_detail"]'); - if (!idOrder) return; + allBookings = []; + $roomTypeSelect.empty().trigger('chosen:updated'); + $bookingSelect.empty().trigger('chosen:updated'); + + if (!idOrder) { + $('#order-info').hide(); + $('#order-view-link').hide(); + return; + } + + var selectedLabel = $('select[name="id_order"] option:selected').text(); + $('#order-info').text(selectedLabel).show(); + + $('#order-view-link') + .attr('href', admin_order_view_link + '&id_order=' + idOrder + '&vieworder') + .show(); $.ajax({ url: ajax_booking_url, @@ -120,31 +154,86 @@ $(document).ready(function() { id_order: idOrder }, success: function (response) { + allBookings = response.bookings || []; - var $bookingSelect = $('select[name="id_booking_detail"]'); - $bookingSelect.empty(); - - if (response.bookings.length > 0) { - $.each(response.bookings, function (index, booking) { - $bookingSelect.append( - $('