diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 028d5559246..f1dfaafaa62 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1315,6 +1315,7 @@ if ($resql) if (GETPOST('confirm') == 'yes') { $tmpproposal = new Propal($db); $db->begin(); + $error = 0; foreach ($toselect as $checked) { if ($tmpproposal->fetch($checked)) { if ($tmpproposal->statut == 0) { @@ -1322,13 +1323,21 @@ if ($resql) setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; } } else { setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors'); + $error++; } } + dol_print_error($db); + $error++; + } + if ($error){ + $db->rollback(); + } else { + $db->commit(); } - $db->commit(); } } @@ -1336,25 +1345,31 @@ if ($resql) if (GETPOST('confirm') == 'yes') { $tmpproposal = new Propal($db); $db->begin(); + $error = 0; foreach ($toselect as $checked) { - $tmpproposal->fetch($checked); if ($tmpproposal->fetch($checked)) { if ($tmpproposal->statut == 1) { - $sqlp = "UPDATE " . MAIN_DB_PREFIX . "propal SET fk_statut = 2 WHERE rowid = " . $checked; - $resqlp = $db->query($sqlp); - if ($resqlp) { + $tmpproposal->statut = 2; + if ($tmpproposal->update($user)) { setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs'); } else { dol_print_error($db); + $error++; } } else { setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors'); + $error++; } } else { dol_print_error($db); + $error++; } } - $db->commit(); + if ($error){ + $db->rollback(); + } else { + $db->commit(); + } } } } else {