Fixed: admin order, cart, email, receipt and cart rule issues on back office
Co-authored-by: Name <azharbhat.qlo098@webkul.in>
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
{if $hotel_names_remaining}
|
||||
{capture name='hotel_names_tooltip'}
|
||||
<div class="ui-tooltip-wrapper">
|
||||
<div class="ui-tooltip-header"><div class="ui-tooltip-label">{l s='Selected Hotels'}</div></div>
|
||||
<div class="ui-tooltip-header"><div class="ui-tooltip-label">{l s='Selected Properties'}</div></div>
|
||||
<ul>
|
||||
{foreach from=$selected_hotels item='hotel'}
|
||||
<li class="ui-tooltip-elem-txt">{$hotel|escape:'html':'UTF-8'}</li>
|
||||
|
||||
@@ -2831,6 +2831,27 @@ class OrderCore extends ObjectModel
|
||||
return Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'orders WHERE id_cart = '.(int)$id_cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all orders linked to a cart, either as the order's own cart or through a room
|
||||
* added to an existing order from the back office (that creates a new cart whose
|
||||
* rooms belong to the order, while orders.id_cart still points at the original cart).
|
||||
*
|
||||
* @param int $idCart
|
||||
* @return array of orders
|
||||
*/
|
||||
public static function getAllOrdersLinkedToCart($idCart)
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT o.* FROM `'._DB_PREFIX_.'orders` o
|
||||
WHERE o.`id_cart` = '.(int) $idCart.'
|
||||
OR o.`id_order` IN (
|
||||
SELECT hbd.`id_order` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_cart` = '.(int) $idCart.'
|
||||
)
|
||||
ORDER BY o.`id_order` ASC'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if order has been completely refunded
|
||||
* @param integer action: can have 3 values as below
|
||||
|
||||
@@ -47,7 +47,7 @@ class AdminCartRulesControllerCore extends AdminController
|
||||
$this->fields_list = array(
|
||||
'id_cart_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'hotel_names' => array('title' => $this->l('Hotels'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'),
|
||||
'hotel_names' => array('title' => $this->l('Property'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'),
|
||||
'priority' => array('title' => $this->l('Priority'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'code' => array('title' => $this->l('Code'), 'class' => 'fixed-width-sm'),
|
||||
'quantity' => array('title' => $this->l('Quantity'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
@@ -274,7 +274,7 @@ class AdminCartRulesControllerCore extends AdminController
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'admin_cart_rule_tab_link' => $this->context->link->getAdminLink('AdminCartRules'),
|
||||
'room_access_err' => $this->l('You can only select room types which hotel(s) access is provided to this employee.'),
|
||||
'room_access_err' => $this->l('You can only select room types of the properties this employee has access to.'),
|
||||
'room_rmv_txt' => $this->l('Unselect below room types'),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -286,7 +286,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$summary = $cart->getSummaryDetails();
|
||||
|
||||
/* Display orders information */
|
||||
$cartOrders = Order::getAllOrdersByCartId($cart->id);
|
||||
$cartOrders = Order::getAllOrdersLinkedToCart($cart->id);
|
||||
if ($cartOrders) {
|
||||
$objOrder = new Order($cartOrders[0]['id_order']);
|
||||
if (Validate::isLoadedObject($objOrder)) {
|
||||
|
||||
@@ -119,7 +119,7 @@ class AdminEmailsControllerCore extends AdminController
|
||||
'type' => 'bool'
|
||||
)
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
'submit' => array('title' => $this->l('Save'), 'name' => 'submitOptions')
|
||||
),
|
||||
'smtp' => array(
|
||||
'title' => $this->l('Email'),
|
||||
@@ -181,7 +181,7 @@ class AdminEmailsControllerCore extends AdminController
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
'submit' => array('title' => $this->l('Save'), 'name' => 'submitOptions')
|
||||
),
|
||||
'test' => array(
|
||||
'title' => $this->l('Test your email configuration'),
|
||||
|
||||
@@ -481,7 +481,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
if ((int) $order->isReturnable()) {
|
||||
// nothing left to refund once every room and service line is deleted
|
||||
// (amount is not checked: a free order can still be refunded)
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail();
|
||||
if ((int) $order->isReturnable()
|
||||
&& ($objHotelBookingDetail->getBookingDataByOrderId($order->id)
|
||||
|| $objServiceProductOrderDetail->getServiceProductsInOrder($order->id)
|
||||
)
|
||||
) {
|
||||
// always "Initiate refund" now, regardless of order status —
|
||||
// cancelling a booking happens through Room Status only
|
||||
$this->page_header_toolbar_btn['cancel'] = array(
|
||||
@@ -7219,6 +7227,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order_invoice->total_discount_tax_excl = 0;
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
// the order's own discount totals must follow the deleted cart rules
|
||||
$order->total_discounts = 0;
|
||||
$order->total_discounts_tax_incl = 0;
|
||||
$order->total_discounts_tax_excl = 0;
|
||||
$res &= $order->update();
|
||||
}
|
||||
|
||||
if (isset($order_invoice) && $order_invoice->id) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class AdminPaymentReceiptsControllerCore extends AdminControllerCore
|
||||
),
|
||||
'PS_PAYMENT_RECEIPTS_PREFIX' => array(
|
||||
'title' => $this->l('Receipt prefix'),
|
||||
'desc' => $this->l('Prefix used for receipt name (e.g. #IN00001).'),
|
||||
'desc' => $this->l('Prefix used for receipt name (e.g. REC000001).'),
|
||||
'size' => 6,
|
||||
'type' => 'textLang'
|
||||
),
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
<value>#IN</value>
|
||||
</configuration>
|
||||
<configuration id="PS_PAYMENT_RECEIPTS_PREFIX" name="PS_PAYMENT_RECEIPTS_PREFIX">
|
||||
<value>#IN</value>
|
||||
<value>REC</value>
|
||||
</configuration>
|
||||
<configuration id="PS_INVCE_INVOICE_ADDR_RULES" name="PS_INVCE_INVOICE_ADDR_RULES">
|
||||
<value>{"avoid":[]}</value>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<value>#IN</value>
|
||||
</configuration>
|
||||
<configuration id="PS_PAYMENT_RECEIPTS_PREFIX" name="PS_PAYMENT_RECEIPTS_PREFIX">
|
||||
<value>#IN</value>
|
||||
<value>REC</value>
|
||||
</configuration>
|
||||
<configuration id="PS_DELIVERY_PREFIX">
|
||||
<value>#DE</value>
|
||||
|
||||
@@ -1643,10 +1643,16 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$(document).on('click', '#initiateRefund', function(e) {
|
||||
if ($(this).data('submitted')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($.trim($('.cancellation_reason').val()) == '') {
|
||||
$('.cancellation_reason').focus().css('border', '1px solid red');
|
||||
return false;
|
||||
}
|
||||
|
||||
$(this).data('submitted', true);
|
||||
});
|
||||
// End: CancelRoomBookingModal: Processes
|
||||
// ======================================
|
||||
|
||||
@@ -1532,7 +1532,7 @@ class HotelHelper
|
||||
),
|
||||
array(
|
||||
'id' => HotelBookingDetail::STATUS_NO_SHOW,
|
||||
'color' => '#DC143C',
|
||||
'color' => '#FF8C00',
|
||||
'is_terminal' => 1,
|
||||
'name' => array(
|
||||
'en' => 'No-show',
|
||||
@@ -1545,7 +1545,7 @@ class HotelHelper
|
||||
),
|
||||
array(
|
||||
'id' => HotelBookingDetail::STATUS_CANCELLED,
|
||||
'color' => '#FF8C00',
|
||||
'color' => '#DC143C',
|
||||
'is_terminal' => 1,
|
||||
'name' => array(
|
||||
'en' => 'Cancelled',
|
||||
|
||||
Reference in New Issue
Block a user