From 65cec1825d68c79f09029cc8e8f1fb474cb4d187 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 15 Jan 2018 16:03:18 +0100 Subject: [PATCH] Set philea as first --- modules/logistics/AdminLogistics.php | 2 +- modules/logistics/ajax.php | 66 ++++++++++++++-------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/modules/logistics/AdminLogistics.php b/modules/logistics/AdminLogistics.php index 5a7ccda0..dfd3f176 100644 --- a/modules/logistics/AdminLogistics.php +++ b/modules/logistics/AdminLogistics.php @@ -274,7 +274,7 @@ class AdminLogistics extends AdminTab $order = new Order((int) $id_order); if (Validate::isLoadedObject($order)) { $parcel_carrier == 'laposte' ? $weight = 0.24 : true; - if ($parcel_carrier == "laposte" || $parcel_carrier == "mondialrelay") { + if ($parcel_carrier == 'laposte' || $parcel_carrier == 'mondialrelay') { $result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight); if($result[0] != '') { $this->_html .= $result[0]; diff --git a/modules/logistics/ajax.php b/modules/logistics/ajax.php index 574702c3..466f5725 100644 --- a/modules/logistics/ajax.php +++ b/modules/logistics/ajax.php @@ -130,6 +130,7 @@ if(($id_order = (int) Tools::getValue('id_order')) $link = new Link(2); $products = array(); foreach($order->getProductsDetail() as $p) { + // --- Get quantity sent // LaPoste $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) @@ -214,8 +215,18 @@ if(($id_order = (int) Tools::getValue('id_order')) $p['location'] = isset($locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']]) ? $locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']]: ''; - // Get Shipping Numbers + // --- Get Shipping Numbers $shipping_numbers = array(); + // Philea + foreach(Db::getInstance()->ExecuteS(' + SELECT l.`shipping_number` + FROM `'._DB_PREFIX_.'philea_parcel` l + LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) + LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`) + WHERE h.`id_order` = '.(int) $order->id.' + ') as $row) { + $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; + } // LaPoste foreach(Db::getInstance()->ExecuteS(' SELECT l.`shipping_number` @@ -246,21 +257,11 @@ if(($id_order = (int) Tools::getValue('id_order')) ') as $row) { $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } - // Philea - foreach(Db::getInstance()->ExecuteS(' - SELECT l.`shipping_number` - FROM `'._DB_PREFIX_.'philea_parcel` l - LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) - LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`) - WHERE h.`id_order` = '.(int) $order->id.' - ') as $row) { - $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; - } if(((int) $p['product_quantity_sent'] === 0) && Db::getInstance()->getRow(' SELECT h.`id_sale` FROM `'._DB_PREFIX_.'shipping_history` h - WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999? 0: (int) $p['id_sale']).' + WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999 ? 0: (int) $p['id_sale']).' AND h.`id_order` = '.(int) $order->id.' '.(count($shipping_numbers) > 0? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')': '').' ')) { @@ -288,8 +289,24 @@ if(($id_order = (int) Tools::getValue('id_order')) if(count($id_order_details) > 0) { $logs = array(); + // Send by PHILEA + if ($l = Db::getInstance()->ExecuteS(' + SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname, + (CASE c.`external_module_name` WHEN "soflexibilite" THEN "laposte" ELSE c.`external_module_name` END) as carrier, + "1" as philea + FROM `'._DB_PREFIX_.'philea_parcel` l + LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail` + LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order` + LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier` + WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).') + AND l.`quantity` > 0 + ORDER BY l.`date_add` DESC + ')) { + $logs = array_merge($logs, $l); + } + // Send by LAPOSTE - if($l = Db::getInstance()->ExecuteS(' + if ($l = Db::getInstance()->ExecuteS(' SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "laposte" as carrier, "0" as philea FROM `'._DB_PREFIX_.'lapostews` l @@ -304,7 +321,7 @@ if(($id_order = (int) Tools::getValue('id_order')) } // Send by EXAPAQ - if($l = Db::getInstance()->ExecuteS(' + if ($l = Db::getInstance()->ExecuteS(' SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "exapaq" as carrier, "0" as philea FROM `'._DB_PREFIX_.'exapaqws` l @@ -319,7 +336,7 @@ if(($id_order = (int) Tools::getValue('id_order')) } // Send by MONDIAL RELAY - if($l = Db::getInstance()->ExecuteS(' + if ($l = Db::getInstance()->ExecuteS(' SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "mondialrelay" as carrier, "0" as philea FROM `'._DB_PREFIX_.'mondialrelay_parcel` l @@ -334,7 +351,7 @@ if(($id_order = (int) Tools::getValue('id_order')) } // Send by DROPSHIPPING - if($l = Db::getInstance()->ExecuteS(' + if ($l = Db::getInstance()->ExecuteS(' SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Dropshipping" as firstname, "0" as philea FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` l @@ -346,22 +363,7 @@ if(($id_order = (int) Tools::getValue('id_order')) ')) { $logs = array_merge($logs, $l); } - - // Send by PHILEA - if($l = Db::getInstance()->ExecuteS(' - SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname, - (CASE c.`external_module_name` WHEN "soflexibilite" THEN "laposte" ELSE c.`external_module_name` END) as carrier, - "1" as philea - FROM `'._DB_PREFIX_.'philea_parcel` l - LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail` - LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order` - LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier` - WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).') - AND l.`quantity` > 0 - ORDER BY l.`date_add` DESC - ')) { - $logs = array_merge($logs, $l); - } + } else { $logs = array(); }