dolibarr 19.0.3
salaries.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 */
18
25// Load Dolibarr environment
26require '../../main.inc.php';
27
28// Class
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
31if (isModEnabled('accounting')) {
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
33}
34
35// Load translation files required by the page
36$langs->loadLangs(array('admin', 'salaries'));
37
38// Security check
39if (!$user->admin) {
41}
42
43$action = GETPOST('action', 'aZ09');
44
45// Other parameters SALARIES_*
46$list = array(
47 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
48);
49
50/*
51 * Actions
52 */
53
54if ($action == 'update') {
55 $error = 0;
56
57 foreach ($list as $constname) {
58 $constvalue = GETPOST($constname, 'alpha');
59
60 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
61 $error++;
62 }
63 }
64
65 if (!$error) {
66 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
67 } else {
68 setEventMessages($langs->trans("Error"), null, 'errors');
69 }
70}
71
72$reg = array();
73if (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
74 // Set boolean (on/off) constants
75 if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
76 dol_print_error($db);
77 }
78}
79
80/*
81 * View
82 */
83
84llxHeader('', $langs->trans('SalariesSetup'));
85
86$form = new Form($db);
87if (isModEnabled('accounting')) {
88 $formaccounting = new FormAccounting($db);
89}
90
91$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
92print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
93
94$head = salaries_admin_prepare_head();
95
96print dol_get_fiche_head($head, 'general', $langs->trans("Salaries"), -1, 'payment');
97
98// Document templates
99print load_fiche_titre($langs->trans("Options"), '', '');
100
101print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
102print '<input type="hidden" name="token" value="'.newToken().'">';
103print '<input type="hidden" name="action" value="update">';
104
105/*
106 * Params
107 */
108print '<table class="noborder centpercent">';
109print '<tr class="liste_titre">';
110print '<td>'.$langs->trans("Parameters").'</td>';
111print '<td width="60">'.$langs->trans("Value")."</td>\n";
112print "</tr>\n";
113
114foreach ($list as $key) {
115 print '<tr class="oddeven value">';
116
117 // Param
118 $label = $langs->trans($key);
119 print '<td class="fieldrequired" width="50%"><label for="'.$key.'">'.$label.'</label></td>';
120
121 // Value
122 print '<td>';
123 if (isModEnabled('accounting')) {
124 print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
125 } else {
126 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
127 }
128 print '</td></tr>';
129}
130
131print '</tr>';
132
133print "</table>\n";
134
135//print dol_get_fiche_end();
136
137print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
138
139print '</form><br>';
140
141echo '<div>';
142echo '<table class="noborder centpercent">';
143echo '<thead>';
144echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
145echo '</thead>';
146echo '<tbody>';
147
148$key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
149echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
150
151echo '</tbody>';
152echo '</table>';
153echo '</div>';
154
155// End of page
156llxFooter();
157$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.