Commit 8ca969b74c295eadecffd2aa9444127e68e24720

Authored by aspangaro
1 parent 4af9730c
Exists in 3.5 and in 1 other branch 3.6

Fix :: When you cancel in mode account create, no empty account are created

Showing 1 changed file with 42 additions and 36 deletions   Show diff stats
accountingex/admin/fiche.php
... ... @@ -18,9 +18,9 @@
18 18 */
19 19  
20 20 /**
21   - * \file accountingex/admin/fiche.php
22   - * \ingroup Accounting Expert
23   - * \brief Page fiche de compte
  21 + * \file accountancyex/admin/fiche.php
  22 + * \ingroup Accounting Expert
  23 + * \brief Card accounting account
24 24 */
25 25 $res = @include ("../main.inc.php");
26 26 if (! $res && file_exists("../main.inc.php"))
... ... @@ -32,7 +32,7 @@ if (! $res && file_exists("../../../main.inc.php"))
32 32 if (! $res)
33 33 die("Include of main fails");
34 34  
35   - // Class
  35 +// Class
36 36 dol_include_once("/accountingex/core/lib/account.lib.php");
37 37 dol_include_once("/accountingex/class/accountingaccount.class.php");
38 38 dol_include_once("/accountingex/class/html.formventilation.class.php");
... ... @@ -53,38 +53,44 @@ if (! $user->rights->accountingex->admin)
53 53 accessforbidden();
54 54 $accounting = new AccountingAccount($db);
55 55  
56   -// action
57   -if ($action == 'add') {
58   - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
59   -
60   - dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
61   - $result = $db->query($sql);
62   - $obj = $db->fetch_object($result);
63   -
64   - $accounting->fk_pcg_version = $obj->pcg_version;
65   - $accounting->pcg_type = GETPOST('pcg_type');
66   - $accounting->pcg_subtype = GETPOST('pcg_subtype');
67   - $accounting->account_number = GETPOST('account_number', 'int');
68   - $accounting->account_parent = GETPOST('account_parent', 'int');
69   - $accounting->label = GETPOST('label', 'alpha');
70   - $accounting->active = 1;
71   -
72   - $res = $accounting->create($user);
73   -
74   - if ($res == 0) {
75   - } else {
76   - if ($res == - 3) {
77   - $_error = 1;
78   - $action = "create";
79   - }
80   - if ($res == - 4) {
81   - $_error = 2;
82   - $action = "create";
  56 +// Action
  57 +if ($action == 'add')
  58 +{
  59 + if (! GETPOST('cancel', 'alpha')) {
  60 + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
  61 +
  62 + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
  63 + $result = $db->query($sql);
  64 + $obj = $db->fetch_object($result);
  65 +
  66 + $accounting->fk_pcg_version = $obj->pcg_version;
  67 + $accounting->pcg_type = GETPOST('pcg_type');
  68 + $accounting->pcg_subtype = GETPOST('pcg_subtype');
  69 + $accounting->account_number = GETPOST('account_number', 'int');
  70 + $accounting->account_parent = GETPOST('account_parent', 'int');
  71 + $accounting->label = GETPOST('label', 'alpha');
  72 + $accounting->active = 1;
  73 +
  74 + $res = $accounting->create($user);
  75 +
  76 + if ($res == 0) {
  77 + } else {
  78 + if ($res == - 3) {
  79 + $_error = 1;
  80 + $action = "create";
  81 + }
  82 + if ($res == - 4) {
  83 + $_error = 2;
  84 + $action = "create";
  85 + }
83 86 }
84 87 }
85 88 Header("Location: account.php");
86   -} elseif ($action == 'edit') {
87   - if (! GETPOST('cancel', 'alpha')) {
  89 +}
  90 +elseif ($action == 'edit')
  91 +{
  92 + if (! GETPOST('cancel', 'alpha'))
  93 + {
88 94 $result = $accounting->fetch($id);
89 95  
90 96 $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
... ... @@ -268,9 +274,9 @@ if ($action == 'create') {
268 274  
269 275 print '</div>';
270 276  
271   - /*
272   - * Barre d'actions
273   - */
  277 + /*
  278 + * Barre d'actions
  279 + */
274 280  
275 281 print '<div class="tabsAction">';
276 282  
... ...