diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index f6633f279d5..883018b259b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -236,8 +236,13 @@ if ($action == 'update') $error++; } - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $db->begin(); + + if (! $error) + { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + } if (! $error) { @@ -252,10 +257,20 @@ if ($action == 'update') } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action='edit'; // Force chargement page edition } } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } } if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) @@ -412,7 +427,7 @@ if ($action == 'create') $doleditor->Create(); print ''; - // Other attributes + // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -639,12 +654,12 @@ else print ''.$langs->trans("AccountancyJournal").''; print ''; - if ($object->fk_accountancy_journal > 0) { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($object->fk_accountancy_journal); + if ($object->fk_accountancy_journal > 0) { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($object->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } print ''; }