Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Christophe Latour 2017-08-28 15:38:27 +02:00
commit 1a3533b003

View File

@ -260,15 +260,20 @@ class AdminLogisticsPending extends AdminTab {
$_orders = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order`, p.`id_product`, c.`id_sale`, GREATEST(d.`product_quantity` - d.`product_quantity_return`, 0) AS `product_quantity`,
d.`product_reference`, COUNT(d.id_order_detail) as `nb_p`
d.`product_reference`, COUNT(d.id_order_detail) as `nb_p`,
CASE
WHEN SUBSTRING(ca.`name`, 1,1) = "T" THEN 1
WHEN SUBSTRING(ca.name`, 1,1) = "C" THEN 1
ELSE '2'
END as `carrier_name`
FROM `'._DB_PREFIX_.'privatesale_category` c
LEFT JOIN `'._DB_PREFIX_.'product` p
ON c.`id_category` = p.`id_category_default`
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
ON d.`product_id` = p.`id_product`
LEFT JOIN `'._DB_PREFIX_.'product` p ON c.`id_category` = p.`id_category_default`
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`product_id` = p.`id_product`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'carrier` ca ON ca.id_carrier = o.id_carrier
WHERE d.`id_order` IN ('.implode(', ', $orders).')
GROUP BY d.`id_order`
ORDER BY `nb_p` ASC, d.`product_reference`
ORDER BY `carrier_name` ASC, `nb_p` ASC, d.`product_reference`
') as $row) {
if(!isset($_orders[(int)$row['id_order']])) {
$_orders[(int)$row['id_order']] = (int)$row['id_order'];