diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e8a716c10f0..04d895fd015 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -653,7 +653,6 @@ if (empty($reshook)) else if ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('save')) { // Clean parameters - $qty=0; $entrepot_id = 0; $batch_id = 0; @@ -662,9 +661,8 @@ if (empty($reshook)) $num_prod = count($lines); for ($i = 0 ; $i < $num_prod ; $i++) { - if ($lines[$i]->id == $line_id) + if ($lines[$i]->id == $line_id) // we have found line to update { - // line to update $line = new ExpeditionLigne($db); // Extrafields Lines $extrafieldsline = new ExtraFields($db); @@ -796,46 +794,61 @@ if (empty($reshook)) } else { - // line without lot - if ($lines[$i]->entrepot_id > 0) + if ($lines[$i]->fk_product > 0) + { + // line without lot + if ($lines[$i]->entrepot_id > 0) + { + // single warehouse shipment line + $stockLocation="entl".$line_id; + $qty = "qtyl".$line_id; + $line->id = $line_id; + $line->entrepot_id = GETPOST($stockLocation,'int'); + $line->qty = GETPOST($qty, 'int'); + if ($line->update($user) < 0) { + setEventMessages($line->error, $line->errors, 'errors'); + $error++; + } + unset($_POST[$stockLocation]); + unset($_POST[$qty]); + } + else if (count($lines[$i]->details_entrepot) > 1) + { + // multi warehouse shipment lines + foreach ($lines[$i]->details_entrepot as $detail_entrepot) + { + if (! $error) { + $stockLocation="entl".$detail_entrepot->line_id; + $qty = "qtyl".$detail_entrepot->line_id; + $warehouse = GETPOST($stockLocation,'int'); + if (!empty ($warehouse)) + { + $line->id = $detail_entrepot->line_id; + $line->entrepot_id = $warehouse; + $line->qty = GETPOST($qty, 'int'); + if ($line->update($user) < 0) { + setEventMessages($line->error, $line->errors, 'errors'); + $error++; + } + } + unset($_POST[$stockLocation]); + unset($_POST[$qty]); + } + } + } + } + else // Product no predefined { - // single warehouse shipment line - $stockLocation="entl".$line_id; $qty = "qtyl".$line_id; $line->id = $line_id; - $line->entrepot_id = GETPOST($stockLocation,'int'); $line->qty = GETPOST($qty, 'int'); + $line->entrepot_id = 0; if ($line->update($user) < 0) { setEventMessages($line->error, $line->errors, 'errors'); $error++; } - unset($_POST[$stockLocation]); unset($_POST[$qty]); } - else if (count($lines[$i]->details_entrepot) > 1) - { - // multi warehouse shipment lines - foreach ($lines[$i]->details_entrepot as $detail_entrepot) - { - if (! $error) { - $stockLocation="entl".$detail_entrepot->line_id; - $qty = "qtyl".$detail_entrepot->line_id; - $warehouse = GETPOST($stockLocation,'int'); - if (!empty ($warehouse)) - { - $line->id = $detail_entrepot->line_id; - $line->entrepot_id = $warehouse; - $line->qty = GETPOST($qty, 'int'); - if ($line->update($user) < 0) { - setEventMessages($line->error, $line->errors, 'errors'); - $error++; - } - } - unset($_POST[$stockLocation]); - unset($_POST[$qty]); - } - } - } } } } @@ -2010,9 +2023,8 @@ else if ($id || $ref) print '
'; - /* - * Lines of products - */ + // Lines of products + if ($action == 'editline') { print '