diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index 170fe675a..31372ae8d 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -78,11 +78,6 @@ class AdminOrderPreferencesControllerCore extends AdminController 'class' => 'fixed-width-xl', 'suffix' => $this->l('day(s)'), ), - 'BACKDATE_ORDER_EMPLOYEES' => array( - 'title' => $this->l('Allow backdate order from Back-office'), - 'hint' => $this->l('Allow backoffice employees to create bookings for backdate'), - 'type' => 'bool', - ), ), 'submit' => array( 'title' => $this->l('Save'), @@ -202,6 +197,22 @@ class AdminOrderPreferencesControllerCore extends AdminController ), 'submit' => array('title' => $this->l('Save')) ), + 'back_date_order' => array( + 'title' => $this->l('Backdate Order Restrictions'), + 'icon' => 'icon-cogs', + 'fields' => array( + 'PS_BACKDATE_ORDER_SUPERADMIN' => array( + 'title' => $this->l('Allow backdate order from Back-office for super-admin'), + 'hint' => $this->l('Allow superadmin to create bookings for backdate'), + 'type' => 'bool', + ), + 'PS_BACKDATE_ORDER_EMPLOYEES' => array( + 'title' => $this->l('Allow backdate order from Back-office for employees'), + 'hint' => $this->l('Allow employees to create bookings for backdate'), + 'type' => 'bool', + ), + ) + ) ); if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index dc98bbe1b..3a611b3ee 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -286,7 +286,12 @@ class AdminOrdersControllerCore extends AdminController $cart_order_exists = $cart->orderExists(); if (!$cart_order_exists) { $this->context->cart = $cart; - if (!Configuration::get('BACKDATE_ORDER_EMPLOYEES')) { + if ($this->context->employee->isSuperAdmin()) { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; + } else { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; + } + if (!Configuration::get($backOrderConfigKey)) { $objHotelCartBookingData = new HotelCartBookingData(); $objHotelCartBookingData->removeBackdateRoomsFromCart($this->context->cart->id); } diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 5ec2a0371..29d13d5ed 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -905,7 +905,10 @@ 1 - + + 1 + + 1 diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 4e6f07575..04a2aa885 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -63,8 +63,12 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $objCustomer->id_guest = (int) $this->context->cookie->id_guest; $this->context->customer = $objCustomer; - - if (!Configuration::get('BACKDATE_ORDER_EMPLOYEES')) { + if ($this->context->employee->isSuperAdmin()) { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; + } else { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; + } + if (!Configuration::get($backOrderConfigKey)) { $htlCart = new HotelCartBookingData(); $htlCart->removeBackdateRoomsFromCart($this->context->cart->id); } @@ -97,7 +101,12 @@ class AdminHotelRoomsBookingController extends ModuleAdminController } else { $date_from = date('Y-m-d'); } - if (!Configuration::get('BACKDATE_ORDER_EMPLOYEES')) { + if ($this->context->employee->isSuperAdmin()) { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; + } else { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; + } + if (!Configuration::get($backOrderConfigKey)) { if (strtotime(date('Y-m-d')) > strtotime($date_from)) { $date_from = date('Y-m-d'); } @@ -811,6 +820,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $occupancyRequiredForBooking = true; } + if ($this->context->employee->isSuperAdmin()) { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; + } else { + $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; + } + $PS_BACKDATE_ORDER_ALLOW = (int)Configuration::get($backOrderConfigKey); + $jsVars = array( 'currency_prefix' => $currency->prefix, 'currency_suffix' => $currency->suffix, @@ -852,7 +868,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'years_txt' => $this->l('years', null, true), 'all_children_txt' => $this->l('All Children', null, true), 'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', null, true), - 'BACKDATE_ORDER_EMPLOYEES' => Configuration::get('BACKDATE_ORDER_EMPLOYEES'), + 'PS_BACKDATE_ORDER_ALLOW' => $PS_BACKDATE_ORDER_ALLOW, // 'check_calender_var' => $check_calender_var, ); if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) { diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index 31b7593a5..98da293f4 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -220,7 +220,7 @@ $(document).ready(function() { dateFormat: 'dd-mm-yy', altFormat: 'yy-mm-dd', altField: '#date_from', - minDate: BACKDATE_ORDER_EMPLOYEES == 1 ? null : 0, + minDate: PS_BACKDATE_ORDER_ALLOW == 1 ? null : 0, beforeShowDay: function (date) { return highlightDateBorder($("#from_date").val(), date); }, @@ -237,7 +237,7 @@ $(document).ready(function() { dateFormat: 'dd-mm-yy', altFormat: 'yy-mm-dd', altField: '#date_to', - minDate: BACKDATE_ORDER_EMPLOYEES == 1 ? null : 1, + minDate: PS_BACKDATE_ORDER_ALLOW == 1 ? null : 1, beforeShowDay: function (date) { return highlightDateBorder($("#to_date").val(), date); },