From 4c52a6ee6f4c3ca4a4c5f78c3e9cadc7dd8f4343 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 10 Sep 2014 04:53:18 +0200 Subject: [PATCH] Add admin page into salaries to manage accountancy --- htdocs/admin/salaries.php | 118 ++++++++++++++++++++++ htdocs/core/modules/modSalaries.class.php | 13 ++- htdocs/langs/en_US/salaries.lang | 2 + 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 htdocs/admin/salaries.php diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php new file mode 100644 index 00000000000..453db8e4203 --- /dev/null +++ b/htdocs/admin/salaries.php @@ -0,0 +1,118 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file htdocs/admin/salaries.php + * \ingroup Salaries + * \brief Setup page to configure salaries module + */ + +require '../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("salaries"); + +// Security check +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters COMPTA_* & ACCOUNTING_* +$list = array ( + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', + 'SALARIES_ACCOUNTING_ACCOUNT_CHARGE' +); + +/* + * Actions + */ + +if ($action == 'update') +{ + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans('ConfigSalaries'),$linkback,'setup'); + +print '
'; +print ''; +print ''; + +/* + * Params + */ +print ''; +print ''; +print ''; +print "\n"; + +foreach ($list as $key) +{ + $var=!$var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; + +print ''; +print "
' . $langs->trans('Options') . '
'; + print ''; + print '
\n"; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index f8a99b99aab..c82e3d83784 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,7 +67,7 @@ class modSalaries extends DolibarrModules $this->dirs = array("/salaries/temp"); // Config pages - $this->config_page_url = array(); + $this->config_page_url = array('salaries.php'); // Dependances $this->depends = array(); @@ -76,6 +77,16 @@ class modSalaries extends DolibarrModules // Constants $this->const = array(); + $this->const[0] = array( + "SALARIES_ACCOUNTING_ACCOUNT_PAYMENT", + "chaine", + "421" + ); + $this->const[1] = array( + "SALARIES_ACCOUNTING_ACCOUNT_CHARGE", + "chaine", + "641" + ); // Boxes $this->boxes = array(); diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index edca71a1829..84eba6fc2bd 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - users +SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accountancy code for salaries payments +SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accountancy code for financial charge Salary=Salary Salaries=Salaries Employee=Employee