for ($i = 0; $i < $_POST["max_prod"]; $i++) { if ($_POST["prod_qty_" . $i] > 0) { if ($object->add_sousproduit($id, $_POST["prod_id_" . $i], $_POST["prod_qty_" . $i], $_POST["prod_incdec_" . $i]) > 0) { //var_dump($id.' - '.$_POST["prod_id_".$i].' - '.$_POST["prod_qty_".$i]);exit; $action = 'edit'; } else { $error++; $action = 're-edit'; if ($object->error == "isFatherOfThis") { setEventMessage($langs->trans("ErrorAssociationIsFatherOfThis"), 'errors'); } else { setEventMessage($object->error, 'errors'); } } } else { if ($object->del_sousproduit($id, $_POST["prod_id_" . $i]) > 0) { $action = 'edit'; } else { $error++; $action = 're-edit'; setEventMessage($object->error, 'errors'); } } } if (!$error) { header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id); exit; } } else { if ($action === 'save_composed_product') { $TProduct = GETPOST('TProduct', 'array');
{ if($product->add_sousproduit($id, $_POST["prod_id_".$i],$_POST["prod_qty_".$i]) > 0) { $action = 'edit'; } else { $error++; $action = 're-edit'; if ($product->error == "isFatherOfThis") $mesg = $langs->trans("ErrorAssociationIsFatherOfThis"); else $mesg=$product->error; } } else { if ($product->del_sousproduit($id, $_POST["prod_id_".$i]) > 0) { $action = 'edit'; } else { $error++; $action = 're-edit'; $mesg=$product->error; } } } if (! $error) { header("Location: ".$_SERVER["PHP_SELF"].'?id='.$product->id); exit;