Fixed: date pickers for the AdminOrder, AdminSpecificPriceRul, AdminInvoices, AdminCreditSlip, AdminHotelFeaturePriceSettings and filters

This commit is contained in:
vishalsingh.qlo325
2024-03-01 17:45:16 +05:30
parent 17256b4ccb
commit 4e66542e0d
8 changed files with 154 additions and 22 deletions

View File

@@ -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();

View File

@@ -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');
}
}

View File

@@ -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');
}
}

View File

@@ -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();
}
}

56
js/admin/invoices.js Normal file
View File

@@ -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 <contact@prestashop.com>
* @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);
}
},
});
});

View File

@@ -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(

56
js/admin/slips.js Normal file
View File

@@ -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 <contact@prestashop.com>
* @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);
}
},
});
});

View File

@@ -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)