From 6a29d0bdb125ef79f83adc1039ef51ba87773b89 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Thu, 23 May 2024 16:46:53 +0530 Subject: [PATCH 01/27] Fixed: After check-out, it is showing occupied in the occupancy chart in dashboard for checkout date --- controllers/admin/AdminStatsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 2de11a362..97fcfc65a 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1140,7 +1140,7 @@ class AdminStatsControllerCore extends AdminStatsTabController ON (p.`id_product` = hri.`id_product`) WHERE p.`active` = 1 AND hbd.`is_refunded` = 0 - AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'. + AND IF(hbd.`id_status` = '. HotelBookingDetail::STATUS_CHECKED_OUT .', hbd.`date_from` < DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d") AND hbd.`date_from` < \''.pSQL($dateTo).'\' AND DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d") > \''.pSQL($dateFrom).'\', hbd.`date_from` < \''.pSQL($dateTo).'\' AND hbd.`date_to` > \''.pSQL($dateFrom).'\')'. HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd') ); From b458aee50abc83cfcd4b69f4f9ca6627689b2917 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Mon, 27 May 2024 17:44:23 +0530 Subject: [PATCH 02/27] Fixed:After disabling the demo option, demo data is still showing in the room nights graph until page reload. --- controllers/admin/AdminStatsController.php | 2 +- modules/dashinsights/views/js/dashinsights.js | 3 +-- .../views/templates/hook/dashboard_zone_two.tpl | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 97fcfc65a..917d5b3e1 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1232,7 +1232,7 @@ class AdminStatsControllerCore extends AdminStatsTabController return $averageDailyRates; } - // Average Daily Rate is the average income per paid occupied room in a given time period + // Average Daily Rate is the average income per occupied room in a given time period public static function getAverageDailyRate($dateFrom, $dateTo, $idHotel = null) { $roomsRevenueByDates = self::getRoomsRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel); diff --git a/modules/dashinsights/views/js/dashinsights.js b/modules/dashinsights/views/js/dashinsights.js index c4c065975..feb98d0d1 100644 --- a/modules/dashinsights/views/js/dashinsights.js +++ b/modules/dashinsights/views/js/dashinsights.js @@ -21,7 +21,6 @@ function line_chart_dashinsights(widget_name, chart_details) { $('#dashinsights_room_nights svg').html(''); nv.addGraph(function () { var chart = nv.models.lineChart() - .useInteractiveGuideline(true) .x(function (d) { return (d !== undefined ? d[0] : 0); }) .y(function (d) { return (d !== undefined ? d[1] : 0); }) .forceY([0, 1]) @@ -32,7 +31,7 @@ function line_chart_dashinsights(widget_name, chart_details) { chart.yAxis.scale().domain([0, 1]); // create content for the tooltip of chart - chart.interactiveLayer.tooltip.contentGenerator((obj, element) => { + chart.tooltip.contentGenerator((obj, element) => { var totalNightsBooked = 0; var tooltipContent = ''; diff --git a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl index 97b3051de..fc59ed294 100644 --- a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl @@ -30,7 +30,7 @@
-
+

{l s='Average Daily Rate' mod='dashperformance'}

From 32168b44e14e73c1604dca9dd79b1857c94c2126 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Mon, 27 May 2024 18:01:13 +0530 Subject: [PATCH 03/27] Fixed: In Dashinsight:Room Nights line graphs fail to scale y axis to max values --- modules/dashinsights/views/js/dashinsights.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dashinsights/views/js/dashinsights.js b/modules/dashinsights/views/js/dashinsights.js index feb98d0d1..7cdfb2d66 100644 --- a/modules/dashinsights/views/js/dashinsights.js +++ b/modules/dashinsights/views/js/dashinsights.js @@ -22,7 +22,7 @@ function line_chart_dashinsights(widget_name, chart_details) { nv.addGraph(function () { var chart = nv.models.lineChart() .x(function (d) { return (d !== undefined ? d[0] : 0); }) - .y(function (d) { return (d !== undefined ? d[1] : 0); }) + .y(function (d) { return (d !== undefined ? parseInt(d[1]) : 0); }) .forceY([0, 1]) .margin({ left: 40, From 0655785564650fca621a381cfe54e5db3f346916 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Tue, 28 May 2024 13:41:34 +0530 Subject: [PATCH 04/27] FIxed:Traffic visits in the activity overview increment if the customer logs in and logs out multiple times --- classes/Guest.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/classes/Guest.php b/classes/Guest.php index 15a71165c..2ec8ebbef 100644 --- a/classes/Guest.php +++ b/classes/Guest.php @@ -173,9 +173,18 @@ class GuestCore extends ObjectModel public function mergeWithCustomer($idGuest, $idCustomer) { // Since the guests are merged, the guest id in the connections table must be changed too - Db::getInstance()->update('connections', [ - 'id_guest' => (int) $idGuest, - ], 'id_guest = ' . (int) $this->id); + // If guest entry is already there in the connection within 30 mins then delete the visitor entry else update it with guest id of the customer + + $sql = 'SELECT SQL_NO_CACHE `id_guest` FROM `'._DB_PREFIX_.'connections` + WHERE `id_guest` = '.(int)$idGuest.' AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\''. + Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `date_add` DESC'; + if (Db::getInstance()->getRow($sql, false)) { + Db::getInstance()->delete('connections', 'id_guest = ' . (int) $this->id); + } else { + Db::getInstance()->update('connections', [ + 'id_guest' => (int) $idGuest, + ], 'id_guest = ' . (int) $this->id); + } // Since the guests are merged, the guest id in the cart table must be changed too Db::getInstance()->update('cart', [ From 572ab9c2d5d69845a40f26b74f199b75174202af Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Tue, 28 May 2024 14:50:59 +0530 Subject: [PATCH 05/27] Fixed: Filtered data is not correct for the links under Currently Pending section in dashboard. --- controllers/admin/AdminOrdersController.php | 6 ++++++ .../views/templates/hook/dashboard_zone_one.tpl | 6 +++--- .../admin/AdminOrderRefundRequestsController.php | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index c08b5f111..ca1a817f7 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -102,6 +102,12 @@ class AdminOrdersControllerCore extends AdminController } elseif (Tools::getValue('orders_stay_over')) { $this->_where .= ' AND hbd.`is_refunded` = 0 AND hbd.`is_back_order` = 0 AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.' AND hbd.`date_to` > \''.pSQL(date('Y-m-d')).' 00:00:00\''; + } elseif (Tools::getValue('orders_not_paid')) { + $this->_where .= ' AND os.`paid` = 0 AND a.`current_state` NOT IN ('.implode(',', array( + Configuration::get('PS_OS_CANCELED'), + Configuration::get('PS_OS_REFUND'), + Configuration::get('PS_OS_ERROR') + )).')'; } $this->_orderBy = 'id_order'; diff --git a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl index 95cee2cd3..7d4675f50 100644 --- a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl +++ b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl @@ -79,7 +79,7 @@
  • - + {l s="Bookings (not paid)" mod='dashactivity'} @@ -89,7 +89,7 @@
  • - + {l s="Refunds" mod='dashactivity'} @@ -99,7 +99,7 @@
  • - + {l s="Abandoned Carts" mod='dashactivity'} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index fa74ab46a..7799f70af 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -38,6 +38,11 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $this->_orderWay = 'DESC'; $this->_group = 'GROUP BY ord.`id_order`'; + // filter pending refund requests + if (Tools::getValue('action') == 'filterPendingRequests') { + $this->_filterHaving = ' AND `total_pending_requests` > 0'; + } + $orderStatuses = OrderState::getOrderStates($this->context->language->id); $ordStatuses = array(); foreach ($orderStatuses as $status) { From 00c4deb9ff52d52f91cdd4b6b4fc55a100c6d78c Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Tue, 28 May 2024 16:09:32 +0530 Subject: [PATCH 06/27] Validation messages are improved for invalid date selection of the dates from calendar in admin dashboard --- controllers/admin/AdminDashboardController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index 11ffe69e6..1fc4a45ae 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -295,9 +295,12 @@ class AdminDashboardControllerCore extends AdminController public function postProcess() { if (Tools::isSubmit('submitDateRange')) { - if (!Validate::isDate(Tools::getValue('date_from')) - || !Validate::isDate(Tools::getValue('date_to'))) { + if (!Validate::isDate(Tools::getValue('date_from')) && !Validate::isDate(Tools::getValue('date_to'))) { $this->errors[] = Tools::displayError('The selected date range is not valid.'); + } elseif (!Validate::isDate(Tools::getValue('date_from'))) { + $this->errors[] = Tools::displayError('Date from in not selected. Please select a date range from the calendar.'); + } elseif (!Validate::isDate(Tools::getValue('date_to'))) { + $this->errors[] = Tools::displayError('Date to in not selected. Please select a date range from the calendar.'); } if (Tools::getValue('datepicker_compare')) { From 054005294027dd581261d7a6599696a511f64c26 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Wed, 29 May 2024 11:44:21 +0530 Subject: [PATCH 07/27] Fixed:If pending refund requests are more than 1 , then clicking on refunds redirects to the blank page. Change Abondant cart link also --- .../views/templates/hook/dashboard_zone_one.tpl | 2 +- .../admin/AdminOrderRefundRequestsController.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl index 7d4675f50..e78b1e692 100644 --- a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl +++ b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl @@ -89,7 +89,7 @@
  • - + {l s="Refunds" mod='dashactivity'} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 7799f70af..af9ee1d77 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -38,11 +38,6 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $this->_orderWay = 'DESC'; $this->_group = 'GROUP BY ord.`id_order`'; - // filter pending refund requests - if (Tools::getValue('action') == 'filterPendingRequests') { - $this->_filterHaving = ' AND `total_pending_requests` > 0'; - } - $orderStatuses = OrderState::getOrderStates($this->context->language->id); $ordStatuses = array(); foreach ($orderStatuses as $status) { @@ -78,6 +73,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController 'total_pending_requests' => array( 'title' => $this->l('Pending Requests'), 'align' => 'center', + 'type' => 'range', 'havingFilter' => true, ), ); From 574790a18c2ffb0a8fb67779e1dd991d595453bb Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Wed, 12 Jun 2024 15:38:46 +0530 Subject: [PATCH 08/27] Fixed:Net Profit amount on dashboard is not getting reduced until admin refund amount for all rooms available in the booking. --- controllers/admin/AdminStatsController.php | 40 ++++++++++++++++++++++ modules/dashtrends/dashtrends.php | 3 ++ 2 files changed, 43 insertions(+) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 83eb40591..0585557aa 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -516,6 +516,46 @@ class AdminStatsControllerCore extends AdminStatsTabController } } + public static function getRefunds($date_from, $date_to, $granularity = false, $id_hotel = 0) + { + if ($granularity == 'day') { + $refunds = array(); + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + SELECT + LEFT(`invoice_date`, 10) as date, + SUM(orr.`refunded_amount`) as total_refund_amount, + ( + SELECT hbd.`id_hotel` + FROM`'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_order` = o.`id_order` LIMIT 1 + ) AS id_hotel + FROM `'._DB_PREFIX_.'orders` o + LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (o.id_order = orr.id_order) + LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.current_state = os.id_order_state) + WHERE orr.`payment_mode` != "" AND orr.`id_transaction` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.' + GROUP BY LEFT(`invoice_date`, 10) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)); + + foreach ($result as $row) { + $refunds[strtotime($row['date'])] = $row['total_refund_amount']; + } + + return $refunds; + } else { + return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue( + 'SELECT SUM(orr.`refunded_amount`), + ( + SELECT hbd.`id_hotel` + FROM`'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_order` = o.`id_order` LIMIT 1 + ) AS id_hotel + FROM `'._DB_PREFIX_.'orders` o + LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (o.id_order = orr.id_order) + LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.current_state = os.id_order_state) + WHERE orr.`payment_mode` != "" AND orr.`id_transaction` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1 HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel) + ); + } + } + public static function getExpenses($date_from, $date_to, $granularity = false, $id_hotel = 0) { $expenses = ($granularity == 'day' ? array() : 0); diff --git a/modules/dashtrends/dashtrends.php b/modules/dashtrends/dashtrends.php index 7c6f1d06a..ae009aafc 100644 --- a/modules/dashtrends/dashtrends.php +++ b/modules/dashtrends/dashtrends.php @@ -107,6 +107,7 @@ class Dashtrends extends Module $tmp_data['total_paid_tax_excl'][$date] = $tmp_data['orders'][$date] * $tmp_data['average_cart_value'][$date]; $tmp_data['total_purchases'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(50, 70) / 100; $tmp_data['total_expenses'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 10) / 100; + $tmp_data['total_refunds'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 5) / 100; } } else { $tmp_data['visits'] = AdminStatsController::getVisits(false, $date_from, $date_to, 'day'); @@ -114,6 +115,7 @@ class Dashtrends extends Module $tmp_data['total_paid_tax_excl'] = AdminStatsController::getTotalSales($date_from, $date_to, 'day', $id_hotel); $tmp_data['total_purchases'] = AdminStatsController::getPurchases($date_from, $date_to, 'day', $id_hotel); $tmp_data['total_expenses'] = AdminStatsController::getExpenses($date_from, $date_to, 'day', $id_hotel); + $tmp_data['total_refunds'] = AdminStatsController::getRefunds($date_from, $date_to, 'day', $id_hotel); } return $tmp_data; @@ -151,6 +153,7 @@ class Dashtrends extends Module $refined_data['net_profits'][$date] += (isset($gross_data['total_paid_tax_excl'][$date]) ? $gross_data['total_paid_tax_excl'][$date] : 0); $refined_data['net_profits'][$date] -= (isset($gross_data['total_purchases'][$date]) ? $gross_data['total_purchases'][$date] : 0); $refined_data['net_profits'][$date] -= (isset($gross_data['total_expenses'][$date]) ? $gross_data['total_expenses'][$date] : 0); + $refined_data['net_profits'][$date] -= (isset($gross_data['total_refunds'][$date]) ? $gross_data['total_refunds'][$date] : 0); } return $refined_data; From 969b25bee2f8bb181682625b7975fe976ea12c82 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Wed, 12 Jun 2024 20:47:10 +0530 Subject: [PATCH 09/27] Fixed: Issues of TREVPAR and GOPPAR --- controllers/admin/AdminStatsController.php | 109 ++++++++++++--------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 0585557aa..b410c01b6 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1553,7 +1553,8 @@ class AdminStatsControllerCore extends AdminStatsTabController return $result; } - public static function getTotalRevenueForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + // Calculate total services revenue (services and demands) + public static function getServicesRevenueForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) { $dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo; @@ -1571,41 +1572,53 @@ class AdminStatsControllerCore extends AdminStatsTabController $result = array(); foreach ($discreteDates as $discreteDate) { - $cacheKey = 'AdminStats::getTotalRevenueForDiscreteDates'.'_'.(int) $discreteDate['timestamp_from'].'_'. - (!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel)); - if (!Cache::isStored($cacheKey) || !$useCache) { - $sql = 'SELECT SUM((current_parts / total_parts) * total_paid_tax_excl) AS total_revenue - FROM ( - SELECT o.`id_order`, - o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl, - ( - SELECT SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`)) - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) - WHERE hbd.`id_order` = o.`id_order` - AND p.`active` = 1 AND hbd.`is_refunded` = 0 AND o.`valid` = 1'. - (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').' - ) AS total_parts, - ( - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) - WHERE hbd.`id_order` = o.`id_order` - AND hbd.`date_from` <= "'.pSQL($discreteDate['date_from']).' 00:00:00" AND hbd.`date_to` >= "'.pSQL($discreteDate['date_to']).' 00:00:00" - AND p.`active` = 1 AND hbd.`is_refunded` = 0 AND o.`valid` = 1'. - (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').' - ) AS current_parts - FROM `'._DB_PREFIX_.'orders` o - HAVING total_parts IS NOT NULL AND current_parts > 0 - ORDER BY o.`id_order` - ) AS t'; + $totalServicesRevenue = 0; + // Calculate services revenue + $servicesRevenueSql = 'SELECT SUM((rtspod.`total_price_tax_excl` / o.`conversion_rate`) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) + FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rtspod + LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd + ON (rtspod.`id_htl_booking_detail` = hbd.`id`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); - $value = Db::getInstance()->getValue($sql); - $value = !$value ? 0: (float) $value; - Cache::store($cacheKey, $value); + if ($servicesRevenue = Db::getInstance()->getValue($servicesRevenueSql)) { + $totalServicesRevenue += $servicesRevenue; } - $result[$discreteDate['timestamp_from']] = Cache::retrieve($cacheKey); + // Calculate demands revenue + $demandsRevenueSql = 'SELECT SUM((hdmd.`total_price_tax_excl` / o.`conversion_rate`) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) + FROM `'._DB_PREFIX_.'htl_booking_demands` hdmd + LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd + ON (hdmd.`id_htl_booking` = hbd.`id`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); + + if ($demandsRevenue = Db::getInstance()->getValue($demandsRevenueSql)) { + $totalServicesRevenue += $demandsRevenue; + } + + $result[$discreteDate['timestamp_from']] = $totalServicesRevenue; + } + + return $result; + } + + public static function getTotalRevenueForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true) + { + $result = array(); + $servicesRevenueByDates = self::getServicesRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel); + if ($roomsRevenueByDates = self::getRoomsRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel)) { + foreach ($roomsRevenueByDates as $key => $value) { + $result[$key] = (isset($servicesRevenueByDates[$key]) ? $servicesRevenueByDates[$key] : 0) + $value; + } } return $result; @@ -2061,17 +2074,16 @@ class AdminStatsControllerCore extends AdminStatsTabController $roomsSql = 'SELECT IFNULL(SUM( CASE - WHEN od.`original_wholesale_price` <> "0.000000" - THEN od.`original_wholesale_price` - WHEN p.`wholesale_price` <> "0.000000" - THEN p.`wholesale_price` + WHEN od.`purchase_supplier_price` <> "0.000000" + THEN od.`purchase_supplier_price` + WHEN od.`purchase_supplier_price` = "0.000000" + THEN (od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100 END ), 0) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - LEFT JOIN `'._DB_PREFIX_.'product` p - ON (p.`id_product` = hbd.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'order_detail` od - ON (od.`id_order_detail` = hbd.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = hbd.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) WHERE p.`active` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. @@ -2085,19 +2097,18 @@ class AdminStatsControllerCore extends AdminStatsTabController $servicesSql = 'SELECT IFNULL(SUM( CASE - WHEN od.`original_wholesale_price` <> "0.000000" - THEN od.`original_wholesale_price` - WHEN p.`wholesale_price` <> "0.000000" - THEN p.`wholesale_price` + WHEN od.`purchase_supplier_price` <> "0.000000" + THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) + WHEN od.`purchase_supplier_price` = "0.000000" + THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) END ), 0) FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rtspod LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (rtspod.`id_htl_booking_detail` = hbd.`id`) - LEFT JOIN `'._DB_PREFIX_.'product` p - ON (p.`id_product` = hbd.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'order_detail` od - ON (od.`id_order_detail` = rtspod.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rtspod.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = rtspod.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) WHERE p.`active` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. From 63e31e7e59b80932c6b44596944e2644475e3cd0 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Wed, 12 Jun 2024 20:55:20 +0530 Subject: [PATCH 10/27] Fixed: Valid order condition for TREVPAR and GOPPAR --- controllers/admin/AdminStatsController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index b410c01b6..bfade8289 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1581,6 +1581,7 @@ class AdminStatsControllerCore extends AdminStatsTabController LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) WHERE p.`active` = 1 + AND o.`valid` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); @@ -1597,6 +1598,7 @@ class AdminStatsControllerCore extends AdminStatsTabController LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) WHERE p.`active` = 1 + AND o.`valid` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); @@ -2085,6 +2087,7 @@ class AdminStatsControllerCore extends AdminStatsTabController LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = hbd.`id_order_detail`) LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) WHERE p.`active` = 1 + AND o.`valid` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); @@ -2110,6 +2113,7 @@ class AdminStatsControllerCore extends AdminStatsTabController LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = rtspod.`id_order_detail`) LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) WHERE p.`active` = 1 + AND o.`valid` = 1 AND hbd.`is_refunded` = 0 AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); From 6c0622af234ed9c77129c0c69e15e4c5cd10eb4d Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Sat, 13 Jul 2024 13:24:05 +0530 Subject: [PATCH 11/27] Fixed: The net profit amount should decrease if an admin issues a refund by creating a voucher or credit slip --- controllers/admin/AdminStatsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 7d6846f18..151aeca79 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -532,7 +532,7 @@ class AdminStatsControllerCore extends AdminStatsTabController FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (o.id_order = orr.id_order) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.current_state = os.id_order_state) - WHERE orr.`payment_mode` != "" AND orr.`id_transaction` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.' + WHERE orr.`payment_mode` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.' GROUP BY LEFT(`invoice_date`, 10) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)); foreach ($result as $row) { From c6c3d44a09bfd9791474b3ff9a5578d5bbaf28a2 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 2 Aug 2024 13:29:45 +0530 Subject: [PATCH 12/27] Fixed the design issues on the rtl languages and updated the done button design for occupancy blocks --- modules/wkroomsearchblock/views/css/chosen.css | 6 ++++++ .../views/css/wk-global-search.css | 11 ++++++----- .../views/templates/hook/searchForm.tpl | 6 +++--- .../_partials/occupancy_field.tpl | 4 ++-- themes/hotel-reservation-theme/css/occupancy.css | 14 +++++++++++--- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/modules/wkroomsearchblock/views/css/chosen.css b/modules/wkroomsearchblock/views/css/chosen.css index 779c5e4c7..eba0b2181 100644 --- a/modules/wkroomsearchblock/views/css/chosen.css +++ b/modules/wkroomsearchblock/views/css/chosen.css @@ -41,6 +41,12 @@ border-top: 0; box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15); } +.rtl .chosen-container .chosen-drop { + right: -9999px; +} +.rtl .chosen-container.chosen-with-drop .chosen-drop { + right: 0; +} .chosen-container.chosen-container-single-nosearch .chosen-drop { top: 100%; } diff --git a/modules/wkroomsearchblock/views/css/wk-global-search.css b/modules/wkroomsearchblock/views/css/wk-global-search.css index 3949a7c10..83edd356b 100644 --- a/modules/wkroomsearchblock/views/css/wk-global-search.css +++ b/modules/wkroomsearchblock/views/css/wk-global-search.css @@ -215,9 +215,7 @@ border-radius: 4px;} .submit_occupancy_btn { background-color: #1292FF; - font-size: 13px; border: none; - padding: 5px 20px; border-radius: 4px;} @@ -229,7 +227,7 @@ overflow: auto; box-shadow: 0 8px 25px -4px rgba(0,0,0,0.39); left: 0px; - padding: 12px 20px;} + padding: 15px 20px;} #search_occupancy_wrapper.top { top: unset; bottom: 100%; } @@ -253,8 +251,11 @@ font-weight: bold; text-decoration: none; font-size: 14px; - color: #0000FF; - line-height: 24px;} + color: #0000FF;} + #search_occupancy_wrapper .occupancy_block_actions { + display: flex; + justify-content: space-between; + align-items: center;} #search_occupancy_wrapper .add_new_occupancy_btn:active, #search_occupancy_wrapper .add_new_occupancy_btn:focus, #search_occupancy_wrapper .add_new_occupancy_btn:hover { text-decoration: none; color: #0000FF;} diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index 8bd27f7fc..a5a6e0bc9 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -40,7 +40,7 @@ -
    +