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)