From 024cecec29465e12c7967860f469cee3a83adc1e Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 27 Feb 2017 11:16:46 +0100
Subject: [PATCH] FIX Error management during bank account creation

---
 htdocs/compta/bank/card.php | 9 +++++++++
 1 file changed, 9 insertions(+)

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