From 7004747ca3b7da741d84f19d49cbf18c1b1d3491 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Apr 2021 09:46:50 +0200 Subject: [PATCH] Add more tooltips on edition of accounting account Fix setup of accountancy Conflicts: htdocs/accountancy/admin/account.php --- htdocs/accountancy/admin/account.php | 14 ++++---- htdocs/accountancy/admin/card.php | 40 +++++++++++++--------- htdocs/accountancy/admin/index.php | 51 ++++++++++++++++++++-------- htdocs/langs/en_US/accountancy.lang | 2 +- 4 files changed, 69 insertions(+), 38 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ca5c10ec63d..caa443ba589 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -48,6 +48,9 @@ $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); $chartofaccounts = GETPOST('chartofaccounts', 'int'); +$permissiontoadd = $user->rights->accounting->chartofaccount; +$permissiontodelete = $user->rights->accounting->chartofaccount; + // Security check if ($user->socid > 0) accessforbidden(); if (!$user->rights->accounting->chartofaccount) accessforbidden(); @@ -79,7 +82,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable' $accounting = new AccountingAccount($db); - /* * Actions */ @@ -107,10 +109,8 @@ if (empty($reshook)) $search_array_options = array(); } if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on - || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified - { - if ($chartofaccounts > 0) - { + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) { // a submit of form is done and chartofaccounts combo has been modified + if ($chartofaccounts > 0 && $permissiontoadd) { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; @@ -156,7 +156,7 @@ if (empty($reshook)) } } - if ($action == 'disable') { + if ($action == 'disable' && $permissiontoadd) { if ($accounting->fetch($id)) { $mode = GETPOST('mode', 'int'); $result = $accounting->accountDeactivate($id, $mode); @@ -166,7 +166,7 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($accounting->error, $accounting->errors, 'errors'); } - } elseif ($action == 'enable') { + } elseif ($action == 'enable' && $permissiontoadd) { if ($accounting->fetch($id)) { $mode = GETPOST('mode', 'int'); $result = $accounting->account_activate($id, $mode); diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 23ebde7e230..c44c0d4adb0 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -34,7 +34,6 @@ $error = 0; // Load translation files required by the page $langs->loadLangs(array("bills", "accountancy", "compta")); -$mesg = ''; $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $id = GETPOST('id', 'int'); @@ -141,7 +140,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) } else { $result = $object->fetch($id); - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS); dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); @@ -150,7 +149,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) // Clean code // To manage zero or not at the end of the accounting account - if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { + if (isset($conf->global->ACCOUNTING_MANAGE_ZERO) && $conf->global->ACCOUNTING_MANAGE_ZERO == 1) { $account_number = $account_number; } else { $account_number = clean_account($account_number); @@ -171,13 +170,12 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->labelshort = GETPOST('labelshort', 'alpha'); $result = $object->update($user); - if ($result > 0) { $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"] . "?id=" . $id); header("Location: " . $urltogo); exit(); } else { - $mesg = $object->error; + setEventMessages($object->error, null, 'errors'); } } } else { @@ -255,13 +253,17 @@ if ($action == 'create') { print ''; // Chart of accounts type - print ''.$langs->trans("Pcgtype").''; + print ''; + print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); + print ''; print ''; print ''; print ''; // Category - print ''.$langs->trans("AccountingCategory").''; + print ''; + print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); + print ''; print ''; $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); print ''; @@ -281,8 +283,6 @@ if ($action == 'create') { $result = $object->fetch($id, $ref, 1); if ($result > 0) { - dol_htmloutput_mesg($mesg); - $head = accounting_prepare_head($object); // Edit mode @@ -317,13 +317,17 @@ if ($action == 'create') { print ''; // Chart of accounts type - print ''.$langs->trans("Pcgtype").''; + print ''; + print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); + print ''; print ''; print ''; print ''; // Category - print ''.$langs->trans("AccountingCategory").''; + print ''; + print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); + print ''; print ''; $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); print ''; @@ -369,13 +373,17 @@ if ($action == 'create') { print ''.$langs->trans("Accountparent").''; print ''.$accp->account_number.' - '.$accp->label.''; - // Category - print "".$langs->trans("AccountingCategory")."".$object->account_category_label.""; - - // Chart of accounts type - print ''.$langs->trans("Pcgtype").''; + // Group of accounting account + print ''; + print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc")); + print ''; print ''.$object->pcg_type.''; + // Custom group of accounting account + print ""; + print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); + print "".$object->account_category_label.""; + print ''; print ''; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 2febe354f2e..5f40022518b 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -58,10 +58,33 @@ $list_binding = array( 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER' ); +$error = 0; + + /* * Actions */ +if (in_array($action, array( + 'setBANK_DISABLE_DIRECT_INPUT', + 'setACCOUNTANCY_COMBO_FOR_AUX', + 'setACCOUNTING_MANAGE_ZERO', + 'setACCOUNTING_LIST_SORT_VENTILATION_TODO', + 'setACCOUNTING_LIST_SORT_VENTILATION_DONE'))) { + $constname = preg_replace('/^set/', '', $action); + $constvalue = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + if ($action == 'update') { $error = 0; @@ -70,7 +93,7 @@ if ($action == 'update') { foreach ($list as $constname) { $constvalue = GETPOST($constname, 'alpha'); - + var_dump($constname); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error++; } @@ -271,11 +294,11 @@ print ''; print ''; print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -284,11 +307,11 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -297,11 +320,11 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -337,11 +360,11 @@ print "\n"; print ''; print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -350,11 +373,11 @@ print ''; print ''; print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -387,7 +410,7 @@ print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").''; if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; } else { print ''; @@ -400,7 +423,7 @@ print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").''; if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; } else { print ''; @@ -413,7 +436,7 @@ print ''; print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").''; if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); print ''; } else { print ''; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index bda6502aeed..e65eb2c3e14 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -207,7 +207,7 @@ Codejournal=Journal JournalLabel=Journal label NumPiece=Piece number TransactionNumShort=Num. transaction -AccountingCategory=Personalized groups +AccountingCategory=Custom group GroupByAccountAccounting=Group by general ledger account GroupBySubAccountAccounting=Group by subledger account AccountingAccountGroupsDesc=You can define here some groups of accounting account. They will be used for personalized accounting reports.