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