dolibarr  x.y.z
hrm.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4  * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5  * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6  * Copyright (C) 2021 GrĂ©gory BLEMAND <gregory.blemand@atm-consulting.fr>
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Load Dolibarr environment
29 require '../main.inc.php';
30 
31 global $langs, $user;
32 
33 // Libraries
34 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
35 require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/hrm/class/skill.class.php';
37 //require_once "../class/myclass.class.php";
38 
39 // Translations
40 $langs->loadLangs(array("admin", "hrm"));
41 
42 // Access control
43 if (!$user->admin) {
45 }
46 
47 // Parameters
48 $action = GETPOST('action', 'aZ09');
49 $backtopage = GETPOST('backtopage', 'alpha');
50 
51 $value = GETPOST('value', 'alpha');
52 $label = GETPOST('label', 'alpha');
53 $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
54 
55 $scandir = GETPOST('scan_dir', 'alpha');
56 $type = 'evaluation';
57 
58 $arrayofparameters = array(
59  'HRM_MAXRANK'=>array('type'=>'integer','enabled'=>1),
60  'HRM_DEFAULT_SKILL_DESCRIPTION'=>array('type'=>'varchar','enabled'=>1),
61 );
62 
63 $error = 0;
64 $setupnotempty = 0;
65 
66 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
67 
68 
69 /*
70  * Actions
71  */
72 
73 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
74 
75 if ($action == 'update') {
76  $max_rank = GETPOST('HRM_MAXRANK', 'int');
77 
78  // We complete skill possible level notation if necessary
79  if (!empty($max_rank)) {
80  $static_skill = new Skill($db);
81  $TAllSkills = $static_skill->fetchAll();
82  if (is_array($TAllSkills)) {
83  foreach ($TAllSkills as &$skill) {
84  if (empty($skill->lines)) $skill->fetchLines();
85  if (count($skill->lines) < $conf->global->HRM_MAXRANK) {
86  $skill->createSkills(count($skill->lines) + 1);
87  }
88  }
89  }
90  }
91 } elseif ($action == 'updateMask') {
92  $maskconst = GETPOST('maskconstEvaluation', 'aZ09');
93  $maskvalue = GETPOST('maskEvaluation', 'alpha');
94 
95  if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
96  $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
97  if (!($res > 0)) {
98  $error++;
99  }
100  }
101 
102  if (!$error) {
103  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
104  } else {
105  setEventMessages($langs->trans("Error"), null, 'errors');
106  }
107 } elseif ($action == 'specimen') {
108  $modele = GETPOST('module', 'alpha');
109  $tmpobjectkey = GETPOST('object');
110 
111  $tmpobject = new $tmpobjectkey($db);
112  $tmpobject->initAsSpecimen();
113 
114  // Search template files
115  $file = ''; $classname = ''; $filefound = 0;
116  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
117  foreach ($dirmodels as $reldir) {
118  $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
119  if (file_exists($file)) {
120  $filefound = 1;
121  $classname = "pdf_".$modele;
122  break;
123  }
124  }
125 
126  if ($filefound) {
127  require_once $file;
128 
129  $module = new $classname($db);
130 
131  if ($module->write_file($tmpobject, $langs) > 0) {
132  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
133  return;
134  } else {
135  setEventMessages($module->error, null, 'errors');
136  dol_syslog($module->error, LOG_ERR);
137  }
138  } else {
139  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
140  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
141  }
142 } elseif ($action == 'setmod') {
143  // TODO Check if numbering module chosen can be activated by calling method canBeActivated
144  $tmpobjectkey = GETPOST('object');
145  if (!empty($tmpobjectkey)) {
146  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey)."_ADDON";
147  dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
148  }
149 } elseif ($action == 'set') {
150  // Activate a model
151  $ret = addDocumentModel($value, $type, $label, $scandir);
152 } elseif ($action == 'del') {
153  $ret = delDocumentModel($value, $type);
154  if ($ret > 0) {
155  $tmpobjectkey = GETPOST('object');
156  if (!empty($tmpobjectkey)) {
157  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
158  if ($conf->global->$constforval == "$value") {
159  dolibarr_del_const($db, $constforval, $conf->entity);
160  }
161  }
162  }
163 } elseif ($action == 'setdoc') {
164  // Set or unset default model
165  $tmpobjectkey = GETPOST('object');
166  if (!empty($tmpobjectkey)) {
167  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
168  if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
169  // The constant that was read before the new set
170  // We therefore requires a variable to have a coherent view
171  $conf->global->$constforval = $value;
172  }
173 
174  // We disable/enable the document template (into llx_document_model table)
175  $ret = delDocumentModel($value, $type);
176  if ($ret > 0) {
177  $ret = addDocumentModel($value, $type, $label, $scandir);
178  }
179  }
180 } elseif ($action == 'unsetdoc') {
181  $tmpobjectkey = GETPOST('object');
182  if (!empty($tmpobjectkey)) {
183  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
184  dolibarr_del_const($db, $constforval, $conf->entity);
185  }
186 }
187 
188 
189 /*
190  * View
191  */
192 
193 $form = new Form($db);
194 
195 $help_url = '';
196 $page_name = "HRMSetup";
197 
198 llxHeader('', $langs->trans($page_name), $help_url);
199 
200 // Subheader
201 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
202 
203 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
204 
205 // Configuration header
206 $head = hrmAdminPrepareHead();
207 print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm");
208 
209 $moduledir = 'hrm';
210 $myTmpObjects = array();
211 $myTmpObjects['evaluation'] = array('label'=>'Evaluation', 'includerefgeneration'=>1, 'includedocgeneration'=>0);
212 
213 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
214  if ($myTmpObjectKey != $type) {
215  continue;
216  }
217  if ($myTmpObjectArray['includerefgeneration']) {
218  /*
219  * Orders Numbering model
220  */
221  $setupnotempty++;
222 
223  print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', '');
224 
225  print '<table class="noborder centpercent">';
226  print '<tr class="liste_titre">';
227  print '<td>'.$langs->trans("Name").'</td>';
228  print '<td>'.$langs->trans("Description").'</td>';
229  print '<td class="nowrap">'.$langs->trans("Example").'</td>';
230  print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
231  print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
232  print '</tr>'."\n";
233 
234  clearstatcache();
235 
236  foreach ($dirmodels as $reldir) {
237  $dir = dol_buildpath($reldir."core/modules/".$moduledir);
238 
239  if (is_dir($dir)) {
240  $handle = opendir($dir);
241  if (is_resource($handle)) {
242  while (($file = readdir($handle)) !== false) {
243  if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
244  $file = substr($file, 0, dol_strlen($file) - 4);
245 
246  require_once $dir.'/'.$file.'.php';
247 
248  $module = new $file($db);
249 
250  // Show modules according to features level
251  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
252  continue;
253  }
254  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
255  continue;
256  }
257 
258  if ($module->isEnabled()) {
259  dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
260 
261  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
262  print $module->info();
263  print '</td>';
264 
265  // Show example of numbering model
266  print '<td class="nowrap">';
267  $tmp = $module->getExample();
268  if (preg_match('/^Error/', $tmp)) {
269  $langs->load("errors");
270  print '<div class="error">'.$langs->trans($tmp).'</div>';
271  } elseif ($tmp == 'NotConfigured') {
272  print $langs->trans($tmp);
273  } else {
274  print $tmp;
275  }
276  print '</td>'."\n";
277 
278  print '<td class="center">';
279  $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
280  if (getDolGlobalString($constforvar) == $file) {
281  print img_picto($langs->trans("Activated"), 'switch_on');
282  } else {
283  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
284  print img_picto($langs->trans("Disabled"), 'switch_off');
285  print '</a>';
286  }
287  print '</td>';
288 
289  $mytmpinstance = new $myTmpObjectKey($db);
290  $mytmpinstance->initAsSpecimen();
291 
292  // Info
293  $htmltooltip = '';
294  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
295 
296  $nextval = $module->getNextValue($mytmpinstance);
297  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
298  $htmltooltip .= ''.$langs->trans("NextValue").': ';
299  if ($nextval) {
300  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
301  $nextval = $langs->trans($nextval);
302  }
303  $htmltooltip .= $nextval.'<br>';
304  } else {
305  $htmltooltip .= $langs->trans($module->error).'<br>';
306  }
307  }
308 
309  print '<td class="center">';
310  print $form->textwithpicto('', $htmltooltip, 1, 0);
311  print '</td>';
312 
313  print "</tr>\n";
314  }
315  }
316  }
317  closedir($handle);
318  }
319  }
320  }
321  print "</table>\n";
322  }
323 
324  if ($myTmpObjectArray['includedocgeneration']) {
325  /*
326  * Document templates generators
327  */
328  $setupnotempty++;
329  $type = strtolower($myTmpObjectKey);
330 
331  print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
332 
333  // Load array def with activated templates
334  $def = array();
335  $sql = "SELECT nom";
336  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
337  $sql .= " WHERE type = '".$db->escape($type)."'";
338  $sql .= " AND entity = ".$conf->entity;
339  $resql = $db->query($sql);
340  if ($resql) {
341  $i = 0;
342  $num_rows = $db->num_rows($resql);
343  while ($i < $num_rows) {
344  $array = $db->fetch_array($resql);
345  array_push($def, $array[0]);
346  $i++;
347  }
348  } else {
349  dol_print_error($db);
350  }
351 
352  print "<table class=\"noborder\" width=\"100%\">\n";
353  print "<tr class=\"liste_titre\">\n";
354  print '<td>'.$langs->trans("Name").'</td>';
355  print '<td>'.$langs->trans("Description").'</td>';
356  print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
357  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
358  print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
359  print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
360  print "</tr>\n";
361 
362  clearstatcache();
363 
364  foreach ($dirmodels as $reldir) {
365  foreach (array('', '/doc') as $valdir) {
366  $realpath = $reldir."core/modules/".$moduledir.$valdir;
367  $dir = dol_buildpath($realpath);
368 
369  if (is_dir($dir)) {
370  $handle = opendir($dir);
371  if (is_resource($handle)) {
372  while (($file = readdir($handle)) !== false) {
373  $filelist[] = $file;
374  }
375  closedir($handle);
376  arsort($filelist);
377 
378  foreach ($filelist as $file) {
379  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
380  if (file_exists($dir.'/'.$file)) {
381  $name = substr($file, 4, dol_strlen($file) - 16);
382  $classname = substr($file, 0, dol_strlen($file) - 12);
383 
384  require_once $dir.'/'.$file;
385  $module = new $classname($db);
386 
387  $modulequalified = 1;
388  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
389  $modulequalified = 0;
390  }
391  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
392  $modulequalified = 0;
393  }
394 
395  if ($modulequalified) {
396  print '<tr class="oddeven"><td width="100">';
397  print (empty($module->name) ? $name : $module->name);
398  print "</td><td>\n";
399  if (method_exists($module, 'info')) {
400  print $module->info($langs);
401  } else {
402  print $module->description;
403  }
404  print '</td>';
405 
406  // Active
407  if (in_array($name, $def)) {
408  print '<td class="center">'."\n";
409  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
410  print img_picto($langs->trans("Enabled"), 'switch_on');
411  print '</a>';
412  print '</td>';
413  } else {
414  print '<td class="center">'."\n";
415  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
416  print "</td>";
417  }
418 
419  // Default
420  print '<td class="center">';
421  $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
422  if (getDolGlobalString($constforvar) == $name) {
423  //print img_picto($langs->trans("Default"), 'on');
424  // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
425  print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
426  } else {
427  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;object='.urlencode(strtolower($myTmpObjectKey)).'&amp;value='.$name.'&amp;scan_dir='.urlencode($module->scandir).'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
428  }
429  print '</td>';
430 
431  // Info
432  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
433  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
434  if ($module->type == 'pdf') {
435  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
436  }
437  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
438 
439  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
440  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
441  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
442 
443  print '<td class="center">';
444  print $form->textwithpicto('', $htmltooltip, 1, 0);
445  print '</td>';
446 
447  // Preview
448  print '<td class="center">';
449  if ($module->type == 'pdf') {
450  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
451  } else {
452  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
453  }
454  print '</td>';
455 
456  print "</tr>\n";
457  }
458  }
459  }
460  }
461  }
462  }
463  }
464  }
465 
466  print '</table>';
467  }
468 }
469 
470 print load_fiche_titre($langs->trans('OtherOptions'), '', '');
471 
472 if (empty($conf->global->HRM_MAXRANK)) {
473  $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
474 }
475 
476 if ($action == 'edit') {
477  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
478  print '<input type="hidden" name="token" value="'.newToken().'">';
479  print '<input type="hidden" name="action" value="update">';
480 
481  print '<table class="noborder centpercent">';
482  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
483 
484  foreach ($arrayofparameters as $constname => $val) {
485  if ($val['enabled']==1) {
486  $setupnotempty++;
487  print '<tr class="oddeven"><td>';
488  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
489  print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
490  print '</td><td>';
491 
492  if ($val['type'] == 'textarea') {
493  print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
494  print getDolGlobalString($constname);
495  print "</textarea>\n";
496  } elseif ($val['type'] == 'integer') {
497  print '<input class="flat" name="' . $constname . '" id="' . $constname . '" value="' . getDolGlobalString($constname) . '" type="number" step="1" min="0" max="50" >' . "\n";
498  } elseif ($val['type'] == 'html') {
499  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
500  $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
501  $doleditor->Create();
502  } elseif ($val['type'] == 'yesno') {
503  print $form->selectyesno($constname, getDolGlobalString($constname), 1);
504  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
505  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
506  $formmail = new FormMail($db);
507 
508  $tmp = explode(':', $val['type']);
509  $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
510  //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
511  $arrayofmessagename = array();
512  if (is_array($formmail->lines_model)) {
513  foreach ($formmail->lines_model as $modelmail) {
514  //var_dump($modelmail);
515  $moreonlabel = '';
516  if (!empty($arrayofmessagename[$modelmail->label])) {
517  $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
518  }
519  // The 'label' is the key that is unique if we exclude the language
520  $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
521  }
522  }
523  print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
524  } elseif (preg_match('/category:/', $val['type'])) {
525  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
526  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
527  $formother = new FormOther($db);
528 
529  $tmp = explode(':', $val['type']);
530  print img_picto('', 'category', 'class="pictofixedwidth"');
531  print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
532  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
533  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
534  $formcompany = new FormCompany($db);
535  print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
536  } elseif ($val['type'] == 'securekey') {
537  print '<input required="required" type="text" class="flat" id="' . $constname . '" name="' . $constname . '" value="' . (GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : $conf->global->{$constname}) . '" size="40">';
538  if (!empty($conf->use_javascript_ajax)) {
539  print '&nbsp;' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"');
540  }
541 
542  // Add button to autosuggest a key
543  include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
544  print dolJSToSetRandomPassword($constname, 'generate_token' . $constname);
545  } elseif ($val['type'] == 'product') {
546  if (isModEnabled('product') || isModEnabled('service')) {
547  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
548  $form->select_produits($selected, $constname, '', 0);
549  }
550  } else {
551  print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . $conf->global->{$constname} . '">';
552  }
553  print '</td></tr>';
554  }
555  }
556  print '</table>';
557 
558  print '<br><div class="center">';
559  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
560  print '</div>';
561 
562  print '</form>';
563  print '<br>';
564 } else {
565  if (!empty($arrayofparameters)) {
566  print '<table class="noborder centpercent">';
567  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
568 
569  foreach ($arrayofparameters as $constname => $val) {
570  if ($val['enabled']==1) {
571  $setupnotempty++;
572  print '<tr class="oddeven"><td>';
573  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
574  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
575  print '</td><td>';
576 
577  if ($val['type'] == 'textarea') {
578  print dol_nl2br(getDolGlobalString($constname));
579  } elseif ($val['type']== 'html') {
580  print getDolGlobalString($constname);
581  } elseif ($val['type'] == 'yesno') {
582  print ajax_constantonoff($constname);
583  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
584  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
585  $formmail = new FormMail($db);
586 
587  $tmp = explode(':', $val['type']);
588 
589  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
590  if ($template<0) {
591  setEventMessages(null, $formmail->errors, 'errors');
592  }
593  print $langs->trans($template->label);
594  } elseif (preg_match('/category:/', $val['type'])) {
595  $c = new Categorie($db);
596  $result = $c->fetch(getDolGlobalString($constname));
597  if ($result < 0) {
598  setEventMessages(null, $c->errors, 'errors');
599  }
600  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
601  $toprint = array();
602  foreach ($ways as $way) {
603  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
604  }
605  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
606  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
607  if ($conf->global->{$constname}==2) {
608  print $langs->trans("Prospect");
609  } elseif ($conf->global->{$constname}==3) {
610  print $langs->trans("ProspectCustomer");
611  } elseif ($conf->global->{$constname}==1) {
612  print $langs->trans("Customer");
613  } elseif ($conf->global->{$constname}==0) {
614  print $langs->trans("NorProspectNorCustomer");
615  }
616  } elseif ($val['type'] == 'product') {
617  $product = new Product($db);
618  $resprod = $product->fetch($conf->global->{$constname});
619  if ($resprod > 0) {
620  print $product->ref;
621  } elseif ($resprod < 0) {
622  setEventMessages(null, $object->errors, "errors");
623  }
624  } else {
625  print getDolGlobalString($constname);
626  }
627  print '</td></tr>';
628  }
629  }
630 
631  print '</table>';
632 
633  print '<div class="tabsAction">';
634  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
635  print '</div>';
636  } else {
637  print '<br>'.$langs->trans("NothingToSetup");
638  }
639 }
640 
641 
642 if (empty($setupnotempty)) {
643  print '<br>'.$langs->trans("NothingToSetup");
644 }
645 
646 // Page end
647 print dol_get_fiche_end();
648 
649 llxFooter();
650 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1888
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
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:556
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1919
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
Definition: ajax.lib.php:601
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 categories.
Class to manage a WYSIWYG editor.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Classe permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
Class for Skill.
Definition: skill.class.php:37
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
hrmAdminPrepareHead()
Prepare admin pages header.
Definition: hrm.lib.php:34
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token')
Ouput javacript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.