From cf8ebe79b2da12736acfa65b15c34892e4399f09 Mon Sep 17 00:00:00 2001 From: abhishek-webkul <84142535+abhishek-webkul@users.noreply.github.com> Date: Thu, 16 Mar 2023 11:51:53 +0530 Subject: [PATCH] Update HotelOrderRefundRules.php --- .../classes/HotelOrderRefundRules.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index 1a8b021d9..e0efe08d8 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -227,32 +227,35 @@ class HotelOrderRefundRules extends ObjectModel { $idLang = Context::getContext()->language->id; - $minDate = Db::getInstance()->getValue( - 'SELECT MIN(DATE(hbd.`date_from`)) + $maxDate = Db::getInstance()->getValue( + 'SELECT MAX(DATE(hbd.`date_from`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = '.(int) $idOrder ); - if (!$minDate) { + if (!$maxDate) { return array(); } $dateToday = date('Y-m-d'); - if (strtotime($minDate) < strtotime($dateToday)) { // same day cancellation rules are allowed - $minDate = $dateToday; + if (strtotime($maxDate) < strtotime($dateToday)) { // same day cancellation rules are allowed + $maxDate = $dateToday; } - $days = HotelBookingDetail::getDays($dateToday, $minDate); + $days = HotelBookingDetail::getDays($dateToday, $maxDate); + $idHotel = HotelBookingDetail::getIdHotelByIdOrder($idOrder); - $sql = 'SELECT * + $sql = 'SELECT hrr.`id_hotel_refund_rule`, hrr.`id_refund_rule`, hrr.`id_hotel`, hrr.`position`, + orrl.`name`, orrl.`description`, orr.`payment_type`, orr.`deduction_value_full_pay`, orr.`deduction_value_adv_pay`, + orr.`days` FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hrr LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` orr ON (orr.`id_refund_rule` = hrr.`id_refund_rule`) LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` orrl ON (orrl.`id_refund_rule` = orr.`id_refund_rule` AND orrl.`id_lang` = '.(int) $idLang.') - WHERE orr.`days` <= '.(int) $days.' - ORDER BY orr.`days` DESC'; + WHERE orr.`days` <= '.(int) $days.' AND hrr.`id_hotel` = '.(int) $idHotel.' + ORDER BY hrr.`position`'; return Db::getInstance()->executeS($sql); }