From 4e66542e0dff0eb551e924a893fa5c9b9036c4d8 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 1 Mar 2024 17:45:16 +0530 Subject: [PATCH 1/3] Fixed: date pickers for the AdminOrder, AdminSpecificPriceRul, AdminInvoices, AdminCreditSlip, AdminHotelFeaturePriceSettings and filters --- .../template/helpers/list/list_header.tpl | 16 +++--- controllers/admin/AdminInvoicesController.php | 9 ++- controllers/admin/AdminSlipController.php | 9 ++- .../AdminSpecificPriceRuleController.php | 6 ++ js/admin/invoices.js | 56 +++++++++++++++++++ js/admin/orders.js | 12 ++-- js/admin/slips.js | 56 +++++++++++++++++++ .../views/js/HotelReservationAdmin.js | 12 ++-- 8 files changed, 154 insertions(+), 22 deletions(-) create mode 100644 js/admin/invoices.js create mode 100644 js/admin/slips.js diff --git a/admin/themes/default/template/helpers/list/list_header.tpl b/admin/themes/default/template/helpers/list/list_header.tpl index fc2dcc571..e9c626464 100644 --- a/admin/themes/default/template/helpers/list/list_header.tpl +++ b/admin/themes/default/template/helpers/list/list_header.tpl @@ -422,14 +422,14 @@ prevText: '', nextText: '', dateFormat: 'yy-mm-dd', - beforeShow: function() { - let dateTo = $('#local_{$params.id_date}_1').val().trim(); - if (typeof dateTo != 'undefined' && dateTo != '') { - let objDateToMax = $.datepicker.parseDate('yy-mm-dd', dateTo); - objDateToMax.setDate(objDateToMax.getDate() - 1); - $('#local_{$params.id_date}_0').datepicker('option', 'maxDate', objDateToMax); - } - }, + // beforeShow: function() { + // let dateTo = $('#local_{$params.id_date}_1').val().trim(); + // if (typeof dateTo != 'undefined' && dateTo != '') { + // let objDateToMax = $.datepicker.parseDate('yy-mm-dd', dateTo); + // objDateToMax.setDate(objDateToMax.getDate() - 1); + // $('#local_{$params.id_date}_0').datepicker('option', 'maxDate', objDateToMax); + // } + // }, onClose: function() { let dateFrom = $('#local_{$params.id_date}_0').val().trim(); let dateTo = $('#local_{$params.id_date}_1').val().trim(); diff --git a/controllers/admin/AdminInvoicesController.php b/controllers/admin/AdminInvoicesController.php index a264b05c9..d3c4f8c30 100644 --- a/controllers/admin/AdminInvoicesController.php +++ b/controllers/admin/AdminInvoicesController.php @@ -157,7 +157,7 @@ class AdminInvoicesControllerCore extends AdminController $this->fields_value = array( 'date_from' => date('Y-m-d'), - 'date_to' => date('Y-m-d') + 'date_to' => date('Y-m-d', strtotime('+ 1 day')) ); $this->table = 'invoice_date'; @@ -324,4 +324,11 @@ class AdminInvoicesControllerCore extends AdminController return $templates; } + + public function setMedia() + { + parent::setMedia(); + $this->addJS(_PS_JS_DIR_.'admin/invoices.js'); + } + } diff --git a/controllers/admin/AdminSlipController.php b/controllers/admin/AdminSlipController.php index a64d044c2..725b9d87c 100644 --- a/controllers/admin/AdminSlipController.php +++ b/controllers/admin/AdminSlipController.php @@ -156,7 +156,7 @@ class AdminSlipControllerCore extends AdminController $this->fields_value = array( 'date_from' => date('Y-m-d'), - 'date_to' => date('Y-m-d') + 'date_to' => date('Y-m-d', strtotime('+ 1 day')) ); $this->show_toolbar = false; @@ -295,4 +295,11 @@ class AdminSlipControllerCore extends AdminController return '--'; } + + public function setMedia() + { + parent::setMedia(); + $this->addJS(_PS_JS_DIR_.'admin/slips.js'); + } + } diff --git a/controllers/admin/AdminSpecificPriceRuleController.php b/controllers/admin/AdminSpecificPriceRuleController.php index fd45236ba..f110f00f6 100644 --- a/controllers/admin/AdminSpecificPriceRuleController.php +++ b/controllers/admin/AdminSpecificPriceRuleController.php @@ -365,6 +365,12 @@ class AdminSpecificPriceRuleControllerCore extends AdminController public function postProcess() { Tools::clearSmartyCache(); + if (Tools::isSubmit('submitAdd'.$this->table)) { + if (strtotime(Tools::getValue('from')) > strtotime(Tools::getValue('to'))) { + $this->errors[] = Tools::displayError('The price rule cannot end before it begins.'); + } + } + return parent::postProcess(); } } diff --git a/js/admin/invoices.js b/js/admin/invoices.js new file mode 100644 index 000000000..4a97d6d73 --- /dev/null +++ b/js/admin/invoices.js @@ -0,0 +1,56 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/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 license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2017 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +$(document).ready(function() { + $("#date_from").datepicker({ + showOtherMonths: true, + dateFormat: 'yy-mm-dd', + onClose: function() { + let dateFrom = $('#date_from').val().trim(); + let dateTo = $('#date_to').val().trim(); + + if (dateFrom >= dateTo) { + let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); + objDateToMin.setDate(objDateToMin.getDate() + 1); + + $('#date_to').datepicker('option', 'minDate', objDateToMin); + } + }, + }); + + $("#date_to").datepicker({ + showOtherMonths: true, + dateFormat: 'yy-mm-dd', + beforeShow: function() { + let dateFrom = $('#date_from').val().trim(); + + if (typeof dateFrom != 'undefined' && dateFrom != '') { + let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); + objDateToMin.setDate(objDateToMin.getDate() + 1); + + $('#date_to').datepicker('option', 'minDate', objDateToMin); + } + }, + }); +}); \ No newline at end of file diff --git a/js/admin/orders.js b/js/admin/orders.js index c3780bac7..1b2253a06 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1543,12 +1543,12 @@ function initRoomEvents() { showOtherMonths: true, dateFormat: 'dd-mm-yy', - onSelect: function(selectedDate) { - var date_format = selectedDate.split("-"); - var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0]))); - selectedDate.setDate(selectedDate.getDate() - 1); - $(".add_room_date_from").datepicker("option", "maxDate", selectedDate); - } + // onSelect: function(selectedDate) { + // var date_format = selectedDate.split("-"); + // var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0]))); + // selectedDate.setDate(selectedDate.getDate() - 1); + // $(".add_room_date_from").datepicker("option", "maxDate", selectedDate); + // } }); $(".edit_product_date_from").datepicker( diff --git a/js/admin/slips.js b/js/admin/slips.js new file mode 100644 index 000000000..4a97d6d73 --- /dev/null +++ b/js/admin/slips.js @@ -0,0 +1,56 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/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 license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2017 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +$(document).ready(function() { + $("#date_from").datepicker({ + showOtherMonths: true, + dateFormat: 'yy-mm-dd', + onClose: function() { + let dateFrom = $('#date_from').val().trim(); + let dateTo = $('#date_to').val().trim(); + + if (dateFrom >= dateTo) { + let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); + objDateToMin.setDate(objDateToMin.getDate() + 1); + + $('#date_to').datepicker('option', 'minDate', objDateToMin); + } + }, + }); + + $("#date_to").datepicker({ + showOtherMonths: true, + dateFormat: 'yy-mm-dd', + beforeShow: function() { + let dateFrom = $('#date_from').val().trim(); + + if (typeof dateFrom != 'undefined' && dateFrom != '') { + let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); + objDateToMin.setDate(objDateToMin.getDate() + 1); + + $('#date_to').datepicker('option', 'minDate', objDateToMin); + } + }, + }); +}); \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index 653a318e5..6fc09a48d 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -706,12 +706,12 @@ $(document).ready(function() { beforeShowDay: function (date) { return highlightDateBorder($("#feature_plan_date_to").val(), date); }, - onSelect: function(selectedDate) { - var date_format = selectedDate.split("-"); - var selectedDate = new Date(date_format[2], date_format[1] - 1, date_format[0]); - selectedDate.setDate(selectedDate.getDate() - 1); - $("#feature_plan_date_from").datepicker("option", "maxDate", selectedDate); - } + // onSelect: function(selectedDate) { + // var date_format = selectedDate.split("-"); + // var selectedDate = new Date(date_format[2], date_format[1] - 1, date_format[0]); + // selectedDate.setDate(selectedDate.getDate() - 1); + // $("#feature_plan_date_from").datepicker("option", "maxDate", selectedDate); + // } }); function highlightDateBorder(elementVal, date) From 92dc470d320af7e3ca40517854f5f00ef4d112d4 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 13 Mar 2024 13:10:23 +0530 Subject: [PATCH 2/3] updated the datepicker in invoices and slips --- controllers/admin/AdminInvoicesController.php | 2 +- controllers/admin/AdminSlipController.php | 2 +- js/admin/invoices.js | 4 ++-- js/admin/slips.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/admin/AdminInvoicesController.php b/controllers/admin/AdminInvoicesController.php index d3c4f8c30..ac319b80e 100644 --- a/controllers/admin/AdminInvoicesController.php +++ b/controllers/admin/AdminInvoicesController.php @@ -157,7 +157,7 @@ class AdminInvoicesControllerCore extends AdminController $this->fields_value = array( 'date_from' => date('Y-m-d'), - 'date_to' => date('Y-m-d', strtotime('+ 1 day')) + 'date_to' => date('Y-m-d') ); $this->table = 'invoice_date'; diff --git a/controllers/admin/AdminSlipController.php b/controllers/admin/AdminSlipController.php index 725b9d87c..5ec060088 100644 --- a/controllers/admin/AdminSlipController.php +++ b/controllers/admin/AdminSlipController.php @@ -156,7 +156,7 @@ class AdminSlipControllerCore extends AdminController $this->fields_value = array( 'date_from' => date('Y-m-d'), - 'date_to' => date('Y-m-d', strtotime('+ 1 day')) + 'date_to' => date('Y-m-d') ); $this->show_toolbar = false; diff --git a/js/admin/invoices.js b/js/admin/invoices.js index 4a97d6d73..2375f0616 100644 --- a/js/admin/invoices.js +++ b/js/admin/invoices.js @@ -32,7 +32,7 @@ $(document).ready(function() { if (dateFrom >= dateTo) { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#date_to').datepicker('option', 'minDate', objDateToMin); } @@ -47,7 +47,7 @@ $(document).ready(function() { if (typeof dateFrom != 'undefined' && dateFrom != '') { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#date_to').datepicker('option', 'minDate', objDateToMin); } diff --git a/js/admin/slips.js b/js/admin/slips.js index 4a97d6d73..2375f0616 100644 --- a/js/admin/slips.js +++ b/js/admin/slips.js @@ -32,7 +32,7 @@ $(document).ready(function() { if (dateFrom >= dateTo) { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#date_to').datepicker('option', 'minDate', objDateToMin); } @@ -47,7 +47,7 @@ $(document).ready(function() { if (typeof dateFrom != 'undefined' && dateFrom != '') { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#date_to').datepicker('option', 'minDate', objDateToMin); } From ae2705c351be54725cf46f0368da49252b0516aa Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 14 Mar 2024 10:13:32 +0530 Subject: [PATCH 3/3] Updated the notice of license, updated the datepicker for the filters --- .../orders/helpers/list/list_header.tpl | 12 ++-------- .../template/helpers/list/list_header.tpl | 12 ++-------- js/admin/invoices.js | 23 ++++++++----------- js/admin/orders.js | 16 ++----------- js/admin/slips.js | 23 ++++++++----------- .../views/js/HotelReservationAdmin.js | 8 +------ 6 files changed, 25 insertions(+), 69 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl b/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl index c5fa152c5..a21de86ed 100644 --- a/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl @@ -205,21 +205,13 @@ prevText: '', nextText: '', dateFormat: 'yy-mm-dd', - beforeShow: function() { - let dateTo = $('#local_{$params.id_date}_1').val().trim(); - if (typeof dateTo != 'undefined' && dateTo != '') { - let objDateToMax = $.datepicker.parseDate('yy-mm-dd', dateTo); - objDateToMax.setDate(objDateToMax.getDate() - 1); - $('#local_{$params.id_date}_0').datepicker('option', 'maxDate', objDateToMax); - } - }, onClose: function() { let dateFrom = $('#local_{$params.id_date}_0').val().trim(); let dateTo = $('#local_{$params.id_date}_1').val().trim(); if (dateFrom >= dateTo) { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin); } @@ -235,7 +227,7 @@ if (typeof dateFrom != 'undefined' && dateFrom != '') { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin); } diff --git a/admin/themes/default/template/helpers/list/list_header.tpl b/admin/themes/default/template/helpers/list/list_header.tpl index e9c626464..fab09c70e 100644 --- a/admin/themes/default/template/helpers/list/list_header.tpl +++ b/admin/themes/default/template/helpers/list/list_header.tpl @@ -422,21 +422,13 @@ prevText: '', nextText: '', dateFormat: 'yy-mm-dd', - // beforeShow: function() { - // let dateTo = $('#local_{$params.id_date}_1').val().trim(); - // if (typeof dateTo != 'undefined' && dateTo != '') { - // let objDateToMax = $.datepicker.parseDate('yy-mm-dd', dateTo); - // objDateToMax.setDate(objDateToMax.getDate() - 1); - // $('#local_{$params.id_date}_0').datepicker('option', 'maxDate', objDateToMax); - // } - // }, onClose: function() { let dateFrom = $('#local_{$params.id_date}_0').val().trim(); let dateTo = $('#local_{$params.id_date}_1').val().trim(); if (dateFrom >= dateTo) { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin); } @@ -452,7 +444,7 @@ if (typeof dateFrom != 'undefined' && dateFrom != '') { let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom); - objDateToMin.setDate(objDateToMin.getDate() + 1); + objDateToMin.setDate(objDateToMin.getDate()); $('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin); } diff --git a/js/admin/invoices.js b/js/admin/invoices.js index 2375f0616..55732d26a 100644 --- a/js/admin/invoices.js +++ b/js/admin/invoices.js @@ -1,25 +1,20 @@ /* +* Since 2010 Webkul. * * NOTICE OF LICENSE * -* This source file is subject to the Open Software License (OSL 3.0) -* that is bundled with this package in the file LICENSE.txt. -* It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/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 license@prestashop.com so we can send you a copy immediately. +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html * * DISCLAIMER * -* Do not edit or add to this file if you wish to upgrade PrestaShop to newer -* versions in the future. If you wish to customize PrestaShop for your -* needs please refer to http://www.prestashop.com for more information. +* 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 https://store.webkul.com/customisation-guidelines/ for more information. * -* @author PrestaShop SA -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html */ $(document).ready(function() { diff --git a/js/admin/orders.js b/js/admin/orders.js index 1b2253a06..536f2fe9f 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1542,13 +1542,7 @@ function initRoomEvents() $(".add_room_date_to").datepicker( { showOtherMonths: true, - dateFormat: 'dd-mm-yy', - // onSelect: function(selectedDate) { - // var date_format = selectedDate.split("-"); - // var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0]))); - // selectedDate.setDate(selectedDate.getDate() - 1); - // $(".add_room_date_from").datepicker("option", "maxDate", selectedDate); - // } + dateFormat: 'dd-mm-yy' }); $(".edit_product_date_from").datepicker( @@ -1566,13 +1560,7 @@ function initRoomEvents() $(".edit_product_date_to").datepicker( { showOtherMonths: true, - dateFormat: 'dd-mm-yy', - onSelect: function(selectedDate) { - var date_format = selectedDate.split("-"); - var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[2], date_format[1] - 1, date_format[0]))); - selectedDate.setDate(selectedDate.getDate() - 1); - $(".edit_product_date_from").datepicker("option", "maxDate", selectedDate); - } + dateFormat: 'dd-mm-yy' }); /*End*/ diff --git a/js/admin/slips.js b/js/admin/slips.js index 2375f0616..55732d26a 100644 --- a/js/admin/slips.js +++ b/js/admin/slips.js @@ -1,25 +1,20 @@ /* +* Since 2010 Webkul. * * NOTICE OF LICENSE * -* This source file is subject to the Open Software License (OSL 3.0) -* that is bundled with this package in the file LICENSE.txt. -* It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/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 license@prestashop.com so we can send you a copy immediately. +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html * * DISCLAIMER * -* Do not edit or add to this file if you wish to upgrade PrestaShop to newer -* versions in the future. If you wish to customize PrestaShop for your -* needs please refer to http://www.prestashop.com for more information. +* 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 https://store.webkul.com/customisation-guidelines/ for more information. * -* @author PrestaShop SA -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html */ $(document).ready(function() { diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index 6fc09a48d..db259b486 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -705,13 +705,7 @@ $(document).ready(function() { //for calender Css beforeShowDay: function (date) { return highlightDateBorder($("#feature_plan_date_to").val(), date); - }, - // onSelect: function(selectedDate) { - // var date_format = selectedDate.split("-"); - // var selectedDate = new Date(date_format[2], date_format[1] - 1, date_format[0]); - // selectedDate.setDate(selectedDate.getDate() - 1); - // $("#feature_plan_date_from").datepicker("option", "maxDate", selectedDate); - // } + } }); function highlightDateBorder(elementVal, date)