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