diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl
index 8a2b5b313..f7b698329 100644
--- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl
+++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl
@@ -1065,7 +1065,9 @@
| {l s='Refund ID'} |
+ {l s='Total Rooms'} |
{l s='Status'} |
+ {l s='Requested Date'} |
@@ -1074,6 +1076,9 @@
#{$return_info.id_order_return}
|
+
+ {$return_info.total_rooms|escape:'html':'UTF-8'}
+ |
{capture name=refund_status}
{if isset($return_info.payment_mode) && $return_info.payment_mode != ''}{l s='Payment Mode: '}{$return_info.payment_mode} {/if}
@@ -1108,12 +1113,39 @@
{$return_info.state_name}
{/if}
|
+
+ {$return_info.date_add}
+ |
{/foreach}
{/if}
+
+
+ {l s='Cancellation Policies'}
+
+ {if is_array($applicable_refund_policies) && count($applicable_refund_policies)}
+
+ {else}
+
+
+ {l s='No cancellation policies applicable.'}
+
+ {/if}
+
{hook h="displayAdminOrderRight" id_order=$order->id}
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index a3ded107d..319248e72 100644
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -1661,9 +1661,13 @@ class AdminOrdersControllerCore extends AdminController
// hotel booking statuses
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
+
+ // applicable refund policies
+ $applicableRefundPolicies = HotelOrderRefundRules::getApplicableRefundRules($order->id);
$this->tpl_view_vars = array(
// refund info
'refund_allowed' => (int) $order->isReturnable(),
+ 'applicable_refund_policies' => $applicableRefundPolicies,
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
'refundReqBookings' => $refundReqBookings,
'hasCompletelyRefunded' => $order->hasCompletelyRefunded(),
diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
index a952b3aa8..491c82c29 100644
--- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
+++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
@@ -236,4 +236,44 @@ class HotelOrderRefundRules extends ObjectModel
return $totalCancelationCharges;
}
+
+ public static function getApplicableRefundRules($idOrder)
+ {
+ $idLang = Context::getContext()->language->id;
+
+ $maxDate = Db::getInstance()->getValue(
+ 'SELECT MAX(DATE(hbd.`date_from`))
+ FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
+ WHERE hbd.`id_order` = '.(int) $idOrder
+ );
+
+ if ($maxDate) {
+ $dateToday = date('Y-m-d');
+
+ if (strtotime($maxDate) >= strtotime($dateToday)) {
+ $days = HotelBookingDetail::getDays($dateToday, $maxDate); // always returns positive
+
+ $sql = 'SELECT hbrr.`id_hotel_refund_rule`, hbrr.`id_refund_rule`, hbrr.`id_hotel`, hbrr.`position`,
+ horrl.`name`, horrl.`description`, horr.`payment_type`, horr.`deduction_value_full_pay`,
+ horr.`deduction_value_adv_pay`, horr.`days`
+ FROM `'._DB_PREFIX_.'htl_branch_refund_rules` hbrr
+ LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules` horr
+ ON (horr.`id_refund_rule` = hbrr.`id_refund_rule`)
+ LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` horrl
+ ON (horrl.`id_refund_rule` = horr.`id_refund_rule` AND horrl.`id_lang` = '.(int) $idLang.')
+ LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
+ ON (hbd.`id_hotel` = hbrr.`id_hotel` AND hbd.`id_order` = '.(int) $idOrder.')
+ WHERE horr.`days` <= '.(int) $days.'
+ GROUP BY hbrr.`id_refund_rule`
+ ORDER BY hbrr.`position`';
+
+ if ($result = Db::getInstance()->executeS($sql)) {
+ return $result;
+ }
+ }
+ }
+
+ return array();
+
+ }
}