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 ModelePDFEvaluation $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 '@phan-var-force ModeleNumRefEvaluation $module';
266
267 // Show modules according to features level
268 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
269 continue;
270 }
271 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
272 continue;
273 }
274
275 if ($module->isEnabled()) {
276 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
277
278 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
279 print $module->info($langs);
280 print '</td>';
281
282 // Show example of numbering model
283 print '<td class="nowrap">';
284 $tmp = $module->getExample();
285 if (preg_match('/^Error/', $tmp)) {
286 $langs->load("errors");
287 print '<div class="error">'.$langs->trans($tmp).'</div>';
288 } elseif ($tmp == 'NotConfigured') {
289 print $langs->trans($tmp);
290 } else {
291 print $tmp;
292 }
293 print '</td>'."\n";
294
295 print '<td class="center">';
296 $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
297 if (getDolGlobalString($constforvar) == $file) {
298 print img_picto($langs->trans("Activated"), 'switch_on');
299 } else {
300 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
301 print img_picto($langs->trans("Disabled"), 'switch_off');
302 print '</a>';
303 }
304 print '</td>';
305
306 $nameofclass = ucfirst($myTmpObjectKey);
307 $mytmpinstance = new $nameofclass($db);
308 '@phan-var-force Evaluation $mytmpinstance';
309 $mytmpinstance->initAsSpecimen();
310
311 // Info
312 $htmltooltip = '';
313 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
314
315 $nextval = $module->getNextValue($mytmpinstance);
316 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
317 $htmltooltip .= ''.$langs->trans("NextValue").': ';
318 if ($nextval) {
319 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
320 $nextval = $langs->trans($nextval);
321 }
322 $htmltooltip .= $nextval.'<br>';
323 } else {
324 $htmltooltip .= $langs->trans($module->error).'<br>';
325 }
326 }
327
328 print '<td class="center">';
329 print $form->textwithpicto('', $htmltooltip, 1, 0);
330 print '</td>';
331
332 print "</tr>\n";
333 }
334 }
335 }
336 closedir($handle);
337 }
338 }
339 }
340 print "</table>\n";
341 }
342
343 if ($myTmpObjectArray['includedocgeneration']) {
344 /*
345 * Document templates generators
346 */
347 $setupnotempty++;
348 $type = strtolower($myTmpObjectKey);
349
350 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
351
352 // Load array def with activated templates
353 $def = array();
354 $sql = "SELECT nom";
355 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
356 $sql .= " WHERE type = '".$db->escape($type)."'";
357 $sql .= " AND entity = ".$conf->entity;
358 $resql = $db->query($sql);
359 if ($resql) {
360 $i = 0;
361 $num_rows = $db->num_rows($resql);
362 while ($i < $num_rows) {
363 $array = $db->fetch_array($resql);
364 if (is_array($array)) {
365 array_push($def, $array[0]);
366 }
367 $i++;
368 }
369 } else {
370 dol_print_error($db);
371 }
372
373 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
374 print '<table class="noborder centpercent">'."\n";
375 print '<tr class="liste_titre">'."\n";
376 print '<td>'.$langs->trans("Name").'</td>';
377 print '<td>'.$langs->trans("Description").'</td>';
378 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
379 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
380 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
381 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
382 print "</tr>\n";
383
384 clearstatcache();
385
386 foreach ($dirmodels as $reldir) {
387 foreach (array('', '/doc') as $valdir) {
388 $realpath = $reldir."core/modules/".$moduledir.$valdir;
389 $dir = dol_buildpath($realpath);
390
391 if (is_dir($dir)) {
392 $handle = opendir($dir);
393 if (is_resource($handle)) {
394 $filelist = array();
395 while (($file = readdir($handle)) !== false) {
396 $filelist[] = $file;
397 }
398 closedir($handle);
399 arsort($filelist);
400
401 foreach ($filelist as $file) {
402 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
403 if (file_exists($dir.'/'.$file)) {
404 $name = substr($file, 4, dol_strlen($file) - 16);
405 $classname = substr($file, 0, dol_strlen($file) - 12);
406
407 require_once $dir.'/'.$file;
408 $module = new $classname($db);
409
410 '@phan-var-force ModelePDFEvaluation $module';
411
412 $modulequalified = 1;
413 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
414 $modulequalified = 0;
415 }
416 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
417 $modulequalified = 0;
418 }
419
420 if ($modulequalified) {
421 print '<tr class="oddeven"><td width="100">';
422 print(empty($module->name) ? $name : $module->name);
423 print "</td><td>\n";
424 if (method_exists($module, 'info')) {
425 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
426 } else {
427 print $module->description;
428 }
429 print '</td>';
430
431 // Active
432 if (in_array($name, $def)) {
433 print '<td class="center">'."\n";
434 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
435 print img_picto($langs->trans("Enabled"), 'switch_on');
436 print '</a>';
437 print '</td>';
438 } else {
439 print '<td class="center">'."\n";
440 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>';
441 print "</td>";
442 }
443
444 // Default
445 print '<td class="center">';
446 $constforvar = 'HRMTEST_'.strtoupper($myTmpObjectKey).'_ADDON';
447 if (getDolGlobalString($constforvar) == $name) {
448 //print img_picto($langs->trans("Default"), 'on');
449 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
450 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>';
451 } else {
452 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>';
453 }
454 print '</td>';
455
456 // Info
457 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
458 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
459 if ($module->type == 'pdf') {
460 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
461 }
462 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
463
464 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
465 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
466 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
467
468 print '<td class="center">';
469 print $form->textwithpicto('', $htmltooltip, 1, 0);
470 print '</td>';
471
472 // Preview
473 print '<td class="center">';
474 if ($module->type == 'pdf') {
475 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
476 } else {
477 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
478 }
479 print '</td>';
480
481 print "</tr>\n";
482 }
483 }
484 }
485 }
486 }
487 }
488 }
489 }
490
491 print '</table>';
492 print '</div>';
493 }
494}
495
496print load_fiche_titre($langs->trans('OtherOptions'), '', '');
497
498if (!getDolGlobalString('HRM_MAXRANK')) {
499 $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
500}
501
502if ($action == 'edit') {
503 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
504 print '<input type="hidden" name="token" value="'.newToken().'">';
505 print '<input type="hidden" name="action" value="update">';
506
507 print '<table class="noborder centpercent">';
508 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
509
510 foreach ($arrayofparameters as $constname => $val) {
511 if ($val['enabled'] == 1) {
512 $setupnotempty++;
513 print '<tr class="oddeven"><td>';
514 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
515 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
516 print '</td><td>';
517
518 if ($val['type'] == 'textarea') {
519 print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
520 print getDolGlobalString($constname);
521 print "</textarea>\n";
522 } elseif ($val['type'] == 'integer') {
523 print '<input class="flat" name="' . $constname . '" id="' . $constname . '" value="' . getDolGlobalString($constname) . '" type="number" step="1" min="0" max="50" >' . "\n";
524 } elseif ($val['type'] == 'html') {
525 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
526 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
527 $doleditor->Create();
528 } elseif ($val['type'] == 'yesno') {
529 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
530 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
531 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
532 $formmail = new FormMail($db);
533
534 $tmp = explode(':', $val['type']);
535 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
536 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
537 $arrayofmessagename = array();
538 if (is_array($formmail->lines_model)) {
539 foreach ($formmail->lines_model as $modelmail) {
540 //var_dump($modelmail);
541 $moreonlabel = '';
542 if (!empty($arrayofmessagename[$modelmail->label])) {
543 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
544 }
545 // The 'label' is the key that is unique if we exclude the language
546 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
547 }
548 }
549 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
550 } elseif (preg_match('/category:/', $val['type'])) {
551 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
552 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
553 $formother = new FormOther($db);
554
555 $tmp = explode(':', $val['type']);
556 print img_picto('', 'category', 'class="pictofixedwidth"');
557 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
558 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
559 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
560 $formcompany = new FormCompany($db);
561 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
562 } elseif ($val['type'] == 'securekey') {
563 print '<input required="required" type="text" class="flat" id="' . $constname . '" name="' . $constname . '" value="' . (GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)) . '" size="40">';
564 if (!empty($conf->use_javascript_ajax)) {
565 print '&nbsp;' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token' . $constname . '" class="linkobject"');
566 }
567
568 // Add button to autosuggest a key
569 include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
570 print dolJSToSetRandomPassword($constname, 'generate_token' . $constname);
571 } elseif ($val['type'] == 'product') {
572 if (isModEnabled('product') || isModEnabled('service')) {
573 $selected = getDolGlobalString($constname);
574 $form->select_produits($selected, $constname, '', 0);
575 }
576 } else {
577 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
578 }
579 print '</td></tr>';
580 }
581 }
582 print '</table>';
583
584 print '<br><div class="center">';
585 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
586 print '</div>';
587
588 print '</form>';
589 print '<br>';
590} else {
591 if (!empty($arrayofparameters)) {
592 print '<table class="noborder centpercent">';
593 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
594
595 foreach ($arrayofparameters as $constname => $val) {
596 if ($val['enabled'] == 1) {
597 $setupnotempty++;
598 print '<tr class="oddeven"><td>';
599 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
600 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
601 print '</td><td>';
602
603 if ($val['type'] == 'textarea') {
604 print dol_nl2br(getDolGlobalString($constname));
605 } elseif ($val['type'] == 'html') {
606 print getDolGlobalString($constname);
607 } elseif ($val['type'] == 'yesno') {
608 print ajax_constantonoff($constname);
609 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
610 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
611 $formmail = new FormMail($db);
612
613 $tmp = explode(':', $val['type']);
614
615 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
616 if ($template < 0) {
617 setEventMessages(null, $formmail->errors, 'errors');
618 }
619 print $langs->trans($template->label);
620 } elseif (preg_match('/category:/', $val['type'])) {
621 $c = new Categorie($db);
622 $result = $c->fetch(getDolGlobalString($constname));
623 if ($result < 0) {
624 setEventMessages(null, $c->errors, 'errors');
625 }
626 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
627 $toprint = array();
628 foreach ($ways as $way) {
629 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
630 }
631 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
632 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
633 if (getDolGlobalString($constname) == 2) {
634 print $langs->trans("Prospect");
635 } elseif (getDolGlobalString($constname) == 3) {
636 print $langs->trans("ProspectCustomer");
637 } elseif (getDolGlobalString($constname) == 1) {
638 print $langs->trans("Customer");
639 } elseif (getDolGlobalString($constname) == 0) {
640 print $langs->trans("NorProspectNorCustomer");
641 }
642 } elseif ($val['type'] == 'product') {
643 $product = new Product($db);
644 $resprod = $product->fetch(getDolGlobalString($constname));
645 if ($resprod > 0) {
646 print $product->ref;
647 } elseif ($resprod < 0) {
648 setEventMessages(null, $object->errors, "errors");
649 }
650 } else {
651 print getDolGlobalString($constname);
652 }
653 print '</td></tr>';
654 }
655 }
656
657 print '</table>';
658
659 print '<div class="tabsAction">';
660 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
661 print '</div>';
662 } else {
663 print '<br>'.$langs->trans("NothingToSetup");
664 }
665}
666
667
668if (empty($setupnotempty)) {
669 print '<br>'.$langs->trans("NothingToSetup");
670}
671
672// Page end
673print dol_get_fiche_end();
674
675llxFooter();
676$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)
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)
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)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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...
getDolGlobalString($key, $default='')
Return a 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:35
$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.