Optimized code for the max global booking dates

This commit is contained in:
vishalsingh.qlo325
2024-07-08 18:33:58 +05:30
parent f13c672400
commit fa86af848a
4 changed files with 10 additions and 19 deletions

View File

@@ -82,23 +82,21 @@ class AdminOrderPreferencesControllerCore extends AdminController
)
);
$maxOrderDate = (Tools::getValue('MAX_GLOBAL_BOOKING_DATE'))? Tools::getValue('MAX_GLOBAL_BOOKING_DATE') : Configuration::get('MAX_GLOBAL_BOOKING_DATE');
$maxOrderDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE', Configuration::get('MAX_GLOBAL_BOOKING_DATE'));
$this->fields_options = array(
'order_restrict' => array(
'title' => $this->l('Order Restrict'),
'icon' => 'icon-cogs',
'fields' => array(
'max_global_booking_date_formatted' => array(
'MAX_GLOBAL_BOOKING_DATE' => array(
'title' => $this->l('Maximum Global Check-out Date to book a room'),
'hint' => $this->l('Maximum date of check-out for which rooms of your hotels can be booked.'),
'defaultValue' => date('d-m-Y', strtotime($maxOrderDate)),
'type' => 'text',
'id' => 'max_global_book_date',
'auto_value' => false,
'value' => date('d-m-Y', strtotime($maxOrderDate)),
'class' => 'fixed-width-xxl readonly',
),
'MAX_GLOBAL_BOOKING_DATE' => array(
'type' => 'hidden',
),
'GLOBAL_PREPARATION_TIME' => array(
'title' => $this->l('Preparation time'),
'hint' => $this->l('Number of days required to prepare a room for a guest\'s stay. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'),
@@ -334,8 +332,6 @@ class AdminOrderPreferencesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.');
}
// To prevent this from saving in the configuration table
unset($_POST['max_global_booking_date_formatted']);
$_POST['MAX_GLOBAL_BOOKING_DATE'] = date('Y-m-d', strtotime(Tools::getValue('MAX_GLOBAL_BOOKING_DATE')));
$maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE');
$globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME');