From 309691f1e786e5efec06c2a56273b403ac68d096 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 25 Oct 2020 09:28:41 +0100 Subject: [PATCH] Fix #15143 selected lines on invoice creation --- htdocs/compta/facture/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0b6aff2d14..31c42e5ba9e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -997,6 +997,7 @@ if (empty($reshook)) elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + $selectedLines = GETPOST('toselect', 'array'); $db->begin(); @@ -1586,8 +1587,11 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + // Don't add lines with qty 0 when coming from a shipment including all order lines if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) @@ -3647,8 +3651,6 @@ if ($action == 'create') print ''; print ''; - print "\n"; - // Show origin lines if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '
'; @@ -3658,12 +3660,12 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; } - print '
'; + print "\n"; } elseif ($id > 0 || !empty($ref)) {