diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 40fb5917e89..38ca9ea66d2 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -71,6 +71,8 @@ $object = new Expedition($db); if ($action == 'add') { + $error=0; + $db->begin(); $object->note = $_POST["note"]; @@ -100,23 +102,52 @@ if ($action == 'add') $object->tracking_number = $_POST["tracking_number"]; $object->ref_int = $_POST["ref_int"]; - //var_dump($_POST);exit; - $num=count($objectsrc->lines); + $num=count($objectsrc->lines); + $totalqty=0; for ($i = 0; $i < $num; $i++) { - $qty = "qtyl".$i; - if ($_POST[$qty] > 0) - { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = isset($_POST[$ent])?$_POST[$ent]:$_POST["entrepot_id"]; - - $object->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); - } + $qty = "qtyl".$i; + if ($_POST[$qty] > 0) $totalqty+=$_POST[$qty]; } - $ret=$object->create($user); - if ($ret > 0) + if ($totalqty > 0) + { + //var_dump($_POST);exit; + for ($i = 0; $i < $num; $i++) + { + $qty = "qtyl".$i; + if ($_POST[$qty] > 0) + { + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = isset($_POST[$ent])?$_POST[$ent]:$_POST["entrepot_id"]; + + $ret=$object->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); + if ($ret < 0) + { + $mesg='