dolibarr  16.0.5
admin_hrm.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 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 
23 require '../../main.inc.php';
24 require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
26 
27 // Load translation files required by the page
28 $langs->loadLangs(array('admin', 'hrm'));
29 
30 $action = GETPOST('action', 'aZ09');
31 
32 // Other parameters HRM_*
33 $list = array(
34 // 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example
35 );
36 
37 $permissiontoread = $user->admin;
38 $permissiontoadd = $user->admin;
39 
40 // Security check - Protection if external user
41 //if ($user->socid > 0) accessforbidden();
42 //if ($user->socid > 0) $socid = $user->socid;
43 //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
44 //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0);
45 if (empty($conf->hrm->enabled)) accessforbidden();
46 if (empty($permissiontoread)) accessforbidden();
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 
72 /*
73  * View
74  */
75 
76 
77 $title = $langs->trans('Parameters');
78 
79 llxHeader('', $title, '');
80 
81 $form = new Form($db);
82 
83 dol_htmloutput_mesg($mesg);
84 
85 // Subheader
86 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
87 print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
88 
89 // Configuration header
90 $head = hrm_admin_prepare_head();
91 
92 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
93 print '<input type="hidden" name="token" value="'.newToken().'">';
94 print '<input type="hidden" name="action" value="update">';
95 
96 print dol_get_fiche_head($head, 'parameters', $langs->trans("HRM"), -1, "user");
97 
98 print '<table class="noborder centpercent">';
99 print '<tr class="liste_titre">';
100 print '<td colspan="3">'.$langs->trans('Parameters').'</td>';
101 print "</tr>\n";
102 
103 foreach ($list as $key) {
104  print '<tr class="oddeven value">';
105 
106  // Param
107  $label = $langs->trans($key);
108  print '<td width="50%"><label for="'.$key.'">'.$label.'</label></td>';
109 
110  // Value
111  print '<td>';
112  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
113  print '</td></tr>';
114 }
115 
116 print "</table>\n";
117 
118 print dol_get_fiche_end();
119 
120 print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
121 
122 print '</form>';
123 
124 // End of page
125 llxFooter();
126 $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
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
hrm_admin_prepare_head
hrm_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: hrm.lib.php:81
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
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dol_htmloutput_mesg
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
Definition: functions.lib.php:8299
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