dolibarr  17.0.4
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
26 require '../../main.inc.php';
27 
28 // Class
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
31 if (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
39 if (!$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 
54 if ($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();
73 if (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 
84 llxHeader('', $langs->trans('SalariesSetup'));
85 
86 $form = new Form($db);
87 if (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>';
92 print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
93 
94 $head = salaries_admin_prepare_head();
95 
96 print dol_get_fiche_head($head, 'general', $langs->trans("Salaries"), -1, 'payment');
97 
98 // Document templates
99 print load_fiche_titre($langs->trans("Options"), '', '');
100 
101 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
102 print '<input type="hidden" name="token" value="'.newToken().'">';
103 print '<input type="hidden" name="action" value="update">';
104 
105 /*
106  * Params
107  */
108 print '<table class="noborder centpercent">';
109 print '<tr class="liste_titre">';
110 print '<td>'.$langs->trans("Parameters").'</td>';
111 print '<td width="60">'.$langs->trans("Value")."</td>\n";
112 print "</tr>\n";
113 
114 foreach ($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 
131 print '</tr>';
132 
133 print "</table>\n";
134 
135 //print dol_get_fiche_end();
136 
137 print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
138 
139 print '</form><br>';
140 
141 echo '<div>';
142 echo '<table class="noborder centpercent">';
143 echo '<thead>';
144 echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
145 echo '</thead>';
146 echo '<tbody>';
147 
148 $key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
149 echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
150 
151 echo '</tbody>';
152 echo '</table>';
153 echo '</div>';
154 
155 // End of page
156 llxFooter();
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).
Definition: admin.lib.php:632
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:600
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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='')
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.