diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 0876dd81a19..07034c8389c 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -51,6 +51,7 @@ $confirm = GETPOST('confirm', 'alpha');
$chartofaccounts = GETPOST('chartofaccounts', 'int');
+$permissiontoadd = $user->rights->accounting->chartofaccount;
$permissiontodelete = $user->rights->accounting->chartofaccount;
// Security check
@@ -118,9 +119,11 @@ if (empty($reshook)) {
if (!empty($cancel)) {
$action = '';
}
+
$objectclass = 'AccountingAccount';
$uploaddir = $conf->accounting->multidir_output[$conf->entity];
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+
if ($action == "delete") {
$action = "";
}
@@ -136,7 +139,7 @@ if (empty($reshook)) {
}
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) {
+ 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;
@@ -180,7 +183,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'disable') {
+ if ($action == 'disable' && $permissiontoadd) {
if ($accounting->fetch($id)) {
$mode = GETPOST('mode', 'int');
$result = $accounting->accountDeactivate($id, $mode);
@@ -190,7 +193,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 caf98c7d91c..b629e45cf0d 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');
@@ -139,7 +138,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);
@@ -148,7 +147,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);
@@ -169,13 +168,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
@@ -316,13 +316,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 ' |
';
@@ -368,13 +372,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 4e56b5bfa2f..a0764a97af2 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -58,17 +58,40 @@ $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;
if (!$error) {
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
-
+ var_dump($constname);
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
@@ -268,11 +291,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 ' | ';
}
@@ -282,11 +305,11 @@ 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 ' | ';
}
@@ -295,11 +318,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 ' | ';
}
@@ -336,11 +359,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 ' | ';
}
@@ -349,11 +372,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 ' | ';
}
@@ -385,7 +408,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 '';
@@ -398,7 +421,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 '';
@@ -411,7 +434,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 380a747a53a..1afe803c8e2 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -209,7 +209,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.
| | |