From 43ffb061ef2d040a44964d82dd9622ff006f3b92 Mon Sep 17 00:00:00 2001 From: aspangaro <alexandre.spangaro@gmail.com> Date: Wed, 10 Aug 2016 08:07:27 +0200 Subject: [PATCH] FIX : Accountancy - BANK_DISABLE_DIRECT_INPUT Add an option --- htdocs/accountancy/admin/index.php | 26 +++++++++++++++++++++ htdocs/compta/bank/account.php | 15 ++++-------- htdocs/core/modules/modAccounting.class.php | 5 ++++ htdocs/langs/en_US/accountancy.lang | 3 ++- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b019872da6e..0173ac931cc 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -168,6 +168,18 @@ if ($action == 'setmanagezero') { } } +if ($action == 'setdisabledirectinput') { + $setdisabledirectinput = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View */ @@ -342,6 +354,20 @@ if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { } print '</tr>'; +$var = ! $var; +print "<tr " . $bc[$var] . ">"; +print '<td width="80%">' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>'; +if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">'; + print img_picto($langs->trans("Activated"), 'switch_on'); + print '</a></td>'; +} else { + print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">'; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '</a></td>'; +} +print '</tr>'; + print "</table>\n"; dol_fiche_end(); diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 3eb4764bb11..10c52e657ab 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -366,16 +366,11 @@ if ($id > 0 || ! empty($ref)) { if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if (empty($conf->accounting->enabled)) - { - if ($user->rights->banque->modifier) { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&id='.$object->id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").'</a>'; - } else { - print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; - } - } else { - print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; - } + if ($user->rights->banque->modifier) { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&id='.$object->id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").'</a>'; + } else { + print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; + } } else { print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; } diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index af51e01c576..60d99438f4f 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -207,6 +207,11 @@ class modAccounting extends DolibarrModules "chaine", "csv" ); + $this->const[24] = array( + "BANK_DISABLE_DIRECT_INPUT", + "yesno", + "1" + ); // Tabs $this->tabs = array(); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 056466706a1..3c8a431fbb6 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -56,7 +56,8 @@ ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services descripti ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50) ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounts -ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function of length of the accounts. +ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function "length of the accounts". +BANK_DISABLE_DIRECT_INPUT=Disable free input of bank transactions. Enable by default with this module. ACCOUNTING_SELL_JOURNAL=Sell journal ACCOUNTING_PURCHASE_JOURNAL=Purchase journal -- GitLab