dolibarr  16.0.5
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 = 'myobject';
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  $maskconstorder = GETPOST('maskconstorder', 'alpha');
95  $maskorder = GETPOST('maskorder', 'alpha');
96 
97  if ($maskconstorder) {
98  $res = dolibarr_set_const($db, $maskconstorder, $maskorder, '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('includerefgeneration'=>1, 'includedocgeneration'=>0);
214 
215 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
216  if ($myTmpObjectKey == 'MyObject') {
217  continue;
218  }
219  if ($myTmpObjectArray['includerefgeneration']) {
220  /*
221  * Orders Numbering model
222  */
223  $setupnotempty++;
224 
225  print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
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, $conf->fckeditor->enabled, 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  if (!empty($conf->use_javascript_ajax)) {
544  print "\n".'<script type="text/javascript">';
545  print '$(document).ready(function () {
546  $("#generate_token'.$constname.'").click(function() {
547  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
548  action: \'getrandompassword\',
549  generic: true
550  },
551  function(token) {
552  $("#'.$constname.'").val(token);
553  });
554  });
555  });';
556  print '</script>';
557  }
558  } elseif ($val['type'] == 'product') {
559  if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
560  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
561  $form->select_produits($selected, $constname, '', 0);
562  }
563  } else {
564  print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
565  }
566  print '</td></tr>';
567  }
568  }
569  print '</table>';
570 
571  print '<br><div class="center">';
572  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
573  print '</div>';
574 
575  print '</form>';
576  print '<br>';
577 } else {
578  if (!empty($arrayofparameters)) {
579  print '<table class="noborder centpercent">';
580  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
581 
582  foreach ($arrayofparameters as $constname => $val) {
583  if ($val['enabled']==1) {
584  $setupnotempty++;
585  print '<tr class="oddeven"><td>';
586  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
587  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
588  print '</td><td>';
589 
590  if ($val['type'] == 'textarea') {
591  print dol_nl2br($conf->global->{$constname});
592  } elseif ($val['type']== 'html') {
593  print $conf->global->{$constname};
594  } elseif ($val['type'] == 'yesno') {
595  print ajax_constantonoff($constname);
596  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
597  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
598  $formmail = new FormMail($db);
599 
600  $tmp = explode(':', $val['type']);
601 
602  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
603  if ($template<0) {
604  setEventMessages(null, $formmail->errors, 'errors');
605  }
606  print $langs->trans($template->label);
607  } elseif (preg_match('/category:/', $val['type'])) {
608  $c = new Categorie($db);
609  $result = $c->fetch($conf->global->{$constname});
610  if ($result < 0) {
611  setEventMessages(null, $c->errors, 'errors');
612  }
613  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
614  $toprint = array();
615  foreach ($ways as $way) {
616  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
617  }
618  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
619  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
620  if ($conf->global->{$constname}==2) {
621  print $langs->trans("Prospect");
622  } elseif ($conf->global->{$constname}==3) {
623  print $langs->trans("ProspectCustomer");
624  } elseif ($conf->global->{$constname}==1) {
625  print $langs->trans("Customer");
626  } elseif ($conf->global->{$constname}==0) {
627  print $langs->trans("NorProspectNorCustomer");
628  }
629  } elseif ($val['type'] == 'product') {
630  $product = new Product($db);
631  $resprod = $product->fetch($conf->global->{$constname});
632  if ($resprod > 0) {
633  print $product->ref;
634  } elseif ($resprod < 0) {
635  setEventMessages(null, $object->errors, "errors");
636  }
637  } else {
638  print $conf->global->{$constname};
639  }
640  print '</td></tr>';
641  }
642  }
643 
644  print '</table>';
645 
646  print '<div class="tabsAction">';
647  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
648  print '</div>';
649  } else {
650  print '<br>'.$langs->trans("NothingToSetup");
651  }
652 }
653 
654 
655 if (empty($setupnotempty)) {
656  print '<br>'.$langs->trans("NothingToSetup");
657 }
658 
659 // Page end
660 print dol_get_fiche_end();
661 
662 llxFooter();
663 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_nl2br
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
Definition: functions.lib.php:6963
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:4844
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:1033
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
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
$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:116
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:3880
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1894
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
Skill
Class for Skill.
Definition: skill.class.php:36
ajax_constantonoff
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:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1863
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:52
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:4211
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
hrmAdminPrepareHead
hrmAdminPrepareHead()
Prepare admin pages header.
Definition: hrm.lib.php:33
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30