diff --git a/modules/logistics/carriers/mondialrelay/cron_trace.php b/modules/logistics/carriers/mondialrelay/cron_trace.php index ebb35844..824b5903 100755 --- a/modules/logistics/carriers/mondialrelay/cron_trace.php +++ b/modules/logistics/carriers/mondialrelay/cron_trace.php @@ -70,8 +70,18 @@ foreach ($iterator as $fileinfo) { if ($situation == 'DPC') $expeditions[] = $expedition_number; } - if (!count($expeditions)) + if (!count($expeditions)) { + ## ARCHIVE FILE + $repo_archive = dirname(__FILE__) . '/archives/trace/'; + $repo_paths = array('others',date('Y'), date('m')); + foreach ($repo_paths as $repo_path) { + $repo_archive .= $repo_path . '/'; + if (!file_exists($repo_archive)) + mkdir($repo_archive); + } + rename(dirname(__FILE__).'/trace/'.$fileinfo->getFilename(), $repo_archive . $fileinfo->getFilename()); continue; + } $expedition_orders = array(); $expedition_order_details = array(); @@ -121,6 +131,7 @@ foreach ($iterator as $fileinfo) { $fully_sent = FALSE; $products_sent = array(); + $remaining = array(); foreach(Db::getInstance()->ExecuteS(' SELECT d.`id_order_detail`, IF( @@ -136,6 +147,8 @@ foreach ($iterator as $fileinfo) { ') as $quantity_remain) { if((int) $quantity_remain['remain'] == 0) { $products_sent[] = (int) $quantity_remain['id_order_detail']; + } elseif ((int) $quantity_remain['remain'] == 1) { + $remaining[] = (int) $quantity_remain['id_order_detail']; } } @@ -153,6 +166,8 @@ foreach ($iterator as $fileinfo) { ') as $quantity_remain) { if((int) $quantity_remain['remain'] == 0) { $products_sent[] = (int) $quantity_remain['id_order_detail']; + } elseif ((int) $quantity_remain['remain'] == 1) { + $remaining[] = (int) $quantity_remain['id_order_detail']; } } @@ -170,6 +185,8 @@ foreach ($iterator as $fileinfo) { ') as $quantity_remain) { if((int) $quantity_remain['remain'] == 0) { $products_sent[] = (int) $quantity_remain['id_order_detail']; + } elseif ((int) $quantity_remain['remain'] == 1) { + $remaining[] = (int) $quantity_remain['id_order_detail']; } } @@ -187,12 +204,13 @@ foreach ($iterator as $fileinfo) { ') as $quantity_remain) { if((int) $quantity_remain['remain'] == 0) { $products_sent[] = (int) $quantity_remain['id_order_detail']; + } elseif ((int) $quantity_remain['remain'] == 1) { + $remaining[] = (int) $quantity_remain['id_order_detail']; } } - $remaining = array(); foreach($order_details as $d) { - if(!in_array($d, $products_sent)) { + if(!in_array($d, $products_sent) && !in_array($d, $remaining)) { $remaining[] = (int) $d; } } diff --git a/modules/philea_magistor/script/send_commande.php b/modules/philea_magistor/script/send_commande.php index 9d6181e5..d89db15c 100644 --- a/modules/philea_magistor/script/send_commande.php +++ b/modules/philea_magistor/script/send_commande.php @@ -409,7 +409,7 @@ if($magistorModule->active) { str_replace(array("\r", "\n"), '', $ref), 0, substr(utf8_decode(cleanChar($pack_item['name'])),0,50), - str_replace(array("\r", "\n"), "", $ean) + substr(str_replace(array("\r", "\n"), "", $ean),0,14) ); } $product_rows[$p_key][1] += (max($product['product_quantity'] - max($product['product_quantity_return'], $product['product_quantity_refunded']), 0) * $pack_item['pack_quantity']); @@ -424,7 +424,7 @@ if($magistorModule->active) { str_replace(array("\r", "\n"), '', $ref), 0, substr(utf8_decode(cleanChar($product['product_name'])),0,50), - str_replace(array("\r", "\n"), "", $ean), + substr(str_replace(array("\r", "\n"), "", $ean),0,14), ); } $product_rows[$p_key][1] += max($product['product_quantity'] - max($product['product_quantity_return'], $product['product_quantity_refunded']), 0);