diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 0df79fce096..9a8ab1fa7ef 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -612,10 +612,11 @@ if ($id > 0 || !empty($ref)) {
// if ($mesg) print $mesg;
print ' ';
- $disabled = 1;
+ /*$disabled = 1;
if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$disabled = 0;
- }
+ }*/
+ $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
// Line of orders
if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) {
diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php
index e0f84f24df4..e5f5fccffad 100644
--- a/htdocs/reception/card.php
+++ b/htdocs/reception/card.php
@@ -1031,9 +1031,17 @@ if ($action == 'create') {
print "\n";
}
+ // $objectsrc->lines contains the line of the purchase order
+ // $dispatchLines is list of lines with dispatching detail (with product, qty and warehouse). One purchase order line may have n of this dispatch lines.
+
+ $arrayofpurchaselinealreadyoutput= array();
+
+ // $_POST contains fk_commandefourndet_X_Y where Y is num of product line and X is number of splitted line
$indiceAsked = 1;
- while ($indiceAsked <= $numAsked) {
+ while ($indiceAsked <= $numAsked) { // Loop on $dispatchLines. Warning: $dispatchLines must be sorted by fk_commandefourndet (it is a regroupment key on output)
$product = new Product($db);
+
+ // We search the purchase order line that is linked to the dispatchLines
foreach ($objectsrc->lines as $supplierLine) {
if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) {
$line = $supplierLine;
@@ -1055,7 +1063,6 @@ if ($action == 'create') {
print ''."\n";
print '
'."\n";
-
// Product label
if ($line->fk_product > 0) { // If predefined product
$product->fetch($line->fk_product);
@@ -1064,42 +1071,45 @@ if ($action == 'create') {
print '
';
print ''; // ancre pour retourner sur la ligne
- print '';
+ if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice
+ print '';
- // Show product and description
- $product_static = $product;
+ // Show product and description
+ $product_static = $product;
- $text = $product_static->getNomUrl(1);
- $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label);
- $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc));
- print $form->textwithtooltip($text, $description, 3, '', '', $i);
+ $text = $product_static->getNomUrl(1);
+ $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label);
+ $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc));
+ print $form->textwithtooltip($text, $description, 3, '', '', $i);
- // Show range
- print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
+ // Show range
+ print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
- // Add description in form
- if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
- print ($line->desc && $line->desc != $line->product_label) ? ' '.dol_htmlentitiesbr($line->desc) : '';
+ // Add description in form
+ if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
+ print ($line->desc && $line->desc != $line->product_label) ? ' '.dol_htmlentitiesbr($line->desc) : '';
+ }
}
-
print '
\n";
$extralabelslines = $extrafields->attributes[$line->table_element];
@@ -1756,7 +1774,9 @@ if ($action == 'create') {
//var_dump($alreadysent);
}
- // Loop on each product to send/sent
+ $arrayofpurchaselinealreadyoutput = array();
+
+ // Loop on each product to send/sent. Warning: $lines must be sorted by ->fk_commandefourndet (it is a regroupment key on output)
for ($i = 0; $i < $num_prod; $i++) {
print ''; // id of order line
print '