From b63fed88e6d545857f7978fbf9ebca350cb2d106 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 30 Apr 2024 12:13:13 +0530 Subject: [PATCH 01/46] Updated: the saving process for the fields in the AdminCustomerThreads --- .../admin/AdminCustomerThreadsController.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index c7a52fc5e..64f02915f 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -165,7 +165,10 @@ class AdminCustomerThreadsControllerCore extends AdminController 'lang' => true ) ), - 'submit' => array('title' => $this->l('Save')) + 'submit' => array( + 'title' => $this->l('Save'), + 'name' => 'submitOptionsCustomerService' + ) ), 'general' => array( 'title' => $this->l('Customer service options'), @@ -232,7 +235,10 @@ class AdminCustomerThreadsControllerCore extends AdminController 'hint' => $this->l('Do not use start-TLS to encrypt the session, even with servers that support it.'), ), ), - 'submit' => array('title' => $this->l('Save')), + 'submit' => array( + 'title' => $this->l('Save'), + 'name' => 'submitOptionsIMAPConfig' + ), ), ); @@ -312,6 +318,17 @@ class AdminCustomerThreadsControllerCore extends AdminController public function postProcess() { + // using this to separate the saving process for the both option fields + $fields = $this->fields_options; + if (Tools::isSubmit('submitOptionsCustomerService')) { + unset($this->fields_options['general']); + $this->processUpdateOptions(); + } else if (Tools::isSubmit('submitOptionsIMAPConfig')) { + unset($this->fields_options['contact']); + $this->processUpdateOptions(); + } + + $this->fields_options = $fields; if ($id_customer_thread = (int)Tools::getValue('id_customer_thread')) { if (($id_contact = (int)Tools::getValue('id_contact'))) { Db::getInstance()->execute(' From 584eed90c28587849aad9c10a998ce6d60d0eeaf Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 10 Jul 2024 16:02:14 +0530 Subject: [PATCH 02/46] Added access wise permission on the IMAP edit process --- .../admin/AdminCustomerThreadsController.php | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 64f02915f..42abddf62 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -318,14 +318,20 @@ class AdminCustomerThreadsControllerCore extends AdminController public function postProcess() { - // using this to separate the saving process for the both option fields - $fields = $this->fields_options; - if (Tools::isSubmit('submitOptionsCustomerService')) { - unset($this->fields_options['general']); - $this->processUpdateOptions(); - } else if (Tools::isSubmit('submitOptionsIMAPConfig')) { - unset($this->fields_options['contact']); - $this->processUpdateOptions(); + if ($this->tabAccess['edit'] === '1') { + // using this to separate the saving process for the both option fields + $fields = $this->fields_options; + if (Tools::isSubmit('submitOptionsCustomerService')) { + unset($this->fields_options['general']); + $this->processUpdateOptions(); + } else if (Tools::isSubmit('submitOptionsIMAPConfig')) { + unset($this->fields_options['contact']); + $this->processUpdateOptions(); + } + + $this->fields_options = $fields; + } else { + $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } $this->fields_options = $fields; From 9343c2748819b0548d5d0e91a74897f86aadc142 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 10 Jul 2024 16:04:09 +0530 Subject: [PATCH 03/46] removed non required code from admin customer threads --- controllers/admin/AdminCustomerThreadsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 42abddf62..627a7b735 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -334,7 +334,6 @@ class AdminCustomerThreadsControllerCore extends AdminController $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } - $this->fields_options = $fields; if ($id_customer_thread = (int)Tools::getValue('id_customer_thread')) { if (($id_contact = (int)Tools::getValue('id_contact'))) { Db::getInstance()->execute(' From 38f075585d7c54fb8c41177cd74c1c6381f43dd3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 2 Aug 2024 12:42:49 +0530 Subject: [PATCH 04/46] 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 15/46] 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 0df9c3bf12b89400213d426295bca10daf4dbbbc Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 2 Sep 2024 15:23:31 +0530 Subject: [PATCH 16/46] optimize Availability and rates search API --- .../WebserviceSpecificManagementHotelAri.php | 79 ++++++++++++++++--- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php index bc4b33dce..084b97c3d 100644 --- a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php +++ b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php @@ -235,6 +235,11 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $dateWiseBreakdown = 1; $datesAriInfo = []; + $bookingParams['search_available'] = 1; + $bookingParams['search_booked'] = 1; + $bookingParams['search_partial'] = 1; + $bookingParams['search_unavai'] = 1; + $ariInfo = $objBookingDtl->getBookingData($bookingParams); $dateFrom = $bookingParams['date_from']; $dateTo = $bookingParams['date_to']; @@ -243,20 +248,73 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $dateBookingParams = $bookingParams; // for a single date there is no use of partial available rooms $dateBookingParams['search_partial'] = 0; + $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - for ($currentDate = $dateFrom; $currentDate < $dateTo; $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) { - $dateBookingParams['date_from'] = $currentDate; - $dateBookingParams['date_to'] = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))); + foreach ($ariInfo['rm_data'] as $key => $roomType) { + $rooms = HotelRoomInformation::getHotelRoomsInfo($ariParams['id_hotel'], $roomType['id_product']); + $ariInfo['rm_data'][$key]['all_rooms'] = array_map(function ($room) { return array('id_room' => $room['id'], 'room_number' => $room['room_num']); }, $rooms); + + } + for ($currentDate = $dateFrom; $currentDate < $dateTo; $currentDate = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate)))) { + // $dateBookingParams['date_from'] = $currentDate; + // $dateBookingParams['date_to'] = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))); // get inventories for every date - $ariInfo = $objBookingDtl->getBookingData($dateBookingParams); - // append request fields also. will be attached in the response xml - $ariInfo['id_hotel'] = $ariParams['id_hotel']; - $ariInfo['date_from'] = $dateBookingParams['date_from']; - $ariInfo['date_to'] = $dateBookingParams['date_to']; - $ariInfo['num_rooms'] = $totalRooms; + // $ariInfo = $objBookingDtl->getBookingData($dateBookingParams); - $searchAriData[] = $ariInfo; + // append request fields also. will be attached in the response xml + $ariDateInfo['id_hotel'] = $ariParams['id_hotel']; + $ariDateInfo['date_from'] = $currentDate; + $ariDateInfo['date_to'] = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))); + $ariDateInfo['currency'] = $objCurrency->iso_code; + $ariDateInfo['total_rooms'] = $totalRooms; + $ariDateInfo['total_available_rooms'] = $totalRooms; + $ariDateInfo['room_types'] = array(); + foreach ($ariInfo['rm_data'] as $roomType) + { + $rooms = array(); + $rooms['available'] = $roomType['all_rooms']; + foreach ($rooms['available'] as $roomKey => $room) { + if (isset($roomType['data']['booked'][$room['id_room']])) { + foreach ($roomType['data']['booked'][$room['id_room']]['detail'] as $bookedDetail) { + if ($bookedDetail['date_to'] > $ariDateInfo['date_from'] && $bookedDetail['date_from'] <= $ariDateInfo['date_to']) { + unset($rooms['available'][$roomKey]); + } + } + } + } + + $roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( + $roomTypeInfo['id_product'], + $ariInfo['date_from'], + $ariInfo['date_to'], + 0 + ); + + $roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( + $roomTypeInfo['id_product'], + $ariInfo['date_from'], + $ariInfo['date_to'], + 1 + ); + $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( + $roomTypeInfo['id_product'], + $ariInfo['date_from'], + $ariInfo['date_to'], + $ariInfo['num_rooms'] + ); + $ariDateInfo['room_types'][] = array( + 'id_room_type' => $roomType->id_product, + 'base_price' => $roomTypePriceTE, + 'base_price_with_tax' => $roomTypePriceTE, + 'total_price' => $totalBookingPrice['total_price_tax_excl'], + 'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'], + 'name' => $roomType->name, + 'rooms' => array() + ); + } + + $searchAriData[] = $ariDateInfo; } } else { // If api is called for getting ari info for a particular date range $dateWiseBreakdown = 0; @@ -272,6 +330,7 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $searchAriData[] = $ariInfo; } + ddd($searchAriData); // We have to create the json and xml response for request by ourself. So we need to check if data to be sent in xml or json // We have no way to check the output format from parent classed. So we used below code From a7fe0eeff3fd6c765c0687b6de8b4cfe67d36c94 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 4 Sep 2024 12:49:02 +0530 Subject: [PATCH 17/46] unset roomDetail variable to clear variable reference --- modules/hotelreservationsystem/classes/HotelBookingDetail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index e51d33789..bfb80f511 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1193,6 +1193,7 @@ class HotelBookingDetail extends ObjectModel } } unset($datetimeObj); + unset($roomDetail); // If all dates are covered if (!$datesToCover) { From ecdae4122f34cc776256a5c281ded2d4ac01cd56 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 5 Sep 2024 11:28:00 +0530 Subject: [PATCH 18/46] Optimized: HotelAri webservice --- .../WebserviceSpecificManagementHotelAri.php | 436 ++++++++---------- 1 file changed, 185 insertions(+), 251 deletions(-) diff --git a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php index 084b97c3d..8185acf93 100644 --- a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php +++ b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php @@ -227,90 +227,133 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser // now call the function $objBookingDtl = new HotelBookingDetail(); - $searchAriData = []; // If api is called for getting ari info for all the dates in the provided date range - if (isset($ariParams['date_wise_breakdown']) && $ariParams['date_wise_breakdown'] && $bookingParams['search_available']) { + if (isset($ariParams['date_wise_breakdown']) && $ariParams['date_wise_breakdown']) { $dateWiseBreakdown = 1; - $datesAriInfo = []; + /** + * To generate data for each day, we will need to get data for booked and unavailable dates, s + * so saving the booking_params for generating the response later + */ + $getavail = $bookingParams['search_available']; + $getBooked = $bookingParams['search_booked']; + $getUnavai = $bookingParams['search_unavai']; $bookingParams['search_available'] = 1; $bookingParams['search_booked'] = 1; - $bookingParams['search_partial'] = 1; $bookingParams['search_unavai'] = 1; - $ariInfo = $objBookingDtl->getBookingData($bookingParams); + $bookingData = $objBookingDtl->getBookingData($bookingParams); - $dateFrom = $bookingParams['date_from']; - $dateTo = $bookingParams['date_to']; - - // Lets get data date by date (Every date in the date range) - $dateBookingParams = $bookingParams; - // for a single date there is no use of partial available rooms - $dateBookingParams['search_partial'] = 0; $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - foreach ($ariInfo['rm_data'] as $key => $roomType) { - $rooms = HotelRoomInformation::getHotelRoomsInfo($ariParams['id_hotel'], $roomType['id_product']); - $ariInfo['rm_data'][$key]['all_rooms'] = array_map(function ($room) { return array('id_room' => $room['id'], 'room_number' => $room['room_num']); }, $rooms); - - } - for ($currentDate = $dateFrom; $currentDate < $dateTo; $currentDate = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate)))) { - // $dateBookingParams['date_from'] = $currentDate; - // $dateBookingParams['date_to'] = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))); - - // get inventories for every date - // $ariInfo = $objBookingDtl->getBookingData($dateBookingParams); - - // append request fields also. will be attached in the response xml - $ariDateInfo['id_hotel'] = $ariParams['id_hotel']; - $ariDateInfo['date_from'] = $currentDate; - $ariDateInfo['date_to'] = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))); - $ariDateInfo['currency'] = $objCurrency->iso_code; - $ariDateInfo['total_rooms'] = $totalRooms; - $ariDateInfo['total_available_rooms'] = $totalRooms; - $ariDateInfo['room_types'] = array(); - foreach ($ariInfo['rm_data'] as $roomType) - { - $rooms = array(); - $rooms['available'] = $roomType['all_rooms']; - foreach ($rooms['available'] as $roomKey => $room) { - if (isset($roomType['data']['booked'][$room['id_room']])) { - foreach ($roomType['data']['booked'][$room['id_room']]['detail'] as $bookedDetail) { - if ($bookedDetail['date_to'] > $ariDateInfo['date_from'] && $bookedDetail['date_from'] <= $ariDateInfo['date_to']) { - unset($rooms['available'][$roomKey]); + // saving date wise booked and unavailable rooms to manage available rooms calculation . + $bookedDates = array(); + $unavailableDates = array(); + foreach ($bookingData['rm_data'] as $key => $roomType) { + if ($rooms = HotelRoomInformation::getHotelRoomsInfo($ariParams['id_hotel'], $roomType['id_product'])) { + foreach ($rooms as $room) { + $bookingData['rm_data'][$key]['all_rooms'][$room['id']] = array('id_room' => $room['id'], 'room_number' => $room['room_num']); + } + if (count($roomType['data']['booked'])) { + foreach ($roomType['data']['booked'] as $bookedRoom) { + foreach ($bookedRoom['detail'] as $bookDetail) { + for ($currentDate = date('Y-m-d', strtotime($bookDetail['date_from'])); + $currentDate < date('Y-m-d', strtotime($bookDetail['date_to'])); + $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))) + ) { + $bookedDates[$currentDate][$roomType['id_product']][$bookedRoom['id_room']] = $bookedRoom['id_room']; } } } } + if (count($roomType['data']['unavailable'])) { + foreach ($roomType['data']['unavailable'] as $unavailableRooms) { + foreach ($unavailableRooms['detail'] as $unavailableDetail) { + for ($currentDate = date('Y-m-d', strtotime($unavailableDetail['date_from'])); + $currentDate < date('Y-m-d', strtotime($unavailableDetail['date_to'])); + $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))) + ) { + $unavailableDates[$currentDate][$roomType['id_product']][$bookedRoom['id_room']] = $bookedRoom['id_room']; + } + } + } + } + } + } + + // creating ari details for every date + for ($currentDate = $bookingParams['date_from']; $currentDate < $bookingParams['date_to']; $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) { + $nextDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate))); + // append request fields also. will be attached in the response xml + $ariDateInfo['id_hotel'] = $ariParams['id_hotel']; + $ariDateInfo['date_from'] = $currentDate; + $ariDateInfo['date_to'] = $nextDate; + $ariDateInfo['currency'] = $objCurrency->iso_code; + $ariDateInfo['total_rooms'] = 0; + $ariDateInfo['room_types'] = array(); + foreach ($bookingData['rm_data'] as $roomType) + { + if (count($roomType['all_rooms'])) { + $ariDateInfo['total_rooms'] += count($roomType['all_rooms']); + $roomDetail = array(); + + $roomDetail['available'] = $roomType['all_rooms']; + if (isset($bookedDates[$currentDate][$roomType['id_product']])) { + $roomDetail['available'] = array_diff_key($roomDetail['available'], $bookedDates[$currentDate][$roomType['id_product']]); + $roomDetail['booked'] = array_intersect_key($roomType['all_rooms'], $bookedDates[$currentDate][$roomType['id_product']]); + } else { + $roomDetail['booked'] = array(); + } + if (isset($unavailableDates[$currentDate][$roomType['id_product']])) { + $roomDetail['available'] = array_diff_key($roomDetail['available'], $unavailableDates[$currentDate][$roomType['id_product']]); + $roomDetail['unavailable'] = array_intersect_key($roomType['all_rooms'], $unavailableDates[$currentDate][$roomType['id_product']]); + } else { + $roomDetail['unavailable'] = array(); + } + if ($getavail) { + $ariDateInfo[''] += count($roomDetail['available']); + } else { + unset($roomDetail['available']); + } + if ($getUnavai) { + $ariDateInfo['total_unavailable_rooms'] += count($roomDetail['available']); + } else { + unset($roomDetail['unavailable']); + } + if ($getBooked) { + $ariDateInfo['total_booked_rooms'] += count($roomDetail['available']); + } else { + unset($roomDetail['booked']); + } + } $roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), 0 ); - $roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), 1 ); $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - $ariInfo['num_rooms'] + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), + $totalRooms ); $ariDateInfo['room_types'][] = array( - 'id_room_type' => $roomType->id_product, + 'id_room_type' => $roomType['id_product'], 'base_price' => $roomTypePriceTE, - 'base_price_with_tax' => $roomTypePriceTE, + 'base_price_with_tax' => $roomTypePriceTI, 'total_price' => $totalBookingPrice['total_price_tax_excl'], 'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'], - 'name' => $roomType->name, - 'rooms' => array() + 'name' => $roomType['name'], + 'rooms' => $roomDetail ); } @@ -320,17 +363,59 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $dateWiseBreakdown = 0; // If api is called for getting ari info for a particular date range - $ariInfo = $objBookingDtl->getBookingData($bookingParams); - + $bookingData = $objBookingDtl->getBookingData($bookingParams); // append request fields also. will be attached in the response xml + $ariInfo = array(); $ariInfo['id_hotel'] = $ariParams['id_hotel']; $ariInfo['date_from'] = $bookingParams['date_from']; $ariInfo['date_to'] = $bookingParams['date_to']; - $ariInfo['num_rooms'] = $totalRooms; + $ariInfo['currency'] = $objCurrency->iso_code; + $ariInfo['total_rooms'] = $bookingData['stats']['total_rooms']; + if (isset($bookingData['stats']['num_avail'])) { + $ariInfo['total_available_rooms'] = $bookingData['stats']['num_avail']; + } + if (isset($bookingData['stats']['num_unavail'])) { + $ariInfo['total_unavailable_rooms'] = $bookingData['stats']['num_unavail']; + } + if (isset($bookingData['stats']['num_part_avai'])) { + $ariInfo['total_partial_available_rooms'] = $bookingData['stats']['num_part_avai']; + } + if (isset($bookingData['stats']['num_booked'])) { + $ariInfo['total_booked_rooms'] = $bookingData['stats']['num_booked']; + } + $ariInfo['room_types'] = array(); + foreach ($bookingData['rm_data'] as $roomType) { + $roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), + 0 + ); + $roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), + 1 + ); + $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( + $roomType['id_product'], + $currentDate, + date('Y-m-d H:i:s', strtotime('+1 day', strtotime($currentDate))), + $totalRooms + ); + $ariInfo['room_types'][] = array( + 'id_room_type' => $roomType['id_product'], + 'base_price' => $roomTypePriceTE, + 'base_price_with_tax' => $roomTypePriceTI, + 'total_price' => $totalBookingPrice['total_price_tax_excl'], + 'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'], + 'name' => $roomType['name'], + 'rooms' => $roomType['data'] + ); + } $searchAriData[] = $ariInfo; } - ddd($searchAriData); // We have to create the json and xml response for request by ourself. So we need to check if data to be sent in xml or json // We have no way to check the output format from parent classed. So we used below code @@ -509,92 +594,70 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $field = array('sqlId' => 'date_to', 'value' => $ariInfo['date_to']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - $field = array('sqlId' => 'currency', 'value' => $objCurrency->iso_code); + $field = array('sqlId' => 'currency', 'value' => $ariInfo['currency']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - // check if availability stats are available then only process further - if (isset($ariInfo['stats']) && $ariInfo['stats']) { - $field = array('sqlId' => 'total_rooms', 'value' => $ariInfo['stats']['total_rooms']); + $field = array('sqlId' => 'total_rooms', 'value' => $ariInfo['total_rooms']); + $this->output .= $this->objOutput->getObjectRender()->renderField($field); + + if (isset($ariInfo['total_available_rooms'])) { + $field = array('sqlId' => 'total_available_rooms', 'value' => $ariInfo['total_available_rooms']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); + } - if (isset($ariInfo['stats']['num_avail'])) { - $field = array('sqlId' => 'total_available_rooms', 'value' => $ariInfo['stats']['num_avail']); - $this->output .= $this->objOutput->getObjectRender()->renderField($field); - } + if (isset($ariInfo['total_unavailable_rooms'])) { + $field = array('sqlId' => 'total_unavailable_rooms', 'value' => $ariInfo['total_unavailable_rooms']); + $this->output .= $this->objOutput->getObjectRender()->renderField($field); + } - if (isset($ariInfo['stats']['num_unavail'])) { - $field = array('sqlId' => 'total_unavailable_rooms', 'value' => $ariInfo['stats']['num_unavail']); - $this->output .= $this->objOutput->getObjectRender()->renderField($field); - } + if (isset($ariInfo['total_partial_available_rooms'])) { + $field = array('sqlId' => 'total_partial_available_rooms', 'value' => $ariInfo['total_partial_available_rooms']); + $this->output .= $this->objOutput->getObjectRender()->renderField($field); + } - if (isset($ariInfo['stats']['num_part_avai'])) { - $field = array('sqlId' => 'total_partial_available_rooms', 'value' => $ariInfo['stats']['num_part_avai']); - $this->output .= $this->objOutput->getObjectRender()->renderField($field); - } - - if (isset($ariInfo['stats']['num_booked'])) { - $field = array('sqlId' => 'total_booked_rooms', 'value' => $ariInfo['stats']['num_booked']); - $this->output .= $this->objOutput->getObjectRender()->renderField($field); - } + if (isset($ariInfo['total_booked_rooms'])) { + $field = array('sqlId' => 'total_booked_rooms', 'value' => $ariInfo['total_booked_rooms']); + $this->output .= $this->objOutput->getObjectRender()->renderField($field); } // check if room type data is available then only process further - if (isset($ariInfo['rm_data']) && $ariInfo['rm_data']) { + if (isset($ariInfo['room_types']) && $ariInfo['room_types']) { $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_types', array()); - foreach ($ariInfo['rm_data'] as $roomTypeInfo) { - $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_type', array(), array('id' => $roomTypeInfo['id_product'], 'xlink_resource' => $this->wsObject->wsUrl.'room_types'.'/'.$roomTypeInfo['id_product'])); + foreach ($ariInfo['room_types'] as $roomTypeInfo) { + $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('room_type', array(), array( + 'id' => $roomTypeInfo['id_product'], + 'xlink_resource' => $this->wsObject->wsUrl.'room_types'.'/'.$roomTypeInfo['id_product'] + )); - $field = array('sqlId' => 'id_room_type', 'value' => $roomTypeInfo['id_product'], 'xlink_resource' => 'room_types'); + $field = array('sqlId' => 'id_room_type', 'value' => $roomTypeInfo['id_room_type'], 'xlink_resource' => 'room_types'); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - // get feature price of room type - $roomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - 0 - ); - $field = array('sqlId' => 'base_price', 'value' => $roomTypePrice); + $field = array('sqlId' => 'base_price', 'value' => $roomTypeInfo['base_price']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - // get feature price of room type - $roomTypePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - 1 - ); - $field = array('sqlId' => 'base_price_with_tax', 'value' => $roomTypePrice); + $field = array('sqlId' => 'base_price_with_tax', 'value' => $roomTypeInfo['base_price_with_tax']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - $ariInfo['num_rooms'] - ); - $field = array('sqlId' => 'total_price', 'value' => $totalBookingPrice['total_price_tax_excl']); + $field = array('sqlId' => 'total_price', 'value' => $roomTypeInfo['total_price']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - $ariInfo['num_rooms'] - ); - $field = array('sqlId' => 'total_price_with_tax', 'value' => $totalBookingPrice['total_price_tax_incl']); + $field = array('sqlId' => 'total_price_with_tax', 'value' => $roomTypeInfo['total_price_with_tax']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - $objRoomType = new Product($roomTypeInfo['id_product']); + $objRoomType = new Product($roomTypeInfo['id_room_type']); $field = array('sqlId' => 'name', 'value' => $objRoomType->name, 'i18n' => true); $this->output .= $this->objOutput->getObjectRender()->renderField($field); // rooms info of the room type - if (isset($roomTypeInfo['data']) && $roomTypeInfo['data']) { + if ($dateWiseBreakdown) { + $roomTypeKey = 'rooms'; + } else { + $roomTypeKey = 'data'; + } + if (isset($roomTypeInfo['rooms']) && $roomTypeInfo['rooms']) { $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('rooms', array()); - foreach ($roomTypeInfo['data'] as $key => $roomsInfo) { + foreach ($roomTypeInfo['rooms'] as $key => $roomsInfo) { if ($key == 'available') { $nodeRoomAvailability = 'available'; } elseif ($key == 'unavailable') { @@ -635,7 +698,7 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser $field = array('sqlId' => 'id_room', 'value' => $roomInfo['id_room']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); - $field = array('sqlId' => 'room_number', 'value' => $roomInfo['room_num']); + $field = array('sqlId' => 'room_number', 'value' => $roomInfo['room_number']); $this->output .= $this->objOutput->getObjectRender()->renderField($field); $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('room', array()); @@ -673,141 +736,12 @@ class WebserviceSpecificManagementHotelAri extends ObjectModel implements Webser // create json for the response of the ari request private function getResponseJson($ariInfoArray, $dateWiseBreakdown = 0) { - $ariFormatted = array(); - if ($ariInfoArray) { - foreach ($ariInfoArray as $ariInfo) { - $dateAriInfo = array(); - $dateAriInfo = array(); - $dateAriInfo['id_hotel'] = $ariInfo['id_hotel']; - $dateAriInfo['date_from'] = $ariInfo['date_from']; - $dateAriInfo['date_to'] = $ariInfo['date_to']; - - $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - $dateAriInfo['currency'] = $objCurrency->iso_code; - - // check if availability stats are available then only process further - if (isset($ariInfo['stats']) && $ariInfo['stats']) { - $dateAriInfo['total_rooms'] = $ariInfo['stats']['total_rooms']; - if (isset($ariInfo['stats']['num_avail'])) { - $dateAriInfo['total_available_rooms'] = $ariInfo['stats']['num_avail']; - } - if (isset($ariInfo['stats']['num_unavail'])) { - $dateAriInfo['total_unavailable_rooms'] = $ariInfo['stats']['num_unavail']; - } - if (isset($ariInfo['stats']['num_part_avai'])) { - $dateAriInfo['total_partial_available_rooms'] = $ariInfo['stats']['num_part_avai']; - } - if (isset($ariInfo['stats']['num_booked'])) { - $dateAriInfo['total_booked_rooms'] = $ariInfo['stats']['num_booked']; - } - } - - // check if room type data is available then only process further - if (isset($ariInfo['rm_data']) && $ariInfo['rm_data']) { - $dateAriInfo['room_types'] = array(); - - foreach ($ariInfo['rm_data'] as $roomTypeIndex => $roomTypeInfo) { - // get feature price of room type - $roomTypePriceTE = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - 0 - ); - $roomTypePriceTI = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - 1 - ); - $totalBookingPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( - $roomTypeInfo['id_product'], - $ariInfo['date_from'], - $ariInfo['date_to'], - $ariInfo['num_rooms'] - ); - - $dateAriInfo['room_types'][$roomTypeIndex] = array( - 'id_room_type' => $roomTypeInfo['id_product'], - 'base_price' => $roomTypePriceTE, - 'base_price_with_tax' => $roomTypePriceTI, - 'total_price' => $totalBookingPrice['total_price_tax_excl'], - 'total_price_with_tax' => $totalBookingPrice['total_price_tax_incl'] - ); - - $objRoomType = new Product($roomTypeInfo['id_product']); - $dateAriInfo['room_types'][$roomTypeIndex]['name'] = array(); - foreach ($this->objOutput->getObjectRender()->languages as $idLang) { - $dateAriInfo['room_types'][$roomTypeIndex]['name'][] = array( - 'id' => $idLang, - 'value' => $objRoomType->name[$idLang] - ); - } - // if only one lang than do not set name as array and set only value of the room - if (count($dateAriInfo['room_types'][$roomTypeIndex]['name']) == 1) { - $dateAriInfo['room_types'][$roomTypeIndex]['name'] = $dateAriInfo['room_types'][$roomTypeIndex]['name'][0]['value']; - } - - // rooms info of the room type - if (isset($roomTypeInfo['data']) && $roomTypeInfo['data']) { - $dateAriInfo['room_types'][$roomTypeIndex]['rooms'] = array(); - - foreach ($roomTypeInfo['data'] as $key => $roomsInfo) { - $roomsAriInfo = array(); - if ($key == 'available') { - $keyRoomAvailability = 'available'; - } elseif ($key == 'unavailable') { - $keyRoomAvailability = 'unavailable'; - } elseif ($key == 'booked') { - $keyRoomAvailability = 'booked'; - } elseif ($key == 'partially_available') { - $keyRoomAvailability = 'partially_available'; - } - - if ($roomsInfo) { - if ($key == 'partially_available') { - foreach ($roomsInfo as $dateIndex => $partialRoomsInfo) { - if (isset($partialRoomsInfo['rooms']) && $partialRoomsInfo['rooms']) { - $roomsAriInfo[$dateIndex]['date_from'] = $partialRoomsInfo['date_from']; - $roomsAriInfo[$dateIndex]['date_to'] = $partialRoomsInfo['date_to']; - - $roomsAriInfo[$dateIndex]['rooms'] = array(); - foreach ($partialRoomsInfo['rooms'] as $roomInfo) { - $roomDetail = array(); - $roomDetail['id_room'] = $roomInfo['id_room']; - $roomDetail['room_number'] = $roomInfo['room_num']; - - $roomsAriInfo[$dateIndex]['rooms'][] = $roomDetail; - } - } - } - } else { - foreach ($roomsInfo as $roomIndex => $roomInfo) { - $roomsAriInfo[$roomIndex]['id_room'] = $roomInfo['id_room']; - $roomsAriInfo[$roomIndex]['room_number'] = $roomInfo['room_num']; - } - } - } - - $dateAriInfo['room_types'][$roomTypeIndex]['rooms'][$keyRoomAvailability] = array_values($roomsAriInfo); - } - } - - $dateAriInfo['room_types'] = array_values($dateAriInfo['room_types']); - } - } - - $ariFormatted[] = $dateAriInfo; - } - } - - // change the content to the json form for api response $ariReponse = []; if ($dateWiseBreakdown) { // if date wise breakup is requested the parent node will be 'hotel_aris' as per other APIs in QloApps (orders > order) - $ariReponse['hotel_aris'] = array_values($ariFormatted); + $ariReponse['hotel_aris'] = array_values($ariInfoArray); } else { - $ariReponse['hotel_ari'] = $ariFormatted[0]; + $ariReponse['hotel_ari'] = $ariInfoArray[0]; } $this->output .= json_encode($ariReponse); From d5ed2b1110d2eb956119b3175029f7ca50b58564 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Thu, 5 Sep 2024 14:49:51 +0530 Subject: [PATCH 19/46] Updated: Price Rounding process improved in entire QloApps system and Issues in pricing in tables and order edit and reallocation process fixed --- .../controllers/orders/_product_line.tpl | 2 +- ..._extra_services_facilities_tab_content.tpl | 4 +- .../products/additionalfacilities.tpl | 4 +- classes/Cart.php | 190 ++---- classes/PaymentModule.php | 20 +- classes/Tools.php | 21 + classes/order/Order.php | 16 +- classes/order/OrderDetail.php | 18 +- classes/order/OrderSlip.php | 61 +- controllers/admin/AdminCartsController.php | 12 +- controllers/admin/AdminOrdersController.php | 622 +++++++++--------- controllers/front/OrderOpcController.php | 11 +- install/data/xml/configuration.xml | 2 +- .../classes/HotelBookingDemands.php | 51 +- .../classes/HotelBookingDetail.php | 212 +++--- .../classes/HotelCartBookingData.php | 29 +- .../classes/HotelRoomTypeDemandPrice.php | 5 +- .../classes/HotelRoomTypeFeaturePricing.php | 9 +- .../classes/RoomTypeServiceProduct.php | 1 + .../RoomTypeServiceProductCartDetail.php | 258 ++------ .../classes/RoomTypeServiceProductPrice.php | 2 +- .../AdminHotelRoomsBookingController.php | 17 +- .../helpers/view/_partials/booking-rooms.tpl | 2 +- pdf/order-slip.product-tab.tpl | 12 +- 24 files changed, 726 insertions(+), 855 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_product_line.tpl b/admin/themes/default/template/controllers/orders/_product_line.tpl index 453398fd0..c697a8b6f 100644 --- a/admin/themes/default/template/controllers/orders/_product_line.tpl +++ b/admin/themes/default/template/controllers/orders/_product_line.tpl @@ -124,7 +124,7 @@