From 38f075585d7c54fb8c41177cd74c1c6381f43dd3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 2 Aug 2024 12:42:49 +0530 Subject: [PATCH 01/14] Updated the disabled dates interface and flow, also added necessary hooks in the process --- .../default/sass/controllers/_products.sass | 111 ++ .../products/booked_room_date_ranges_list.tpl | 32 +- .../controllers/products/configuration.tpl | 950 ++++++++++++++---- controllers/admin/AdminProductsController.php | 329 +++--- .../classes/HotelRoomDisableDates.php | 10 +- 5 files changed, 1085 insertions(+), 347 deletions(-) diff --git a/admin/themes/default/sass/controllers/_products.sass b/admin/themes/default/sass/controllers/_products.sass index b7302f7d1..01d961ae1 100644 --- a/admin/themes/default/sass/controllers/_products.sass +++ b/admin/themes/default/sass/controllers/_products.sass @@ -1,2 +1,113 @@ #leave_bprice margin-left: 0px + +.margin-lt-5 + margin-left: 5px + +.margin-lt-10 + margin-left: 10px + +.margin-lt-20 + margin-left: 20px + +.margin-rt-5 + margin-right: 5px + +.margin-rt-10 + margin-right: 10px + +.margin-rt-20 + margin-right: 20px + +#deactiveDatesModal + .fc-daygrid-event + box-shadow: 0px 1px 2px 0px rgba(171, 171, 171, 0.3) + border-radius: 4px + .fc-event-title-container + padding: 4px + .highlight-event-day + background: #F5F5F5 + .display_title + text-overflow: ellipsis + white-space: nowrap + max-width: 65% + overflow: hidden + border-left: 2px solid red + padding-left: 10px + #disabled_dates_form + textarea + border-radius: 4px + .form-group + .control-label + margin-bottom: 5px + .btn + margin-top: 10px + margin-left: 5px + border-radius: 5px + margin: 0 + padding-right: 0px + padding: 10px + .modal-title + .close + line-height: 2 + .disabled-dates-modal-title + .disabled-dates-modal-room-num + color: grey + display: inline-block + font-weight: 600 + line-height: 2 + .form-title-text + font-size: 15px + .delete_disabled_dates + margin-left: 10px + .delete_disabled_dates:hover , .edit_disabled_dates:hover + cursor: pointer + .date_from_container, .date_to_container + .ui-datepicker + position: absolute + top: 60px + left: 5px + padding-right: 0 + position: relative + .tooltip_info_block + .tooltip_title + margin: 10px 5px + font-weight: 600 + min-width: 340px + .tooltip_container + .tooltip_title + .close + opacity: 0.6 + padding-bottom: 5px + font-weight: 600 + .tooltip_label + font-weight: 400 + color: #888888 + margin-bottom: 5px + .tooltip_content_label + border: 1px solid #D9D9D9 + border-radius: 6px + padding: 5px + .tooltip_content + &> div + display: inline-block + .row + padding-bottom: 15px + margin-left: 0 + margin-right: 0 + ul.disabled_dates_actions + .btn + text-align: left + display: block + border: none + padding-left: 0 + margin-bottom: 0 + list-style-type: none + font-size: 14px + z-index: 99999 + position: absolute + max-width: 400px + background: #fff + box-shadow: 0 8px 25px -2px rgba(0,0,0,0.20) + padding: 10px 15px + border-radius: 6px \ No newline at end of file diff --git a/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl b/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl index fc157a5b3..eb6207cd5 100644 --- a/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl +++ b/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl @@ -17,21 +17,17 @@ * @license LICENSE.txt *} -{l s='This room already has bookings for highlighted date range(s):'} - - - - - - - - {foreach from=$booked_rows_list item=booked_row} - - - - - - {/foreach} -
{l s='Order ID'}{l s='Date From'}{l s='Date To'}
- #{$booked_row->id_order|intval} - {dateFormat date=$booked_row->date_from}{dateFormat date=$booked_row->date_to}
+{l s='This room already has a booking for the selected date range.'} +
+
+ {l s='Order ID:'} #{$orderDetails->id_order|intval} +
+
+ {l s='Date From:'} {dateFormat date=$orderDetails->date_from} +
+
+ {l s='Date To:'} {dateFormat date=$orderDetails->date_to} +
+
+
+
diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index cbb7eaa65..cf572be7c 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -177,49 +177,81 @@ {*Disable Dates Model*} +{* needs some design*} + - diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d9f71e63c..73305a92f 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2975,34 +2975,8 @@ class AdminProductsControllerCore extends AdminController $room['booked_dates'] = json_encode($bookedDates); if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) { - if ($disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id'])) { - foreach ($disabledDates as $disabledDatesKey => $dates) { - // To display the disabled dates events with date_to as inclusive in the full calendar - $disabledDates[$disabledDatesKey]['date_to'] = date('Y-m-d', strtotime($dates['date_to'])); - $disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add'])); - if (!isset($dates['id_external_event'])) { - $disabledDates[$disabledDatesKey]['id_external_event'] = 0; - } - - if (!isset($dates['is_editable'])) { - $disabledDates[$disabledDatesKey]['is_editable'] = 1; - } - - if (!isset($dates['is_deletable'])) { - $disabledDates[$disabledDatesKey]['is_deletable'] = 1; - } - - if (!isset($dates['event_title'])) { - $disabledDates[$disabledDatesKey]['event_title'] = 0; - } - - if (!isset($dates['external_event_url'])) { - $disabledDates[$disabledDatesKey]['external_event_url'] = 0; - } - } - } - - $room['disable_dates_json'] = json_encode($disabledDates); + $disableDates = $objRoomDisableDates->getRoomDisableDates($room['id']); + $room['disable_dates_json'] = json_encode($disableDates); } } $data->assign('htl_room_info', $hotelRoomInfo); @@ -5018,7 +4992,7 @@ class AdminProductsControllerCore extends AdminController $dateTo = Tools::getValue('date_to'); $idProduct = Tools::getValue('id_product'); if (!Validate::isDate($dateFrom) || !Validate::isDate($dateTo)) { - $this->errors[] = $this->l('Please select the date range during which the room will be disabled.'); + $this->errors[] = $this->l('Please select valid date range to temporary disable this room'); } else if ($idRoom && Validate::isLoadedObject($objHotelRoomInfo = new HotelRoomInformation((int) $idRoom))) { $dateTo = date('Y-m-d', strtotime($dateTo)); $objHotelBookingDetail = new HotelBookingDetail(); @@ -5031,8 +5005,8 @@ class AdminProductsControllerCore extends AdminController $this->errors[] = $this->context->smarty->fetch('controllers/products/booked_room_date_ranges_list.tpl'); } else { - if (!Tools::getValue('id_disabled_date') - || !Validate::isLoadedObject($objHotelRoomDisableDates = new HotelRoomDisableDates((int) Tools::getValue('id_disabled_date'))) + if (!Tools::getValue('id_disable_date') + || !Validate::isLoadedObject($objHotelRoomDisableDates = new HotelRoomDisableDates((int) Tools::getValue('id_disable_date'))) ) { $objHotelRoomDisableDates = new HotelRoomDisableDates(); $objHotelRoomDisableDates->id_room_type = $idProduct; @@ -5046,11 +5020,11 @@ class AdminProductsControllerCore extends AdminController if ($objHotelRoomInfo->save() && $objHotelRoomDisableDates->save() ) { - $response['id_disabled_date'] = $objHotelRoomDisableDates->id; - if (Tools::getValue('id_disabled_date')) { + $response['id_disable_date'] = $objHotelRoomDisableDates->id; + if (Tools::getValue('id_disable_date')) { $this->confirmations[] = $this->l('Successfully updated.'); } else { - $this->confirmations[] = $this->l('Room disabled successfully for the specified date range.'); + $this->confirmations[] = $this->l('Disable date added successfully.'); } } else { $this->errors[] = Tools::displayError('An error occurred while trying to save the disable dates.'); @@ -5073,14 +5047,14 @@ class AdminProductsControllerCore extends AdminController $this->ajaxDie(json_encode($response)); } - public function ajaxProcessRemoveSelectedDate() + public function ajaxProcessRemoveDisableDatesInDateRange() { $response = array('status' => false); $idRoom = (int) Tools::getValue('id_room'); $dateFrom = date('Y-m-d', strtotime(Tools::getValue('date_from'))); $dateTo = date('Y-m-d', strtotime(Tools::getValue('date_to'))); if (!Tools::getValue('date_from') || !Tools::getValue('date_to')) { - $this->errors[] = Tools::displayError('Please select the date range to enable the room.'); + $this->errors[] = Tools::displayError('Please select valid date range.'); } else { $objRoomDisableDates = new HotelRoomDisableDates(); $params = array( @@ -5088,18 +5062,18 @@ class AdminProductsControllerCore extends AdminController 'date_to' => $dateTo, 'id_room' => $idRoom ); - Hook::exec('actionRoomDisabledDatesRemoveBefore', array('disabled_dates', $params)); + Hook::exec('actionRoomDisableDatesRemoveBefore', array('disable_dates', $params)); if (empty($this->errors) - && ($disabledDates = $objRoomDisableDates->checkIfRoomAlreadyDisabled($params)) + && ($disableDates = $objRoomDisableDates->checkIfRoomAlreadyDisabled($params)) ) { $newDates = array(); - foreach ($disabledDates as $disabledDatesInfo) { - $objRoomDisableDates = new HotelRoomDisableDates($disabledDatesInfo['id']); - $newDates[0]['date_from'] = $disabledDatesInfo['date_from']; + foreach ($disableDates as $disableDatesInfo) { + $objRoomDisableDates = new HotelRoomDisableDates($disableDatesInfo['id']); + $newDates[0]['date_from'] = $disableDatesInfo['date_from']; $newDates[0]['date_to'] = $params['date_from']; $newDates[1]['date_from'] = $params['date_to']; - $newDates[1]['date_to'] = date('Y-m-d', strtotime($disabledDatesInfo['date_to'])); + $newDates[1]['date_to'] = date('Y-m-d', strtotime($disableDatesInfo['date_to'])); if (strtotime($newDates[0]['date_from']) >= strtotime($newDates[0]['date_to'])) { unset($newDates[0]); @@ -5110,18 +5084,18 @@ class AdminProductsControllerCore extends AdminController } foreach ($newDates as $newDate) { - $objNewDisabledDates = new HotelRoomDisableDates(); - $objNewDisabledDates->id_room_type = $objRoomDisableDates->id_room_type; - $objNewDisabledDates->id_room = $objRoomDisableDates->id_room; - $objNewDisabledDates->date_from = $newDate['date_from']; - $objNewDisabledDates->date_to = $newDate['date_to']; - $objNewDisabledDates->reason = $objRoomDisableDates->reason; - $objNewDisabledDates->save(); + $objNewDisableDates = new HotelRoomDisableDates(); + $objNewDisableDates->id_room_type = $objRoomDisableDates->id_room_type; + $objNewDisableDates->id_room = $objRoomDisableDates->id_room; + $objNewDisableDates->date_from = $newDate['date_from']; + $objNewDisableDates->date_to = $newDate['date_to']; + $objNewDisableDates->reason = $objRoomDisableDates->reason; + $objNewDisableDates->save(); } $objRoomDisableDates->delete(); } - } else if (!$disabledDates) { + } else if (!$disableDates) { $this->errors[] = Tools::displayError('Room is not disabled for the selected date range.'); } } @@ -5131,36 +5105,13 @@ class AdminProductsControllerCore extends AdminController } else { $response['status'] = true; $this->confirmations[] = $this->l('Removed successfully.'); - if ($disabledDates = $objRoomDisableDates->getRoomDisableDates($idRoom)) { - foreach ($disabledDates as $disabledDatesKey => $dates) { - $disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add'])); - if (!isset($dates['id_external_event'])) { - $disabledDates[$disabledDatesKey]['id_external_event'] = 0; - } - - if (!isset($dates['is_editable'])) { - $disabledDates[$disabledDatesKey]['is_editable'] = 1; - } - - if (!isset($dates['is_deletable'])) { - $disabledDates[$disabledDatesKey]['is_deletable'] = 1; - } - - if (!isset($dates['event_title'])) { - $disabledDates[$disabledDatesKey]['event_title'] = 0; - } - - if (!isset($dates['external_event_url'])) { - $disabledDates[$disabledDatesKey]['external_event_url'] = 0; - } - } - } else { + if (!($disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom))) { $objRoomInfo = new HotelRoomInformation($idRoom); $objRoomInfo->id_status = HotelRoomInformation::STATUS_ACTIVE; $objRoomInfo->save(); } - $response['disabled_dates'] = $disabledDates; + $response['disable_dates'] = $disableDates; } $this->assignAlerts(); @@ -5168,14 +5119,29 @@ class AdminProductsControllerCore extends AdminController $this->ajaxDie(json_encode($response)); } - public function ajaxProcessDeleteDisabledDate() + public function ajaxProcessGetDisableDates() + { + $response['status'] = false; + if (($idRoom = Tools::getValue('id_room')) + && Validate::isLoadedObject(new HotelRoomInformation($idRoom)) + ) { + $objRoomDisableDates = new HotelRoomDisableDates(); + $disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom); + $response['status'] = true; + $response['disable_dates'] = $disableDates; + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessDeleteDisableDate() { $response = array('status' => false); - $idDisabledDate = Tools::getValue('id_disabled_date'); - Hook::exec('actionDisabledDateDeleteBefore', array('id_disabled_date', $idDisabledDate)); + $idDisableDate = Tools::getValue('id_disable_date'); + Hook::exec('actionDisableDateDeleteBefore', array('id_disable_date', $idDisableDate)); if (empty($this->errors) - && (int) $idDisabledDate - && Validate::isLoadedObject($objRoomDisableDates = new HotelRoomDisableDates($idDisabledDate)) + && (int) $idDisableDate + && Validate::isLoadedObject($objRoomDisableDates = new HotelRoomDisableDates($idDisableDate)) ) { $idRoom = $objRoomDisableDates->id_room; if (!$objRoomDisableDates->delete()) { diff --git a/modules/hotelreservationsystem/classes/HotelRoomDisableDates.php b/modules/hotelreservationsystem/classes/HotelRoomDisableDates.php index e9a9d128a..cbbf71a31 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomDisableDates.php +++ b/modules/hotelreservationsystem/classes/HotelRoomDisableDates.php @@ -45,10 +45,14 @@ class HotelRoomDisableDates extends ObjectModel public function getRoomDisableDates($id_room) { - $disabledDates = Db::getInstance()->executeS('SELECT `id`, `date_from`, `date_to`, `reason`, `date_add` FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room`='.(int) $id_room); + $disabledDates = Db::getInstance()->executeS('SELECT `id`, `date_from`, `date_to`, `reason`, `date_add`, + NULL AS `id_event`, NULL AS `event_url`, NULL AS `event_title`, 1 AS `is_editable`, 1 AS `is_deletable` + FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room`='.(int) $id_room + ); + Hook::exec('actionRoomDisabledDatesModifier', array( - 'disabled_dates' => &$disabledDates, + 'disable_dates' => &$disabledDates, 'id_room' => $id_room ) ); From dcbe118dbd314f8c6ab4b87541204f0f774aa2a9 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 29 Aug 2024 18:05:31 +0530 Subject: [PATCH 07/14] fixed: issues in rtl design --- admin/themes/default/sass/partials/_rtl.sass | 4 ---- .../default/template/controllers/products/configuration.tpl | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/admin/themes/default/sass/partials/_rtl.sass b/admin/themes/default/sass/partials/_rtl.sass index 943869529..792fd4666 100644 --- a/admin/themes/default/sass/partials/_rtl.sass +++ b/admin/themes/default/sass/partials/_rtl.sass @@ -136,16 +136,12 @@ html border-right: 2px solid red !important padding-right: 10px !important padding-left: unset !important - .fc-event-title-container - direction: rtl !important .delete_disable_dates margin-left: unset !important margin-right: 10px .remove_disable_dates margin-right: 10px !important margin-left: 20px - .fc-toolbar > * > :not(:first-child) - margin-right: .75em .alert.alert-danger text-align: right !important .error_message_label diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index 0f4212b22..f741781e2 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -708,7 +708,7 @@ initialDate: '{date('Y-m-d', time())}', dayMaxEventRows: true, selectable: true, - direction:{if isset($language_is_rtl) && $language_is_rtl}'rlt'{else}'ltr'{/if}, + direction:{if isset($language_is_rtl) && $language_is_rtl}'rtl'{else}'ltr'{/if}, locale:{if isset($locale) && $locale}'{$locale}'{else}'en'{/if}, unselectAuto: true, eventTextColor: '#333333', From 676ccbb32a78631901ecb6369693ddc7993b18f3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 6 Sep 2024 18:38:05 +0530 Subject: [PATCH 08/14] Resolved Disable dates issues, optmized the code for the user experience, added event highlight on hover --- .../default/sass/controllers/_products.sass | 20 ++- admin/themes/default/sass/partials/_rtl.sass | 2 +- .../controllers/products/configuration.tpl | 155 +++++++++++------- controllers/admin/AdminProductsController.php | 1 + .../classes/HotelRoomDisableDates.php | 4 +- 5 files changed, 118 insertions(+), 64 deletions(-) diff --git a/admin/themes/default/sass/controllers/_products.sass b/admin/themes/default/sass/controllers/_products.sass index 2d98ca948..31db6e4e0 100644 --- a/admin/themes/default/sass/controllers/_products.sass +++ b/admin/themes/default/sass/controllers/_products.sass @@ -2,20 +2,32 @@ margin-left: 0px #deactiveDatesModal + .fc-event-end, .fc-event-start + margin-left: unset !important + margin-right: unset !important + .fc-popover.fc-more-popover + max-width: 450px .fc-daygrid-event box-shadow: 0px 1px 2px 0px rgba(171, 171, 171, 0.3) border-radius: 4px + .fc-daygrid-day-frame + min-height: 100px !important + .calendar_hover_highlight + border-color: #CAE4FF !important + background: #CAE4FF !important .fc-event-title-container + cursor: pointer padding: 4px .highlight-event-day background: #F5F5F5 - .event_title_container + .fc-event-title text-overflow: ellipsis white-space: nowrap max-width: 65% overflow: hidden - border-left: 2px solid red padding-left: 10px + .event_title_container, .fc-popover-body .fc-event-title + border-left: 2px solid red #disable_dates_form .date_from_container, .date_to_container .ui-datepicker @@ -67,6 +79,10 @@ border-radius: 6px padding: 5px 10px .tooltip_content + .tooltip_reason + word-wrap: break-word + max-height: 200px + overflow: auto .tooltip_reason_container, .id_event margin-top: 10px &> div diff --git a/admin/themes/default/sass/partials/_rtl.sass b/admin/themes/default/sass/partials/_rtl.sass index 792fd4666..c2e7a24bb 100644 --- a/admin/themes/default/sass/partials/_rtl.sass +++ b/admin/themes/default/sass/partials/_rtl.sass @@ -131,7 +131,7 @@ html .btn text-align: right !important padding-inline-start: unset - .event_title_container + .fc-event-title border-left: unset !important border-right: 2px solid red !important padding-right: 10px !important diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index f741781e2..c56f5c12b 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -355,12 +355,12 @@