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