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