Merge pull request #589 from abhishek-webkul/gli-1264

Add cancellation policy section on admin order view page
This commit is contained in:
Rohit Jain
2023-03-20 16:03:09 +05:30
committed by GitHub
3 changed files with 76 additions and 0 deletions

View File

@@ -1065,7 +1065,9 @@
<thead>
<tr>
<th class="text-left">{l s='Refund ID'}</th>
<th class="text-center">{l s='Total Rooms'}</th>
<th class="text-left">{l s='Status'}</th>
<th class="text-center">{l s='Requested Date'}</th>
</tr>
</thead>
<tbody>
@@ -1074,6 +1076,9 @@
<td class="text-left">
<a href="{$link->getAdminLink('AdminOrderRefundRequests')}&vieworder_return&id_order_return={$return_info.id_order_return}" target="_blank">#{$return_info.id_order_return}</a>
</td>
<td class="text-center">
{$return_info.total_rooms|escape:'html':'UTF-8'}
</td>
<td class="text-left">
{capture name=refund_status}
{if isset($return_info.payment_mode) && $return_info.payment_mode != ''}{l s='Payment Mode: '}{$return_info.payment_mode}<br/>{/if}
@@ -1108,12 +1113,39 @@
{$return_info.state_name}
{/if}
</td>
<td class="text-center">
{$return_info.date_add}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{/if}
<div class="panel">
<div class="panel-heading">
<i class="icon-list"></i> {l s='Cancellation Policies'}
</div>
{if is_array($applicable_refund_policies) && count($applicable_refund_policies)}
<ul>
{foreach from=$applicable_refund_policies item=$applicable_refund_policy}
<li>
<p>
<a href="{$link->getAdminLink('AdminOrderRefundRules')|escape:'html':'UTF-8'}&id_refund_rule={$applicable_refund_policy.id_refund_rule}&updatehtl_order_refund_rules" target="_blank">
{$applicable_refund_policy.name|escape:'html':'UTF-8'}
<i class="icon-external-link"></i>
</a>
</p>
</li>
{/foreach}
</ul>
{else}
<p>
<i class="icon-warning-sign list-empty-icon"></i>
{l s='No cancellation policies applicable.'}
</p>
{/if}
</div>
{hook h="displayAdminOrderRight" id_order=$order->id}
</div>
</div>

View File

@@ -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(),

View File

@@ -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();
}
}