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