From 5dabcec7671b75f4c978f657aaf1f60e4f4eb44f Mon Sep 17 00:00:00 2001 From: boudet jean pascal <68547382+atm-jpb@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:17:55 +0200 Subject: [PATCH 1/5] rank duplicate on mass action #### rank duplicate on mass action invoice from multiple orders we have to define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several order massaction request. --- htdocs/core/actions_massactions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b98ce37d8f1..5859760d955 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -791,7 +791,10 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. 'HT', 0, $product_type, - $lines[$i]->rang, + + //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders + //-1 will give us the right number + -1, // rank $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, From 244a3fc8199a8969da418aa351aaf9f373b673df Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 4 Jul 2022 15:22:40 +0000 Subject: [PATCH 2/5] Fixing style errors. --- htdocs/core/actions_massactions.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5859760d955..af0ad2a2eaa 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -791,7 +791,6 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. 'HT', 0, $product_type, - //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders //-1 will give us the right number -1, // rank From ea524033391c5fedc3021ddf3ba21df36d8db5dd Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 7 Jul 2022 11:08:01 +0200 Subject: [PATCH 3/5] rank change. if we only have one order we leave the origin rank otherwise we leave the -1 and let the class set the max rank. --- htdocs/core/actions_massactions.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index af0ad2a2eaa..2bebd1ada00 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -641,7 +641,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - + $nbOrders = is_array($orders) ? count($orders) : 1; foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { @@ -773,7 +773,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. } $objecttmp->context['createfromclone']; - + $rankedLine = ($nbOrders > 1) ? -1 : $lines[$i]->rang; $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -793,7 +793,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $product_type, //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders //-1 will give us the right number - -1, // rank + $rankedLine, // rank $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, From 5afe1dbb84e190e6c17f1b2ab8bee157bb0e76ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 20:57:29 +0200 Subject: [PATCH 4/5] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2bebd1ada00..0d279a4ac3d 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -641,7 +641,9 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - $nbOrders = is_array($orders) ? count($orders) : 1; + + $nbOrders = is_array($orders) ? count($orders) : 1; + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { From 7741826d3409f45b9d69a42cc99366556ccde34c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 23:09:39 +0200 Subject: [PATCH 5/5] phpcs --- htdocs/core/actions_massactions.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4f738f68a97..d704d9974f9 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -642,9 +642,9 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - + $nbOrders = is_array($orders) ? count($orders) : 1; - + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) {