Przeglądaj źródła

FIX Error management during bank account creation

Laurent Destailleur 8 lat temu
rodzic
commit
024cecec29
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      htdocs/compta/bank/card.php

+ 9 - 0
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
         }