FIX Presentation of qty already order duplicated on reception card

This commit is contained in:
Laurent Destailleur 2022-01-28 15:51:18 +01:00
parent 2e525a719d
commit 4b5792899e
2 changed files with 106 additions and 74 deletions

View File

@ -612,10 +612,11 @@ if ($id > 0 || !empty($ref)) {
// if ($mesg) print $mesg; // if ($mesg) print $mesg;
print '<br>'; print '<br>';
$disabled = 1; /*$disabled = 1;
if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$disabled = 0; $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 // Line of orders
if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) { if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) {

View File

@ -1031,9 +1031,17 @@ if ($action == 'create') {
print "</tr>\n"; print "</tr>\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; $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); $product = new Product($db);
// We search the purchase order line that is linked to the dispatchLines
foreach ($objectsrc->lines as $supplierLine) { foreach ($objectsrc->lines as $supplierLine) {
if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) {
$line = $supplierLine; $line = $supplierLine;
@ -1055,7 +1063,6 @@ if ($action == 'create') {
print '<!-- line fk_commandefourndet='.$line->id.' for product='.$line->fk_product.' -->'."\n"; print '<!-- line fk_commandefourndet='.$line->id.' for product='.$line->fk_product.' -->'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
// Product label // Product label
if ($line->fk_product > 0) { // If predefined product if ($line->fk_product > 0) { // If predefined product
$product->fetch($line->fk_product); $product->fetch($line->fk_product);
@ -1064,6 +1071,7 @@ if ($action == 'create') {
print '<td>'; print '<td>';
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice
print '<input type="hidden" name="productid'.$indiceAsked.'" value="'.$line->fk_product.'">'; print '<input type="hidden" name="productid'.$indiceAsked.'" value="'.$line->fk_product.'">';
// Show product and description // Show product and description
@ -1081,10 +1089,11 @@ if ($action == 'create') {
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
print ($line->desc && $line->desc != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->desc) : ''; print ($line->desc && $line->desc != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->desc) : '';
} }
}
print '</td>'; print '</td>';
} else { } else {
print "<td>"; print "<td>";
if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice
if ($type == 1) { if ($type == 1) {
$text = img_object($langs->trans('Service'), 'service'); $text = img_object($langs->trans('Service'), 'service');
} else { } else {
@ -1100,6 +1109,7 @@ if ($action == 'create') {
// Show range // Show range
print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
}
print "</td>\n"; print "</td>\n";
} }
@ -1110,8 +1120,11 @@ if ($action == 'create') {
print '<input type="text" class="maxwidth100" name="comment'.$indiceAsked.'" value="'.$defaultcomment.'">'; print '<input type="text" class="maxwidth100" name="comment'.$indiceAsked.'" value="'.$defaultcomment.'">';
print '</td>'; print '</td>';
// Qty // Qty in source purchase order line
print '<td class="center">'.$line->qty; print '<td class="center">';
if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice
print $line->qty;
}
print '<input type="hidden" name="fk_commandefournisseurdet'.$indiceAsked.'" value="'.$line->id.'">'; print '<input type="hidden" name="fk_commandefournisseurdet'.$indiceAsked.'" value="'.$line->id.'">';
print '<input type="hidden" name="pul'.$indiceAsked.'" value="'.$line->pu_ht.'">'; print '<input type="hidden" name="pul'.$indiceAsked.'" value="'.$line->pu_ht.'">';
print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">'; print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">';
@ -1121,7 +1134,9 @@ if ($action == 'create') {
// Qty already received // Qty already received
print '<td class="center">'; print '<td class="center">';
$quantityDelivered = $objectsrc->receptions[$line->id]; $quantityDelivered = $objectsrc->receptions[$line->id];
if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice
print $quantityDelivered; print $quantityDelivered;
}
print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">'; print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">';
print '</td>'; print '</td>';
@ -1190,6 +1205,9 @@ if ($action == 'create') {
} }
} }
} }
$arrayofpurchaselinealreadyoutput[$line->id] = $line->id;
print "</tr>\n"; print "</tr>\n";
$extralabelslines = $extrafields->attributes[$line->table_element]; $extralabelslines = $extrafields->attributes[$line->table_element];
@ -1756,7 +1774,9 @@ if ($action == 'create') {
//var_dump($alreadysent); //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++) { for ($i = 0; $i < $num_prod; $i++) {
print '<!-- origin line id = '.$lines[$i]->origin_line_id.' -->'; // id of order line print '<!-- origin line id = '.$lines[$i]->origin_line_id.' -->'; // id of order line
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -1778,7 +1798,7 @@ if ($action == 'create') {
} }
print '<td>'; print '<td>';
if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
$text = $lines[$i]->product->getNomUrl(1); $text = $lines[$i]->product->getNomUrl(1);
$text .= ' - '.$label; $text .= ' - '.$label;
$description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description));
@ -1787,9 +1807,11 @@ if ($action == 'create') {
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '<br>'.dol_htmlentitiesbr($lines[$i]->description) : ''; print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '<br>'.dol_htmlentitiesbr($lines[$i]->description) : '';
} }
}
print "</td>\n"; print "</td>\n";
} else { } else {
print "<td>"; print "<td>";
if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
if ($lines[$i]->product_type == Product::TYPE_SERVICE) { if ($lines[$i]->product_type == Product::TYPE_SERVICE) {
$text = img_object($langs->trans('Service'), 'service'); $text = img_object($langs->trans('Service'), 'service');
} else { } else {
@ -1804,6 +1826,7 @@ if ($action == 'create') {
} }
print_date_range($lines[$i]->date_start, $lines[$i]->date_end); print_date_range($lines[$i]->date_start, $lines[$i]->date_end);
}
print "</td>\n"; print "</td>\n";
} }
@ -1815,11 +1838,16 @@ if ($action == 'create') {
// Qty ordered // Qty ordered
print '<td class="center">'.$lines[$i]->qty_asked.'</td>'; print '<td class="center">';
if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
print $lines[$i]->qty_asked;
}
print '</td>';
// Qty in other receptions (with reception and warehouse used) // Qty in other receptions (with reception and warehouse used)
if ($origin && $origin_id > 0) { if ($origin && $origin_id > 0) {
print '<td class="center nowrap">'; print '<td class="center nowrap">';
if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
foreach ($alreadysent as $key => $val) { foreach ($alreadysent as $key => $val) {
if ($lines[$i]->fk_commandefourndet == $key) { if ($lines[$i]->fk_commandefourndet == $key) {
$j = 0; $j = 0;
@ -1846,6 +1874,7 @@ if ($action == 'create') {
} }
} }
} }
}
print '</td>'; print '</td>';
if ($action == 'editline' && $lines[$i]->id == $line_id) { if ($action == 'editline' && $lines[$i]->id == $line_id) {
@ -1971,6 +2000,8 @@ if ($action == 'create') {
} }
print "</tr>"; print "</tr>";
$arrayofpurchaselinealreadyoutput[$lines[$i]->fk_commandefourndet] = $lines[$i]->fk_commandefourndet;
// Display lines extrafields // Display lines extrafields
$extralabelslines = $extrafields->attributes[$lines[$i]->table_element]; $extralabelslines = $extrafields->attributes[$lines[$i]->table_element];
if (is_array($extralabelslines) && count($extralabelslines) > 0) { if (is_array($extralabelslines) && count($extralabelslines) > 0) {