Fixed: Employee was able to download invoice for all hotels from Admin Invoice controller

This commit is contained in:
Shreesh Arora
2024-03-14 16:47:07 +05:30
parent aca384c45c
commit 6c0b943abd
2 changed files with 9 additions and 3 deletions

View File

@@ -887,9 +887,11 @@ class OrderInvoiceCore extends ObjectModel
SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
AND oi.date_add >= \''.pSQL($date_from).'\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')
.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
ORDER BY oi.date_add ASC
');
@@ -908,8 +910,10 @@ class OrderInvoiceCore extends ObjectModel
SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE '.(int)$id_order_state.' = o.current_state
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')
.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
ORDER BY oi.`date_add` ASC
');

View File

@@ -195,10 +195,12 @@ class AdminInvoicesControllerCore extends AdminController
);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT COUNT( o.id_order ) AS nbOrders, o.current_state as id_order_state
SELECT COUNT(DISTINCT(o.id_order)) AS nbOrders, o.current_state as id_order_state
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oi.id_order = o.id_order
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE o.id_shop IN('.implode(', ', Shop::getContextListShopID()).')
'.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
GROUP BY o.current_state
');