FIX Error management during bank account creation

This commit is contained in:
Laurent Destailleur 2017-02-27 11:16:46 +01:00
parent 0f8a8869cb
commit 024cecec29

View File

@ -60,9 +60,11 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($account->table_element); $extralabels=$extrafields->fetch_name_optionals_label($account->table_element);
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
$error=0; $error=0;
@ -129,6 +131,8 @@ if ($_POST["action"] == 'add')
if (! $error) if (! $error)
{ {
$db->begin();
$id = $account->create($user); $id = $account->create($user);
if ($id > 0) if ($id > 0)
{ {
@ -137,8 +141,13 @@ if ($_POST["action"] == 'add')
$account->setCategories($categories); $account->setCategories($categories);
$_GET["id"]=$id; // Force chargement page en mode visu $_GET["id"]=$id; // Force chargement page en mode visu
$action='';
$db->commit();
} }
else { else {
$db->rollback();
setEventMessages($account->error, $account->errors, 'errors'); setEventMessages($account->error, $account->errors, 'errors');
$action='create'; // Force chargement page en mode creation $action='create'; // Force chargement page en mode creation
} }