dolibarr  16.0.5
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 require '../../main.inc.php';
26 
27 // Class
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
30 if (isModEnabled('accounting')) {
31  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
32 }
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('admin', 'salaries'));
36 
37 // Security check
38 if (!$user->admin) {
40 }
41 
42 $action = GETPOST('action', 'aZ09');
43 
44 // Other parameters SALARIES_*
45 $list = array(
46  'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
47 );
48 
49 /*
50  * Actions
51  */
52 
53 if ($action == 'update') {
54  $error = 0;
55 
56  foreach ($list as $constname) {
57  $constvalue = GETPOST($constname, 'alpha');
58 
59  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
60  $error++;
61  }
62  }
63 
64  if (!$error) {
65  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
66  } else {
67  setEventMessages($langs->trans("Error"), null, 'errors');
68  }
69 }
70 
71 $reg = array();
72 if (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
73  // Set boolean (on/off) constants
74  if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
75  dol_print_error($db);
76  }
77 }
78 
79 /*
80  * View
81  */
82 
83 llxHeader('', $langs->trans('SalariesSetup'));
84 
85 $form = new Form($db);
86 if (isModEnabled('accounting')) {
87  $formaccounting = new FormAccounting($db);
88 }
89 
90 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
91 print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
92 
93 $head = salaries_admin_prepare_head();
94 
95 print dol_get_fiche_head($head, 'general', $langs->trans("Salaries"), -1, 'payment');
96 
97 // Document templates
98 print load_fiche_titre($langs->trans("Options"), '', '');
99 
100 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
101 print '<input type="hidden" name="token" value="'.newToken().'">';
102 print '<input type="hidden" name="action" value="update">';
103 
104 /*
105  * Params
106  */
107 print '<table class="noborder centpercent">';
108 print '<tr class="liste_titre">';
109 print '<td>'.$langs->trans("Parameters").'</td>';
110 print '<td width="60">'.$langs->trans("Value")."</td>\n";
111 print "</tr>\n";
112 
113 foreach ($list as $key) {
114  print '<tr class="oddeven value">';
115 
116  // Param
117  $label = $langs->trans($key);
118  print '<td class="fieldrequired" width="50%"><label for="'.$key.'">'.$label.'</label></td>';
119 
120  // Value
121  print '<td>';
122  if (isModEnabled('accounting')) {
123  print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
124  } else {
125  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
126  }
127  print '</td></tr>';
128 }
129 
130 print '</tr>';
131 
132 print "</table>\n";
133 
134 //print dol_get_fiche_end();
135 
136 print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
137 
138 print '</form><br>';
139 
140 echo '<div>';
141 echo '<table class="noborder centpercent">';
142 echo '<thead>';
143 echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
144 echo '</thead>';
145 echo '<tbody>';
146 
147 $key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
148 echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
149 
150 echo '</tbody>';
151 echo '</table>';
152 echo '</div>';
153 
154 // End of page
155 llxFooter();
156 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
dolibarr_set_const
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).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59