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