dolibarr 25.0.0-alpha
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 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
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';
37require_once DOL_DOCUMENT_ROOT.'/hrm/class/evaluation.class.php';
38
47// Translations
48$langs->loadLangs(array("admin", "hrm"));
49
50// Access control
51if (!$user->admin) {
53}
54
55// Parameters
56$action = GETPOST('action', 'aZ09');
57$backtopage = GETPOST('backtopage', 'alpha');
58
59$value = GETPOST('value', 'alpha');
60$label = GETPOST('label', 'alpha');
61$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
62
63$scandir = GETPOST('scan_dir', 'alpha');
64$type = 'evaluation';
65
69$arrayofparameters = array(
70 'HRM_MAXRANK' => array('type' => 'integer','enabled' => 1, 'css' => ''),
71 'HRM_DEFAULT_SKILL_DESCRIPTION' => array('type' => 'varchar','enabled' => 1, 'css' => ''),
72);
73
74$error = 0;
75$setupnotempty = 0;
76
77$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
78
79$moduledir = 'hrm';
80// TODO Scan list of objects to fill this array
81$myTmpObjects = [
82 'evaluation' => [
83 'label' => 'Evaluation',
84 'includerefgeneration' => 1,
85 'includedocgeneration' => 1,
86 'class' => 'Evaluation'
87 ],
88];
89
90$tmpobjectkey = GETPOST('object', 'aZ09');
91if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
92 accessforbidden('Bad value for object. Hack attempt ?');
93}
94
95
96/*
97 * Actions
98 */
99
100include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
101
102if ($action == 'update') {
103 $max_rank = GETPOSTINT('HRM_MAXRANK');
104
105 // We complete skill possible level notation if necessary
106 if (!empty($max_rank)) {
107 $static_skill = new Skill($db);
108 $TAllSkills = $static_skill->fetchAll();
109 if (is_array($TAllSkills)) {
110 foreach ($TAllSkills as &$skill) {
111 if (empty($skill->lines)) {
112 $skill->fetchLines();
113 }
114 if (count($skill->lines) < $conf->global->HRM_MAXRANK) {
115 $skill->createSkills(count($skill->lines) + 1);
116 }
117 }
118 }
119 }
120} elseif ($action == 'updateMask') {
121 $maskconst = GETPOST('maskconstEvaluation', 'aZ09');
122 $maskvalue = GETPOST('maskEvaluation', 'alpha');
123
124 if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
125 $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
126 if (!($res > 0)) {
127 $error++;
128 }
129 }
130
131 if (!$error) {
132 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
133 } else {
134 setEventMessages($langs->trans("Error"), null, 'errors');
135 }
136} elseif ($action == 'specimen' && $tmpobjectkey) {
137 $modele = GETPOST('module', 'alpha');
138
139 $className = $myTmpObjects[$tmpobjectkey]['class'];
140 $tmpobject = new $className($db);
141 $tmpobject->initAsSpecimen();
142
143 // Search template files
144 $file = '';
145 $classname = '';
146 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
147 foreach ($dirmodels as $reldir) {
148 $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele.".modules.php", 0);
149 if (file_exists($file)) {
150 $classname = "pdf_".$modele;
151 break;
152 }
153 }
154
155 if ($classname !== '') {
156 require_once $file;
157
158 $module = new $classname($db);
159 '@phan-var-force ModelePDFEvaluation $module';
160
161 if ($module->write_file($tmpobject, $langs) > 0) {
162 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=hrm&file=evaluation/SPECIMEN.pdf");
163 return;
164 } else {
165 setEventMessages($module->error, null, 'errors');
166 dol_syslog($module->error, LOG_ERR);
167 }
168 } else {
169 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
170 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
171 }
172} elseif ($action == 'setmod') {
173 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
174 if (!empty($tmpobjectkey)) {
175 $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey)."_ADDON";
176 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
177 }
178} elseif ($action == 'set') {
179 // Activate a model
180 $ret = addDocumentModel($value, $type, $label, $scandir);
181} elseif ($action == 'del') {
182 $ret = delDocumentModel($value, $type);
183 if ($ret > 0) {
184 if (!empty($tmpobjectkey)) {
185 $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
186 if (getDolGlobalString($constforval) == "$value") {
187 dolibarr_del_const($db, $constforval, $conf->entity);
188 }
189 }
190 }
191} elseif ($action == 'setdoc') {
192 // Set or unset default model
193 if (!empty($tmpobjectkey)) {
194 $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
195 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
196 // The constant that was read before the new set
197 // We therefore requires a variable to have a coherent view
198 $conf->global->$constforval = $value;
199 }
200
201 // We disable/enable the document template (into llx_document_model table)
202 $ret = delDocumentModel($value, $type);
203 if ($ret > 0) {
204 $ret = addDocumentModel($value, $type, $label, $scandir);
205 }
206 }
207} elseif ($action == 'unsetdoc') {
208 if (!empty($tmpobjectkey)) {
209 $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
210 dolibarr_del_const($db, $constforval, $conf->entity);
211 }
212}
213
214
215/*
216 * View
217 */
218
219$form = new Form($db);
220
221$help_url = '';
222$page_name = "HRMSetup";
223
224llxHeader('', $langs->trans($page_name), $help_url, '', 0, 0, '', '', '', 'mod-admin page-hrm');
225
226// Subheader
227$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
228
229print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
230
231// Configuration header
232$head = hrmAdminPrepareHead();
233print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm");
234
235
236foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
237 if ($myTmpObjectKey != $type) {
238 continue;
239 }
240 if ($myTmpObjectArray['includerefgeneration']) {
241 /*
242 * Orders Numbering model
243 */
244 $setupnotempty++;
245
246 print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', '');
247
248 print '<table class="noborder centpercent">';
249 print '<tr class="liste_titre">';
250 print '<td>'.$langs->trans("Name").'</td>';
251 print '<td>'.$langs->trans("Description").'</td>';
252 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
253 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
254 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
255 print "</tr>\n";
256
257 clearstatcache();
258
259 foreach ($dirmodels as $reldir) {
260 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
261
262 if (is_dir($dir)) {
263 $handle = opendir($dir);
264 if (is_resource($handle)) {
265 while (($file = readdir($handle)) !== false) {
266 if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && dol_substr($file, dol_strlen($file) - 3, 3) == 'php') {
267 $file = dol_substr($file, 0, dol_strlen($file) - 4);
268
269 require_once $dir.'/'.$file.'.php';
270
271 $module = new $file($db);
272 '@phan-var-force ModeleNumRefEvaluation $module';
275 // Show modules according to features level
276 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
277 continue;
278 }
279 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
280 continue;
281 }
282
283 if ($module->isEnabled()) {
284 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
285
286 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
287 print $module->info($langs);
288 print '</td>';
289
290 // Show example of numbering model
291 print '<td class="nowrap">';
292 $tmp = $module->getExample();
293 if (preg_match('/^Error/', $tmp)) {
294 $langs->load("errors");
295 print '<div class="error">'.$langs->trans($tmp).'</div>';
296 } elseif ($tmp == 'NotConfigured') {
297 print $langs->trans($tmp);
298 } else {
299 print $tmp;
300 }
301 print '</td>'."\n";
302
303 print '<td class="center">';
304 $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
305 if (getDolGlobalString($constforvar) == $file) {
306 print img_picto($langs->trans("Activated"), 'switch_on');
307 } else {
308 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
309 print img_picto($langs->trans("Disabled"), 'switch_off');
310 print '</a>';
311 }
312 print '</td>';
313
314 $nameofclass = ucfirst($myTmpObjectKey);
315 $mytmpinstance = new $nameofclass($db);
316 '@phan-var-force Evaluation $mytmpinstance';
318 $mytmpinstance->initAsSpecimen();
319
320 // Info
321 $htmltooltip = '';
322 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
323
324 $nextval = $module->getNextValue($mytmpinstance);
325 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
326 $htmltooltip .= ''.$langs->trans("NextValue").': ';
327 if ($nextval) {
328 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
329 $nextval = $langs->trans($nextval);
330 }
331 $htmltooltip .= $nextval.'<br>';
332 } else {
333 $htmltooltip .= $langs->trans($module->error).'<br>';
334 }
335 }
336
337 print '<td class="center">';
338 print $form->textwithpicto('', $htmltooltip, 1, 'info');
339 print '</td>';
340
341 print "</tr>\n";
342 }
343 }
344 }
345 closedir($handle);
346 }
347 }
348 }
349 print "</table>\n";
350 }
351
352 if ($myTmpObjectArray['includedocgeneration']) {
353 /*
354 * Document templates generators
355 */
356 $setupnotempty++;
357 $type = strtolower($myTmpObjectKey);
358
359 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
360
361 // Load array def with activated templates
362 $def = array();
363 $sql = "SELECT nom";
364 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
365 $sql .= " WHERE type = '".$db->escape($type)."'";
366 $sql .= " AND entity = ".((int) $conf->entity);
367 $resql = $db->query($sql);
368 if ($resql) {
369 $i = 0;
370 $num_rows = $db->num_rows($resql);
371 while ($i < $num_rows) {
372 $array = $db->fetch_array($resql);
373 if (is_array($array)) {
374 array_push($def, $array[0]);
375 }
376 $i++;
377 }
378 } else {
379 dol_print_error($db);
380 }
381
382 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
383 print '<table class="noborder centpercent">'."\n";
384 print '<tr class="liste_titre">'."\n";
385 print '<td>'.$langs->trans("Name").'</td>';
386 print '<td>'.$langs->trans("Description").'</td>';
387 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
388 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
389 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
390 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
391 print "</tr>\n";
392
393 clearstatcache();
394
395 foreach ($dirmodels as $reldir) {
396 foreach (array('', '/doc') as $valdir) {
397 $realpath = $reldir."core/modules/".$moduledir.$valdir;
398 $dir = dol_buildpath($realpath);
399
400 if (is_dir($dir)) {
401 $handle = opendir($dir);
402 if (is_resource($handle)) {
403 $filelist = array();
404 while (($file = readdir($handle)) !== false) {
405 $filelist[] = $file;
406 }
407 closedir($handle);
408 arsort($filelist);
409
410 foreach ($filelist as $file) {
411 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
412 if (file_exists($dir.'/'.$file)) {
413 $name = dol_substr($file, 4, dol_strlen($file) - 16);
414 $classname = dol_substr($file, 0, dol_strlen($file) - 12);
415
416 require_once $dir.'/'.$file;
417 $module = new $classname($db);
418
419 '@phan-var-force ModelePDFEvaluation $module';
420
421 $modulequalified = 1;
422 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
423 $modulequalified = 0;
424 }
425 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
426 $modulequalified = 0;
427 }
428
429 if ($modulequalified) {
430 print '<tr class="oddeven"><td width="100">';
431 print(empty($module->name) ? $name : $module->name);
432 print "</td><td>\n";
433 if (method_exists($module, 'info')) {
434 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
435 } else {
436 print $module->description;
437 }
438 print '</td>';
439
440 // Active
441 if (in_array($name, $def)) {
442 print '<td class="center">'."\n";
443 print '<a href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'del', 'value' => $name], true).'">';
444 print img_picto($langs->trans("Enabled"), 'switch_on');
445 print '</a>';
446 print '</td>';
447 } else {
448 print '<td class="center">'."\n";
449 print '<a href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'set', 'value' => $name, 'scan_dir' => $module->scandir, 'label' => $module->name], true).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
450 print "</td>";
451 }
452
453 // Default
454 print '<td class="center">';
455 $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
456 if (getDolGlobalString($constforvar) == $name) {
457 //print img_picto($langs->trans("Default"), 'on');
458 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
459 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>';
460 } else {
461 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>';
462 }
463 print '</td>';
464
465 // Info
466 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
467 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
468 if ($module->type == 'pdf') {
469 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
470 }
471 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
472
473 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
474 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
475 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
476
477 print '<td class="center">';
478 print $form->textwithpicto('', $htmltooltip, 1, 'info');
479 print '</td>';
480
481 // Preview
482 print '<td class="center">';
483 if ($module->type == 'pdf') {
484 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
485 } else {
486 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"), 'generic');
487 }
488 print '</td>';
489
490 print "</tr>\n";
491 }
492 }
493 }
494 }
495 }
496 }
497 }
498 }
499
500 print '</table>';
501 print '</div>';
502 }
503}
504
505print load_fiche_titre($langs->trans('OtherOptions'), '', '');
506
507if (!getDolGlobalString('HRM_MAXRANK')) {
508 $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
509}
510
511if ($action != 'editxxx') {
512 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
513 print '<input type="hidden" name="token" value="'.newToken().'">';
514 print '<input type="hidden" name="action" value="update">';
515
516 print '<table class="noborder centpercent">';
517 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td></td></tr>';
518
519 foreach ($arrayofparameters as $constname => $val) {
520 if ($val['enabled'] == 1) {
521 $setupnotempty++;
522 print '<tr class="oddeven"><td>';
523 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
524 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
525 print '</td><td>';
526
527 if ($val['type'] == 'textarea') {
528 print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
529 print getDolGlobalString($constname);
530 print "</textarea>\n";
531 } elseif ($val['type'] == 'integer') {
532 print '<input class="flat" name="' . $constname . '" id="' . $constname . '" value="' . getDolGlobalString($constname) . '" type="number" step="1" min="0" max="50" >' . "\n";
533 } elseif ($val['type'] == 'html') {
534 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
535 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
536 $doleditor->Create();
537 } elseif ($val['type'] == 'yesno') {
538 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
539 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
540 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
541 $formmail = new FormMail($db);
542
543 $tmp = explode(':', $val['type']);
544 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
545 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
546 $arrayofmessagename = array();
547 if (is_array($formmail->lines_model)) {
548 foreach ($formmail->lines_model as $modelmail) {
549 //var_dump($modelmail);
550 $moreonlabel = '';
551 if (!empty($arrayofmessagename[$modelmail->label])) {
552 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
553 }
554 // The 'label' is the key that is unique if we exclude the language
555 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
556 }
557 }
558 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
559 } elseif (preg_match('/category:/', $val['type'])) {
560 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
561 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
562 $formother = new FormOther($db);
563
564 $tmp = explode(':', $val['type']);
565 print img_picto('', 'category', 'class="pictofixedwidth"');
566 print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
567 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
568 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
569 $formcompany = new FormCompany($db);
570 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
571 } elseif ($val['type'] == 'securekey') {
572 print '<input required="required" type="text" class="flat" id="' . $constname . '" name="' . $constname . '" value="' . (GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)) . '" size="40">';
573 if (!empty($conf->use_javascript_ajax)) {
574 print '&nbsp;' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"');
575 }
576
577 // Add button to autosuggest a key
578 include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
579 print dolJSToSetRandomPassword($constname, 'generate_token' . $constname);
580 } elseif ($val['type'] == 'product') {
581 if (isModEnabled('product') || isModEnabled('service')) {
582 $selected = getDolGlobalInt($constname);
583 $form->select_produits($selected, $constname, '', 0);
584 }
585 } else {
586 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
587 }
588 print '</td></tr>';
589 }
590 }
591 print '</table>';
592
593 print '<br><div class="center">';
594 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
595 print '</div>';
596
597 print '</form>';
598 print '<br>';
599} else {
600 if (!empty($arrayofparameters)) {
601 print '<table class="noborder centpercent">';
602 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td></td></tr>';
603
604 foreach ($arrayofparameters as $constname => $val) {
605 if ($val['enabled'] == 1) {
606 $setupnotempty++;
607 print '<tr class="oddeven"><td>';
608 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
609 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
610 print '</td><td>';
611
612 if ($val['type'] == 'textarea') {
613 print dol_nl2br(getDolGlobalString($constname));
614 } elseif ($val['type'] == 'html') {
615 print getDolGlobalString($constname);
616 } elseif ($val['type'] == 'yesno') {
617 print ajax_constantonoff($constname);
618 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
619 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
620 $formmail = new FormMail($db);
621
622 $tmp = explode(':', $val['type']);
623
624 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname));
625 if ($template < 0) {
626 setEventMessages(null, $formmail->errors, 'errors');
627 }
628 print $langs->trans($template->label);
629 } elseif (preg_match('/category:/', $val['type'])) {
630 $c = new Categorie($db);
631 $result = $c->fetch(getDolGlobalInt($constname));
632 if ($result < 0) {
633 setEventMessages(null, $c->errors, 'errors');
634 }
635 $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
636 $toprint = array();
637 foreach ($ways as $way) {
638 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
639 }
640 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
641 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
642 if (getDolGlobalString($constname) == 2) {
643 print $langs->trans("Prospect");
644 } elseif (getDolGlobalString($constname) == 3) {
645 print $langs->trans("ProspectCustomer");
646 } elseif (getDolGlobalString($constname) == 1) {
647 print $langs->trans("Customer");
648 } elseif (getDolGlobalString($constname) == 0) {
649 print $langs->trans("NorProspectNorCustomer");
650 }
651 } elseif ($val['type'] == 'product') {
652 $product = new Product($db);
653 $resprod = $product->fetch(getDolGlobalInt($constname));
654 if ($resprod > 0) {
655 print $product->ref;
656 } elseif ($resprod < 0) {
657 setEventMessages($product->error, $product->errors, "errors");
658 }
659 } else {
660 print getDolGlobalString($constname);
661 }
662 print '</td></tr>';
663 }
664 }
665
666 print '</table>';
667
668 print '<div class="tabsAction">';
669 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
670 print '</div>';
671 } else {
672 print '<br>'.$langs->trans("NothingToSetup");
673 }
674}
675
676
677if (empty($setupnotempty)) {
678 print '<br>'.$langs->trans("NothingToSetup");
679}
680
681// Page end
682print dol_get_fiche_end();
683
684llxFooter();
685$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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
$c
Definition line.php:346
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.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to help generate other html components Only common components are here.
Class to manage products or services.
Class for Skill.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
hrmAdminPrepareHead()
Prepare admin pages header.
Definition hrm.lib.php:35
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript 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.