dolibarr  19.0.0-dev
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  $nameofclass = ucfirst($myTmpObjectKey);
290  $mytmpinstance = new $nameofclass($db);
291  $mytmpinstance->initAsSpecimen();
292 
293  // Info
294  $htmltooltip = '';
295  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
296 
297  $nextval = $module->getNextValue($mytmpinstance);
298  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
299  $htmltooltip .= ''.$langs->trans("NextValue").': ';
300  if ($nextval) {
301  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
302  $nextval = $langs->trans($nextval);
303  }
304  $htmltooltip .= $nextval.'<br>';
305  } else {
306  $htmltooltip .= $langs->trans($module->error).'<br>';
307  }
308  }
309 
310  print '<td class="center">';
311  print $form->textwithpicto('', $htmltooltip, 1, 0);
312  print '</td>';
313 
314  print "</tr>\n";
315  }
316  }
317  }
318  closedir($handle);
319  }
320  }
321  }
322  print "</table>\n";
323  }
324 
325  if ($myTmpObjectArray['includedocgeneration']) {
326  /*
327  * Document templates generators
328  */
329  $setupnotempty++;
330  $type = strtolower($myTmpObjectKey);
331 
332  print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
333 
334  // Load array def with activated templates
335  $def = array();
336  $sql = "SELECT nom";
337  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
338  $sql .= " WHERE type = '".$db->escape($type)."'";
339  $sql .= " AND entity = ".$conf->entity;
340  $resql = $db->query($sql);
341  if ($resql) {
342  $i = 0;
343  $num_rows = $db->num_rows($resql);
344  while ($i < $num_rows) {
345  $array = $db->fetch_array($resql);
346  array_push($def, $array[0]);
347  $i++;
348  }
349  } else {
350  dol_print_error($db);
351  }
352 
353  print "<table class=\"noborder\" width=\"100%\">\n";
354  print "<tr class=\"liste_titre\">\n";
355  print '<td>'.$langs->trans("Name").'</td>';
356  print '<td>'.$langs->trans("Description").'</td>';
357  print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
358  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
359  print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
360  print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
361  print "</tr>\n";
362 
363  clearstatcache();
364 
365  foreach ($dirmodels as $reldir) {
366  foreach (array('', '/doc') as $valdir) {
367  $realpath = $reldir."core/modules/".$moduledir.$valdir;
368  $dir = dol_buildpath($realpath);
369 
370  if (is_dir($dir)) {
371  $handle = opendir($dir);
372  if (is_resource($handle)) {
373  while (($file = readdir($handle)) !== false) {
374  $filelist[] = $file;
375  }
376  closedir($handle);
377  arsort($filelist);
378 
379  foreach ($filelist as $file) {
380  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
381  if (file_exists($dir.'/'.$file)) {
382  $name = substr($file, 4, dol_strlen($file) - 16);
383  $classname = substr($file, 0, dol_strlen($file) - 12);
384 
385  require_once $dir.'/'.$file;
386  $module = new $classname($db);
387 
388  $modulequalified = 1;
389  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
390  $modulequalified = 0;
391  }
392  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
393  $modulequalified = 0;
394  }
395 
396  if ($modulequalified) {
397  print '<tr class="oddeven"><td width="100">';
398  print (empty($module->name) ? $name : $module->name);
399  print "</td><td>\n";
400  if (method_exists($module, 'info')) {
401  print $module->info($langs);
402  } else {
403  print $module->description;
404  }
405  print '</td>';
406 
407  // Active
408  if (in_array($name, $def)) {
409  print '<td class="center">'."\n";
410  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
411  print img_picto($langs->trans("Enabled"), 'switch_on');
412  print '</a>';
413  print '</td>';
414  } else {
415  print '<td class="center">'."\n";
416  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>';
417  print "</td>";
418  }
419 
420  // Default
421  print '<td class="center">';
422  $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
423  if (getDolGlobalString($constforvar) == $name) {
424  //print img_picto($langs->trans("Default"), 'on');
425  // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
426  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>';
427  } else {
428  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>';
429  }
430  print '</td>';
431 
432  // Info
433  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
434  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
435  if ($module->type == 'pdf') {
436  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
437  }
438  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
439 
440  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
441  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
442  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
443 
444  print '<td class="center">';
445  print $form->textwithpicto('', $htmltooltip, 1, 0);
446  print '</td>';
447 
448  // Preview
449  print '<td class="center">';
450  if ($module->type == 'pdf') {
451  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
452  } else {
453  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
454  }
455  print '</td>';
456 
457  print "</tr>\n";
458  }
459  }
460  }
461  }
462  }
463  }
464  }
465  }
466 
467  print '</table>';
468  }
469 }
470 
471 print load_fiche_titre($langs->trans('OtherOptions'), '', '');
472 
473 if (empty($conf->global->HRM_MAXRANK)) {
474  $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
475 }
476 
477 if ($action == 'edit') {
478  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
479  print '<input type="hidden" name="token" value="'.newToken().'">';
480  print '<input type="hidden" name="action" value="update">';
481 
482  print '<table class="noborder centpercent">';
483  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
484 
485  foreach ($arrayofparameters as $constname => $val) {
486  if ($val['enabled']==1) {
487  $setupnotempty++;
488  print '<tr class="oddeven"><td>';
489  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
490  print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
491  print '</td><td>';
492 
493  if ($val['type'] == 'textarea') {
494  print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
495  print getDolGlobalString($constname);
496  print "</textarea>\n";
497  } elseif ($val['type'] == 'integer') {
498  print '<input class="flat" name="' . $constname . '" id="' . $constname . '" value="' . getDolGlobalString($constname) . '" type="number" step="1" min="0" max="50" >' . "\n";
499  } elseif ($val['type'] == 'html') {
500  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
501  $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
502  $doleditor->Create();
503  } elseif ($val['type'] == 'yesno') {
504  print $form->selectyesno($constname, getDolGlobalString($constname), 1);
505  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
506  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
507  $formmail = new FormMail($db);
508 
509  $tmp = explode(':', $val['type']);
510  $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
511  //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
512  $arrayofmessagename = array();
513  if (is_array($formmail->lines_model)) {
514  foreach ($formmail->lines_model as $modelmail) {
515  //var_dump($modelmail);
516  $moreonlabel = '';
517  if (!empty($arrayofmessagename[$modelmail->label])) {
518  $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
519  }
520  // The 'label' is the key that is unique if we exclude the language
521  $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
522  }
523  }
524  print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
525  } elseif (preg_match('/category:/', $val['type'])) {
526  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
527  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
528  $formother = new FormOther($db);
529 
530  $tmp = explode(':', $val['type']);
531  print img_picto('', 'category', 'class="pictofixedwidth"');
532  print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
533  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
534  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
535  $formcompany = new FormCompany($db);
536  print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
537  } elseif ($val['type'] == 'securekey') {
538  print '<input required="required" type="text" class="flat" id="' . $constname . '" name="' . $constname . '" value="' . (GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)) . '" size="40">';
539  if (!empty($conf->use_javascript_ajax)) {
540  print '&nbsp;' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"');
541  }
542 
543  // Add button to autosuggest a key
544  include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
545  print dolJSToSetRandomPassword($constname, 'generate_token' . $constname);
546  } elseif ($val['type'] == 'product') {
547  if (isModEnabled('product') || isModEnabled('service')) {
548  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
549  $form->select_produits($selected, $constname, '', 0);
550  }
551  } else {
552  print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
553  }
554  print '</td></tr>';
555  }
556  }
557  print '</table>';
558 
559  print '<br><div class="center">';
560  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
561  print '</div>';
562 
563  print '</form>';
564  print '<br>';
565 } else {
566  if (!empty($arrayofparameters)) {
567  print '<table class="noborder centpercent">';
568  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
569 
570  foreach ($arrayofparameters as $constname => $val) {
571  if ($val['enabled']==1) {
572  $setupnotempty++;
573  print '<tr class="oddeven"><td>';
574  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
575  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
576  print '</td><td>';
577 
578  if ($val['type'] == 'textarea') {
579  print dol_nl2br(getDolGlobalString($constname));
580  } elseif ($val['type']== 'html') {
581  print getDolGlobalString($constname);
582  } elseif ($val['type'] == 'yesno') {
583  print ajax_constantonoff($constname);
584  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
585  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
586  $formmail = new FormMail($db);
587 
588  $tmp = explode(':', $val['type']);
589 
590  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
591  if ($template<0) {
592  setEventMessages(null, $formmail->errors, 'errors');
593  }
594  print $langs->trans($template->label);
595  } elseif (preg_match('/category:/', $val['type'])) {
596  $c = new Categorie($db);
597  $result = $c->fetch(getDolGlobalString($constname));
598  if ($result < 0) {
599  setEventMessages(null, $c->errors, 'errors');
600  }
601  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
602  $toprint = array();
603  foreach ($ways as $way) {
604  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
605  }
606  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
607  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
608  if (getDolGlobalString($constname) == 2) {
609  print $langs->trans("Prospect");
610  } elseif (getDolGlobalString($constname) == 3) {
611  print $langs->trans("ProspectCustomer");
612  } elseif (getDolGlobalString($constname) == 1) {
613  print $langs->trans("Customer");
614  } elseif (getDolGlobalString($constname) == 0) {
615  print $langs->trans("NorProspectNorCustomer");
616  }
617  } elseif ($val['type'] == 'product') {
618  $product = new Product($db);
619  $resprod = $product->fetch(getDolGlobalString($constname));
620  if ($resprod > 0) {
621  print $product->ref;
622  } elseif ($resprod < 0) {
623  setEventMessages(null, $object->errors, "errors");
624  }
625  } else {
626  print getDolGlobalString($constname);
627  }
628  print '</td></tr>';
629  }
630  }
631 
632  print '</table>';
633 
634  print '<div class="tabsAction">';
635  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
636  print '</div>';
637  } else {
638  print '<br>'.$langs->trans("NothingToSetup");
639  }
640 }
641 
642 
643 if (empty($setupnotempty)) {
644  print '<br>'.$langs->trans("NothingToSetup");
645 }
646 
647 // Page end
648 print dol_get_fiche_end();
649 
650 llxFooter();
651 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6824
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
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:609
dol_nl2br
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
Definition: functions.lib.php:7339
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:5107
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1129
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1158
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Categorie
Class to manage categories.
Definition: categorie.class.php:47
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:630
$help_url
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
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4135
llxHeader
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
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1949
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
Skill
Class for Skill.
Definition: skill.class.php:36
$sql
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3997
dolJSToSetRandomPassword
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
Definition: security2.lib.php:573
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Definition: functions.lib.php:1979
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
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:638
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1918
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4473
hrmAdminPrepareHead
hrmAdminPrepareHead()
Prepare admin pages header.
Definition: hrm.lib.php:34
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1169
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:40
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30