From 7a207b2010296dfc591996999b8f837ffeab1bf4 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 13 Feb 2018 12:42:39 +0100 Subject: [PATCH 1/2] CS --- modules/ant_logistic/ajax.php | 61 ++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/modules/ant_logistic/ajax.php b/modules/ant_logistic/ajax.php index 223c9f9e..a1ca8ec1 100644 --- a/modules/ant_logistic/ajax.php +++ b/modules/ant_logistic/ajax.php @@ -150,41 +150,42 @@ if(($id_order = (int) Tools::getValue('id_order')) $products = array(); foreach($order->getProductsDetail() as $p) { // --- Get quantity sent + $p['product_quantity_sent'] = 0; // LaPoste $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'lapostews` - WHERE `id_order_detail` = '.(int) $p['id_order_detail'].' - '); + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] + ); // Exapaq $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'exapaqws` - WHERE `id_order_detail` = '.(int) $p['id_order_detail'].' - '); + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] + ); // MondialRelay $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'mondialrelay_parcel` - WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' - '); + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] + ); // Philea $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'philea_parcel` - WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' - '); + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] + ); // DropShipping $p['product_quantity_sent'] += (int) Db::getInstance()->getValue(' SELECT IFNULL(SUM(`quantity`), 0) FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` - WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . ' - '); + WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] + ); // Image $p['id_image'] = 0; - if((int) $p['product_attribute_id'] != 0) { + if ((int) $p['product_attribute_id'] != 0) { $img = Db::getInstance()->getRow(' SELECT `id_image` FROM `'._DB_PREFIX_.'product_attribute_image` @@ -194,7 +195,7 @@ if(($id_order = (int) Tools::getValue('id_order')) $p['id_image'] = $img['id_image']; } - if($p['id_image'] == 0) { + if ($p['id_image'] == 0) { $img = Db::getInstance()->getRow(' SELECT `id_image` FROM `'._DB_PREFIX_.'image` @@ -220,7 +221,7 @@ if(($id_order = (int) Tools::getValue('id_order')) WHERE `id_product` = '.(int) $p['product_id'].' AND id_order = '.(int)$id_order ); - if(!isset($sales_carriers[(int) $p['id_sale']])) { + if (!isset($sales_carriers[(int) $p['id_sale']])) { $sales_carriers[(int) $p['id_sale']] = array(); foreach(Db::getInstance()->ExecuteS(' SELECT `id_carrier` @@ -236,7 +237,7 @@ if(($id_order = (int) Tools::getValue('id_order')) // --- Get Shipping Numbers $shipping_numbers = array(); // Philea - foreach(Db::getInstance()->ExecuteS(' + 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`) @@ -246,7 +247,7 @@ if(($id_order = (int) Tools::getValue('id_order')) $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } // LaPoste - foreach(Db::getInstance()->ExecuteS(' + foreach (Db::getInstance()->ExecuteS(' SELECT l.`shipping_number` FROM `'._DB_PREFIX_.'lapostews` l LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) @@ -256,7 +257,7 @@ if(($id_order = (int) Tools::getValue('id_order')) $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } // Exapaq - foreach(Db::getInstance()->ExecuteS(' + foreach (Db::getInstance()->ExecuteS(' SELECT e.`shipping_number` FROM `'._DB_PREFIX_.'exapaqws` e LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`id_order_detail`) @@ -266,7 +267,7 @@ if(($id_order = (int) Tools::getValue('id_order')) $shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"'; } // MondialRelay - foreach(Db::getInstance()->ExecuteS(' + foreach (Db::getInstance()->ExecuteS(' SELECT l.`shipping_number` FROM `'._DB_PREFIX_.'mondialrelay_parcel` l LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`) @@ -275,20 +276,22 @@ if(($id_order = (int) Tools::getValue('id_order')) ') 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']).' - AND h.`id_order` = '.(int) $order->id.' - '.(count($shipping_numbers) > 0? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')': '').' - ')) { - $p['product_quantity_sent'] = $p['product_quantity'] - ( $p['product_quantity_return'] > 0 ? - $p['product_quantity_return']: $p['product_quantity_refunded'] ); + if ((int)$p['product_quantity_sent'] === 0) { + if (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']).' + AND h.`id_order` = '.(int) $order->id.' + '.(count($shipping_numbers) > 0 ? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')' : '').' + ')) { + $p['product_quantity_sent'] = $p['product_quantity'] - ( + $p['product_quantity_return'] > 0 ? $p['product_quantity_return'] : $p['product_quantity_refunded'] + ); + } } /* Pack */ - if(Pack::isPack($p['product_id'])){ + if (Pack::isPack($p['product_id'])){ $p['items_pack'] = Pack::getCompleteSimplePack((int) $p['product_id']); } @@ -477,7 +480,7 @@ if(($id_order = (int) Tools::getValue('id_order')) '.str_replace(' - ','
',$products[$key]['product_name']).'
'.($products[$key]['product_reference']? $products[$key]['product_reference'].'
': '').($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').($products[$key]['location']?'
'.$products[$key]['location'].'': '').' '.($products[$key]['product_supplier_reference']? $products[$key]['product_supplier_reference']: '').' - '.$products[$key]['product_quantity'].' / '.($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']).' / '.$products[$key]['product_quantity_sent'].' + '.$products[$key]['product_quantity'].' / '.($products[$key]['product_quantity_refunded'] > 0 ? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']).' / '.$products[$key]['product_quantity_sent'].' '.max(in_array($products[$key]['product_id'], $locked_products)? '0': ($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent']), 0).' 0?'checked disabled':'').'/> '; From fb61d8b1ad57aa95d9f8aaefa2f78079a7307975 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 13 Feb 2018 16:45:38 +0100 Subject: [PATCH 2/2] id_order --- modules/ant_logistic/AdminAntLogistic.php | 2 +- modules/ant_logistic/ajax.php | 1 + modules/ant_logistic/script.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ant_logistic/AdminAntLogistic.php b/modules/ant_logistic/AdminAntLogistic.php index c9d43e39..121a1a67 100644 --- a/modules/ant_logistic/AdminAntLogistic.php +++ b/modules/ant_logistic/AdminAntLogistic.php @@ -346,7 +346,7 @@ class AdminAntLogistic extends AdminTab $to_ship[(int) $p['id_order_detail']] = $p['product_quantity'] - ($p['product_quantity_refunded'] > 0? $p['product_quantity_refunded']: $p['product_quantity_return']) - (int) $p['quantity_sent']; } - if(Validate::isLoadedObject($order)) { + if (Validate::isLoadedObject($order)) { $parcel_carrier = Tools::getValue('parcel_carrier', 'laposte'); if(($weight = Tools::getValue('weight')) && ($products = Tools::getValue('shipped'))) { diff --git a/modules/ant_logistic/ajax.php b/modules/ant_logistic/ajax.php index a1ca8ec1..8c837d3b 100644 --- a/modules/ant_logistic/ajax.php +++ b/modules/ant_logistic/ajax.php @@ -577,6 +577,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
kg
+ '; diff --git a/modules/ant_logistic/script.js b/modules/ant_logistic/script.js index 7c003730..6ff6683a 100644 --- a/modules/ant_logistic/script.js +++ b/modules/ant_logistic/script.js @@ -47,7 +47,9 @@ function checkPrinting() { }); if(!allok) { - prompt("Les quantités scannées sont inférieures aux quantités à envoyer. Confirmer l\'envoi ?", function() { $("#button4").attr("onclick", "").trigger("click"); }); + prompt("Les quantités scannées sont inférieures aux quantités à envoyer. Confirmer l\'envoi ?", function() { + $("#button4").attr("onclick", "").trigger("click"); + }); } else { $("#button4").attr("onclick", "").trigger("click"); }