Merge pull request #479 from abhishek-webkul/gli-1045
New Feature: Preparation time for bookings
This commit is contained in:
@@ -59,6 +59,30 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
'order_restrict' => array(
|
||||
'title' => $this->l('Order Restrict'),
|
||||
'icon' => 'icon-cogs',
|
||||
'fields' => array(
|
||||
'MAX_GLOBAL_BOOKING_DATE' => array(
|
||||
'title' => $this->l('Maximum Global Date to book a room'),
|
||||
'hint' => $this->l('Maximum date by which rooms of your hotels can be booked.'),
|
||||
'type' => 'text',
|
||||
'id' => 'max_global_book_date',
|
||||
'class' => 'fixed-width-xxl readonly',
|
||||
),
|
||||
'GLOBAL_PREPARATION_TIME' => array(
|
||||
'title' => $this->l('Preparation time'),
|
||||
'hint' => $this->l('Number of days required to prepare a room for stay.'),
|
||||
'desc' => $this->l('Set to 0 to disable this feature.'),
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xl',
|
||||
'suffix' => $this->l('day(s)'),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
),
|
||||
'general' => array(
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'icon-cogs',
|
||||
@@ -183,9 +207,34 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql))) {
|
||||
$this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.');
|
||||
}
|
||||
|
||||
$maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE');
|
||||
$globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME');
|
||||
$maxGlobalBookingDateFormatted = date('Y-m-d', strtotime($maxGlobalBookingDate));
|
||||
|
||||
if ($maxGlobalBookingDate == '') {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' can not be empty.');
|
||||
} elseif (!Validate::isDate($maxGlobalBookingDateFormatted)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' is invalid.');
|
||||
} elseif (strtotime($maxGlobalBookingDateFormatted) < strtotime(date('Y-m-d'))) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' can not be a past date. Please use a future date.');
|
||||
}
|
||||
|
||||
if ($globalPreparationTime === '') {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' can not be empty.');
|
||||
} elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
$this->addJS(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user