dolibarr  17.0.4
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 if ((float) DOL_VERSION >= 6) {
74  include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
75 }
76 
77 if ($action == 'update') {
78  $max_rank = GETPOST('HRM_MAXRANK', 'int');
79 
80  // We complete skill possible level notation if necessary
81  if (!empty($max_rank)) {
82  $static_skill = new Skill($db);
83  $TAllSkills = $static_skill->fetchAll();
84  if (is_array($TAllSkills)) {
85  foreach ($TAllSkills as &$skill) {
86  if (empty($skill->lines)) $skill->fetchLines();
87  if (count($skill->lines) < $conf->global->HRM_MAXRANK) {
88  $skill->createSkills(count($skill->lines) + 1);
89  }
90  }
91  }
92  }
93 } elseif ($action == 'updateMask') {
94  $maskconst = GETPOST('maskconstEvaluation', 'aZ09');
95  $maskvalue = GETPOST('maskEvaluation', 'alpha');
96 
97  if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
98  $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
99  if (!($res > 0)) {
100  $error++;
101  }
102  }
103 
104  if (!$error) {
105  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
106  } else {
107  setEventMessages($langs->trans("Error"), null, 'errors');
108  }
109 } elseif ($action == 'specimen') {
110  $modele = GETPOST('module', 'alpha');
111  $tmpobjectkey = GETPOST('object');
112 
113  $tmpobject = new $tmpobjectkey($db);
114  $tmpobject->initAsSpecimen();
115 
116  // Search template files
117  $file = ''; $classname = ''; $filefound = 0;
118  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
119  foreach ($dirmodels as $reldir) {
120  $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
121  if (file_exists($file)) {
122  $filefound = 1;
123  $classname = "pdf_".$modele;
124  break;
125  }
126  }
127 
128  if ($filefound) {
129  require_once $file;
130 
131  $module = new $classname($db);
132 
133  if ($module->write_file($tmpobject, $langs) > 0) {
134  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
135  return;
136  } else {
137  setEventMessages($module->error, null, 'errors');
138  dol_syslog($module->error, LOG_ERR);
139  }
140  } else {
141  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
142  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
143  }
144 } elseif ($action == 'setmod') {
145  // TODO Check if numbering module chosen can be activated by calling method canBeActivated
146  $tmpobjectkey = GETPOST('object');
147  if (!empty($tmpobjectkey)) {
148  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey)."_ADDON";
149  dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
150  }
151 } elseif ($action == 'set') {
152  // Activate a model
153  $ret = addDocumentModel($value, $type, $label, $scandir);
154 } elseif ($action == 'del') {
155  $ret = delDocumentModel($value, $type);
156  if ($ret > 0) {
157  $tmpobjectkey = GETPOST('object');
158  if (!empty($tmpobjectkey)) {
159  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
160  if ($conf->global->$constforval == "$value") {
161  dolibarr_del_const($db, $constforval, $conf->entity);
162  }
163  }
164  }
165 } elseif ($action == 'setdoc') {
166  // Set or unset default model
167  $tmpobjectkey = GETPOST('object');
168  if (!empty($tmpobjectkey)) {
169  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
170  if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
171  // The constant that was read before the new set
172  // We therefore requires a variable to have a coherent view
173  $conf->global->$constforval = $value;
174  }
175 
176  // We disable/enable the document template (into llx_document_model table)
177  $ret = delDocumentModel($value, $type);
178  if ($ret > 0) {
179  $ret = addDocumentModel($value, $type, $label, $scandir);
180  }
181  }
182 } elseif ($action == 'unsetdoc') {
183  $tmpobjectkey = GETPOST('object');
184  if (!empty($tmpobjectkey)) {
185  $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
186  dolibarr_del_const($db, $constforval, $conf->entity);
187  }
188 }
189 
190 
191 /*
192  * View
193  */
194 
195 $form = new Form($db);
196 
197 $help_url = '';
198 $page_name = "HRMSetup";
199 
200 llxHeader('', $langs->trans($page_name), $help_url);
201 
202 // Subheader
203 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
204 
205 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
206 
207 // Configuration header
208 $head = hrmAdminPrepareHead();
209 print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm");
210 
211 $moduledir = 'hrm';
212 $myTmpObjects = array();
213 $myTmpObjects['evaluation'] = array('label'=>'Evaluation', 'includerefgeneration'=>1, 'includedocgeneration'=>0);
214 
215 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
216  if ($myTmpObjectKey != $type) {
217  continue;
218  }
219  if ($myTmpObjectArray['includerefgeneration']) {
220  /*
221  * Orders Numbering model
222  */
223  $setupnotempty++;
224 
225  print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', '');
226 
227  print '<table class="noborder centpercent">';
228  print '<tr class="liste_titre">';
229  print '<td>'.$langs->trans("Name").'</td>';
230  print '<td>'.$langs->trans("Description").'</td>';
231  print '<td class="nowrap">'.$langs->trans("Example").'</td>';
232  print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
233  print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
234  print '</tr>'."\n";
235 
236  clearstatcache();
237 
238  foreach ($dirmodels as $reldir) {
239  $dir = dol_buildpath($reldir."core/modules/".$moduledir);
240 
241  if (is_dir($dir)) {
242  $handle = opendir($dir);
243  if (is_resource($handle)) {
244  while (($file = readdir($handle)) !== false) {
245  if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
246  $file = substr($file, 0, dol_strlen($file) - 4);
247 
248  require_once $dir.'/'.$file.'.php';
249 
250  $module = new $file($db);
251 
252  // Show modules according to features level
253  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
254  continue;
255  }
256  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
257  continue;
258  }
259 
260  if ($module->isEnabled()) {
261  dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
262 
263  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
264  print $module->info();
265  print '</td>';
266 
267  // Show example of numbering model
268  print '<td class="nowrap">';
269  $tmp = $module->getExample();
270  if (preg_match('/^Error/', $tmp)) {
271  $langs->load("errors");
272  print '<div class="error">'.$langs->trans($tmp).'</div>';
273  } elseif ($tmp == 'NotConfigured') {
274  print $langs->trans($tmp);
275  } else {
276  print $tmp;
277  }
278  print '</td>'."\n";
279 
280  print '<td class="center">';
281  $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
282  if (getDolGlobalString($constforvar) == $file) {
283  print img_picto($langs->trans("Activated"), 'switch_on');
284  } else {
285  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
286  print img_picto($langs->trans("Disabled"), 'switch_off');
287  print '</a>';
288  }
289  print '</td>';
290 
291  $mytmpinstance = new $myTmpObjectKey($db);
292  $mytmpinstance->initAsSpecimen();
293 
294  // Info
295  $htmltooltip = '';
296  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
297 
298  $nextval = $module->getNextValue($mytmpinstance);
299  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
300  $htmltooltip .= ''.$langs->trans("NextValue").': ';
301  if ($nextval) {
302  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
303  $nextval = $langs->trans($nextval);
304  }
305  $htmltooltip .= $nextval.'<br>';
306  } else {
307  $htmltooltip .= $langs->trans($module->error).'<br>';
308  }
309  }
310 
311  print '<td class="center">';
312  print $form->textwithpicto('', $htmltooltip, 1, 0);
313  print '</td>';
314 
315  print "</tr>\n";
316  }
317  }
318  }
319  closedir($handle);
320  }
321  }
322  }
323  print "</table>\n";
324  }
325 
326  if ($myTmpObjectArray['includedocgeneration']) {
327  /*
328  * Document templates generators
329  */
330  $setupnotempty++;
331  $type = strtolower($myTmpObjectKey);
332 
333  print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
334 
335  // Load array def with activated templates
336  $def = array();
337  $sql = "SELECT nom";
338  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
339  $sql .= " WHERE type = '".$db->escape($type)."'";
340  $sql .= " AND entity = ".$conf->entity;
341  $resql = $db->query($sql);
342  if ($resql) {
343  $i = 0;
344  $num_rows = $db->num_rows($resql);
345  while ($i < $num_rows) {
346  $array = $db->fetch_array($resql);
347  array_push($def, $array[0]);
348  $i++;
349  }
350  } else {
351  dol_print_error($db);
352  }
353 
354  print "<table class=\"noborder\" width=\"100%\">\n";
355  print "<tr class=\"liste_titre\">\n";
356  print '<td>'.$langs->trans("Name").'</td>';
357  print '<td>'.$langs->trans("Description").'</td>';
358  print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
359  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
360  print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
361  print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
362  print "</tr>\n";
363 
364  clearstatcache();
365 
366  foreach ($dirmodels as $reldir) {
367  foreach (array('', '/doc') as $valdir) {
368  $realpath = $reldir."core/modules/".$moduledir.$valdir;
369  $dir = dol_buildpath($realpath);
370 
371  if (is_dir($dir)) {
372  $handle = opendir($dir);
373  if (is_resource($handle)) {
374  while (($file = readdir($handle)) !== false) {
375  $filelist[] = $file;
376  }
377  closedir($handle);
378  arsort($filelist);
379 
380  foreach ($filelist as $file) {
381  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
382  if (file_exists($dir.'/'.$file)) {
383  $name = substr($file, 4, dol_strlen($file) - 16);
384  $classname = substr($file, 0, dol_strlen($file) - 12);
385 
386  require_once $dir.'/'.$file;
387  $module = new $classname($db);
388 
389  $modulequalified = 1;
390  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
391  $modulequalified = 0;
392  }
393  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
394  $modulequalified = 0;
395  }
396 
397  if ($modulequalified) {
398  print '<tr class="oddeven"><td width="100">';
399  print (empty($module->name) ? $name : $module->name);
400  print "</td><td>\n";
401  if (method_exists($module, 'info')) {
402  print $module->info($langs);
403  } else {
404  print $module->description;
405  }
406  print '</td>';
407 
408  // Active
409  if (in_array($name, $def)) {
410  print '<td class="center">'."\n";
411  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
412  print img_picto($langs->trans("Enabled"), 'switch_on');
413  print '</a>';
414  print '</td>';
415  } else {
416  print '<td class="center">'."\n";
417  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>';
418  print "</td>";
419  }
420 
421  // Default
422  print '<td class="center">';
423  $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
424  if (getDolGlobalString($constforvar) == $name) {
425  //print img_picto($langs->trans("Default"), 'on');
426  // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
427  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>';
428  } else {
429  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>';
430  }
431  print '</td>';
432 
433  // Info
434  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
435  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
436  if ($module->type == 'pdf') {
437  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
438  }
439  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
440 
441  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
442  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
443  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
444 
445  print '<td class="center">';
446  print $form->textwithpicto('', $htmltooltip, 1, 0);
447  print '</td>';
448 
449  // Preview
450  print '<td class="center">';
451  if ($module->type == 'pdf') {
452  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
453  } else {
454  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
455  }
456  print '</td>';
457 
458  print "</tr>\n";
459  }
460  }
461  }
462  }
463  }
464  }
465  }
466  }
467 
468  print '</table>';
469  }
470 }
471 
472 print load_fiche_titre($langs->trans('OtherOptions'), '', '');
473 
474 if (empty($conf->global->HRM_MAXRANK)) {
475  $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
476 }
477 
478 if ($action == 'edit') {
479  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
480  print '<input type="hidden" name="token" value="'.newToken().'">';
481  print '<input type="hidden" name="action" value="update">';
482 
483  print '<table class="noborder centpercent">';
484  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
485 
486  foreach ($arrayofparameters as $constname => $val) {
487  if ($val['enabled']==1) {
488  $setupnotempty++;
489  print '<tr class="oddeven"><td>';
490  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
491  print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
492  print '</td><td>';
493 
494  if ($val['type'] == 'textarea') {
495  print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
496  print $conf->global->{$constname};
497  print "</textarea>\n";
498  } elseif ($val['type'] == 'integer') {
499  print '<input class="flat" name="' . $constname . '" id="' . $constname . '" value="' . $conf->global->$constname . '" type="number" step="1" min="0" max="50" >' . "\n";
500  } elseif ($val['type'] == 'html') {
501  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
502  $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
503  $doleditor->Create();
504  } elseif ($val['type'] == 'yesno') {
505  print $form->selectyesno($constname, $conf->global->{$constname}, 1);
506  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
507  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
508  $formmail = new FormMail($db);
509 
510  $tmp = explode(':', $val['type']);
511  $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
512  //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
513  $arrayofmessagename = array();
514  if (is_array($formmail->lines_model)) {
515  foreach ($formmail->lines_model as $modelmail) {
516  //var_dump($modelmail);
517  $moreonlabel = '';
518  if (!empty($arrayofmessagename[$modelmail->label])) {
519  $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
520  }
521  // The 'label' is the key that is unique if we exclude the language
522  $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
523  }
524  }
525  print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
526  } elseif (preg_match('/category:/', $val['type'])) {
527  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
528  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
529  $formother = new FormOther($db);
530 
531  $tmp = explode(':', $val['type']);
532  print img_picto('', 'category', 'class="pictofixedwidth"');
533  print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
534  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
535  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
536  $formcompany = new FormCompany($db);
537  print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
538  } elseif ($val['type'] == 'securekey') {
539  print '<input required="required" type="text" class="flat" id="' . $constname . '" name="' . $constname . '" value="' . (GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : $conf->global->{$constname}) . '" size="40">';
540  if (!empty($conf->use_javascript_ajax)) {
541  print '&nbsp;' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"');
542  }
543 
544  // Add button to autosuggest a key
545  include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
546  print dolJSToSetRandomPassword($constname, 'generate_token' . $constname);
547  } elseif ($val['type'] == 'product') {
548  if (isModEnabled('product') || isModEnabled('service')) {
549  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
550  $form->select_produits($selected, $constname, '', 0);
551  }
552  } else {
553  print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . $conf->global->{$constname} . '">';
554  }
555  print '</td></tr>';
556  }
557  }
558  print '</table>';
559 
560  print '<br><div class="center">';
561  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
562  print '</div>';
563 
564  print '</form>';
565  print '<br>';
566 } else {
567  if (!empty($arrayofparameters)) {
568  print '<table class="noborder centpercent">';
569  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
570 
571  foreach ($arrayofparameters as $constname => $val) {
572  if ($val['enabled']==1) {
573  $setupnotempty++;
574  print '<tr class="oddeven"><td>';
575  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
576  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
577  print '</td><td>';
578 
579  if ($val['type'] == 'textarea') {
580  print dol_nl2br($conf->global->{$constname});
581  } elseif ($val['type']== 'html') {
582  print $conf->global->{$constname};
583  } elseif ($val['type'] == 'yesno') {
584  print ajax_constantonoff($constname);
585  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
586  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
587  $formmail = new FormMail($db);
588 
589  $tmp = explode(':', $val['type']);
590 
591  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
592  if ($template<0) {
593  setEventMessages(null, $formmail->errors, 'errors');
594  }
595  print $langs->trans($template->label);
596  } elseif (preg_match('/category:/', $val['type'])) {
597  $c = new Categorie($db);
598  $result = $c->fetch($conf->global->{$constname});
599  if ($result < 0) {
600  setEventMessages(null, $c->errors, 'errors');
601  }
602  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
603  $toprint = array();
604  foreach ($ways as $way) {
605  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
606  }
607  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
608  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
609  if ($conf->global->{$constname}==2) {
610  print $langs->trans("Prospect");
611  } elseif ($conf->global->{$constname}==3) {
612  print $langs->trans("ProspectCustomer");
613  } elseif ($conf->global->{$constname}==1) {
614  print $langs->trans("Customer");
615  } elseif ($conf->global->{$constname}==0) {
616  print $langs->trans("NorProspectNorCustomer");
617  }
618  } elseif ($val['type'] == 'product') {
619  $product = new Product($db);
620  $resprod = $product->fetch($conf->global->{$constname});
621  if ($resprod > 0) {
622  print $product->ref;
623  } elseif ($resprod < 0) {
624  setEventMessages(null, $object->errors, "errors");
625  }
626  } else {
627  print getDolGlobalString($constname);
628  }
629  print '</td></tr>';
630  }
631  }
632 
633  print '</table>';
634 
635  print '<div class="tabsAction">';
636  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
637  print '</div>';
638  } else {
639  print '<br>'.$langs->trans("NothingToSetup");
640  }
641 }
642 
643 
644 if (empty($setupnotempty)) {
645  print '<br>'.$langs->trans("NothingToSetup");
646 }
647 
648 // Page end
649 print dol_get_fiche_end();
650 
651 llxFooter();
652 $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='')
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 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', $generic=1)
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.