diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 70b79ffbefc..811e9b80d44 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -605,6 +605,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $db->begin(); + $nbOrders = is_array($orders) ? count($orders) : 1; + foreach ($orders as $id_order) { $cmd = new Commande($db); @@ -726,7 +728,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } - + $rankedLine = ($nbOrders > 1) ? -1 : $lines[$i]->rang; $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -744,7 +746,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders 'HT', 0, $product_type, - $lines[$i]->rang, + $rankedLine, $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid,