dolibarr 20.0.0
knowledgemanagement.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28
29global $langs, $user;
30
31// Libraries
32require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
33require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/lib/knowledgemanagement.lib.php";
34require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/class/knowledgerecord.class.php";
35
36// Translations
37$langs->loadLangs(array("admin", "knowledgemanagement"));
38
39// Parameters
40$action = GETPOST('action', 'aZ09');
41$backtopage = GETPOST('backtopage', 'alpha');
42$value = GETPOST('value', 'alpha');
43$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
44
45$label = GETPOST('label', 'alpha');
46$scandir = GETPOST('scan_dir', 'alpha');
47$type = 'knowledgemanagement';
48
49$arrayofparameters = array(
50 //'KNOWLEDGEMANAGEMENT_MYPARAM1' => array('type' => 'string', 'css' => 'minwidth500' ,'enabled' => 0),
51 //'KNOWLEDGEMANAGEMENT_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
52 //'KNOWLEDGEMANAGEMENT_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
53 //'KNOWLEDGEMANAGEMENT_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
54 //'KNOWLEDGEMANAGEMENT_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
55 //'KNOWLEDGEMANAGEMENT_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
56);
57
58$error = 0;
59$setupnotempty = 0;
60
61// Access control
62if (!$user->admin) {
64}
65
66if (!getDolGlobalString('KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON')) {
67 $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON = 'mod_knowledgerecord_standard';
68}
69
70$moduledir = 'knowledgemanagement';
71$myTmpObjects = array();
72// TODO Scan list of objects to fill this array
73$myTmpObjects['knowledgemanagement'] = array('label' => 'KnowledgeManagement', 'includerefgeneration' => 1, 'includedocgeneration' => 0, 'class' => 'KnowledgeRecord');
74
75$tmpobjectkey = GETPOST('object', 'aZ09');
76if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
77 accessforbidden('Bad value for object. Hack attempt ?');
78}
79
80
81/*
82 * Actions
83 */
84
85include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
86
87if ($action == 'updateMask') {
88 $maskconst = GETPOST('maskconst', 'aZ09');
89 $maskdata = GETPOST('maskKnowledgeRecord', 'alpha');
90
91 if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
92 $res = dolibarr_set_const($db, $maskconst, $maskdata, 'chaine', 0, '', $conf->entity);
93 if (!($res > 0)) {
94 $error++;
95 }
96 }
97
98 if (!$error) {
99 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
100 } else {
101 setEventMessages($langs->trans("Error"), null, 'errors');
102 }
103} elseif ($action == 'specimen' && $tmpobjectkey) {
104 $modele = GETPOST('module', 'alpha');
105
106 $className = $myTmpObjects[$tmpobjectkey]['class'];
107 $tmpobject = new $className($db);
108 $tmpobject->initAsSpecimen();
109
110 // Search template files
111 $file = '';
112 $className = '';
113 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
114 foreach ($dirmodels as $reldir) {
115 $file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
116 if (file_exists($file)) {
117 $className = "pdf_".$modele;
118 break;
119 }
120 }
121
122 if ($className !== '') {
123 require_once $file;
124
125 $module = new $className($db);
126 '@phan-var-force CommonDocGenerator $module';
127
128 if ($module->write_file($tmpobject, $langs) > 0) {
129 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
130 return;
131 } else {
132 setEventMessages($module->error, null, 'errors');
133 dol_syslog($module->error, LOG_ERR);
134 }
135 } else {
136 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
137 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
138 }
139} elseif ($action == 'setmod') {
140 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
141 if (!empty($tmpobjectkey)) {
142 $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey)."_ADDON";
143 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
144 }
145} elseif ($action == 'set') {
146 // Activate a model
147 $ret = addDocumentModel($value, $type, $label, $scandir);
148} elseif ($action == 'del') {
149 $ret = delDocumentModel($value, $type);
150 if ($ret > 0) {
151 $tmpobjectkey = GETPOST('object', 'aZ09');
152 if (!empty($tmpobjectkey)) {
153 $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
154 if (getDolGlobalString($constforval) == "$value") {
155 dolibarr_del_const($db, $constforval, $conf->entity);
156 }
157 }
158 }
159} elseif ($action == 'setdoc') {
160 // Set or unset default model
161 if (!empty($tmpobjectkey)) {
162 $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
163 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
164 // The constant that was read before the new set
165 // We therefore requires a variable to have a coherent view
166 $conf->global->$constforval = $value;
167 }
168
169 // We disable/enable the document template (into llx_document_model table)
170 $ret = delDocumentModel($value, $type);
171 if ($ret > 0) {
172 $ret = addDocumentModel($value, $type, $label, $scandir);
173 }
174 }
175} elseif ($action == 'unsetdoc') {
176 if (!empty($tmpobjectkey)) {
177 $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
178 dolibarr_del_const($db, $constforval, $conf->entity);
179 }
180}
181
182
183
184/*
185 * View
186 */
187
188$form = new Form($db);
189
190$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
191
192$page_name = "KnowledgeManagementSetup";
193llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-admin page-knowledgemanagement');
194
195// Subheader
196$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
197
198print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
199
200// Configuration header
202print dol_get_fiche_head($head, 'setup', $langs->trans('ModuleKnowledgeManagementName'), -1, "knowledgemanagement");
203
204// Setup page goes here
205echo '<span class="opacitymedium">'.$langs->trans("KnowledgeManagementSetupPage").'</span><br><br>';
206
207
208if ($action == 'edit') {
209 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
210 print '<input type="hidden" name="token" value="'.newToken().'">';
211 print '<input type="hidden" name="action" value="update">';
212
213 print '<table class="noborder centpercent">';
214 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
215
216 foreach ($arrayofparameters as $constname => $val) {
217 if ($val['enabled'] == 1) {
218 $setupnotempty++;
219 print '<tr class="oddeven"><td>';
220 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
221 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
222 print '</td><td>';
223
224 if ($val['type'] == 'textarea') {
225 print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
226 print getDolGlobalString($constname);
227 print "</textarea>\n";
228 } elseif ($val['type'] == 'html') {
229 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
230 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
231 $doleditor->Create();
232 } elseif ($val['type'] == 'yesno') {
233 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
234 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
235 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
236 $formmail = new FormMail($db);
237
238 $tmp = explode(':', $val['type']);
239 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
240 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
241 $arrayofmessagename = array();
242 if (is_array($formmail->lines_model)) {
243 foreach ($formmail->lines_model as $modelmail) {
244 //var_dump($modelmail);
245 $moreonlabel = '';
246 if (!empty($arrayofmessagename[$modelmail->label])) {
247 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
248 }
249 // The 'label' is the key that is unique if we exclude the language
250 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
251 }
252 }
253 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
254 } elseif (preg_match('/category:/', $val['type'])) {
255 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
256 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
257 $formother = new FormOther($db);
258
259 $tmp = explode(':', $val['type']);
260 print img_picto('', 'category', 'class="pictofixedwidth"');
261 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
262 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
263 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
264 $formcompany = new FormCompany($db);
265 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
266 } else {
267 print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($constname).'">';
268 }
269 print '</td></tr>';
270 }
271 }
272 print '</table>';
273
274 print $form->buttonsSaveCancel("Save", '');
275
276 print '</form>';
277 print '<br>';
278} else {
279 if (!empty($arrayofparameters)) {
280 print '<table class="noborder centpercent">';
281 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
282
283 foreach ($arrayofparameters as $constname => $val) {
284 if ($val['enabled'] == 1) {
285 $setupnotempty++;
286 print '<tr class="oddeven"><td>';
287 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
288 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
289 print '</td><td>';
290
291 if ($val['type'] == 'textarea') {
292 print dol_nl2br(getDolGlobalString($constname));
293 } elseif ($val['type'] == 'html') {
294 print getDolGlobalString($constname);
295 } elseif ($val['type'] == 'yesno') {
296 print ajax_constantonoff($constname);
297 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
298 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
299 $formmail = new FormMail($db);
300
301 $tmp = explode(':', $val['type']);
302
303 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
304 if ($template < 0) {
305 setEventMessages(null, $formmail->errors, 'errors');
306 }
307 print $langs->trans($template->label);
308 } elseif (preg_match('/category:/', $val['type'])) {
309 $c = new Categorie($db);
310 $result = $c->fetch(getDolGlobalInt($constname));
311 if ($result < 0) {
312 setEventMessages(null, $c->errors, 'errors');
313 }
314 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
315 $toprint = array();
316 foreach ($ways as $way) {
317 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
318 }
319 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
320 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
321 if (getDolGlobalString($constname) == 2) {
322 print $langs->trans("Prospect");
323 } elseif (getDolGlobalString($constname) == 3) {
324 print $langs->trans("ProspectCustomer");
325 } elseif (getDolGlobalInt($constname) == 1) {
326 print $langs->trans("Customer");
327 } elseif (getDolGlobalInt($constname) == 0) {
328 print $langs->trans("NorProspectNorCustomer");
329 }
330 } else {
331 print getDolGlobalString($constname);
332 }
333 print '</td></tr>';
334 }
335 }
336
337 print '</table>';
338
339 print '<div class="tabsAction">';
340 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
341 print '</div>';
342 } else {
343 //print '<br>'.$langs->trans("NothingToSetup");
344 }
345}
346
347
348foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
349 if (!empty($myTmpObjectArray['includerefgeneration'])) {
350 /*
351 * Orders Numbering model
352 */
353 $setupnotempty++;
354
355 print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
356
357 print '<table class="noborder centpercent">';
358 print '<tr class="liste_titre">';
359 print '<td>'.$langs->trans("Name").'</td>';
360 print '<td>'.$langs->trans("Description").'</td>';
361 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
362 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
363 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
364 print '</tr>'."\n";
365
366 clearstatcache();
367
368 foreach ($dirmodels as $reldir) {
369 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
370
371 if (is_dir($dir)) {
372 $handle = opendir($dir);
373 if (is_resource($handle)) {
374 while (($file = readdir($handle)) !== false) {
375 if (strpos($file, 'mod_'.strtolower($myTmpObjectArray['class']).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
376 $file = substr($file, 0, dol_strlen($file) - 4);
377
378 require_once $dir.'/'.$file.'.php';
379
380 $module = new $file($db);
381
382 // Show modules according to features level
383 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
384 continue;
385 }
386 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
387 continue;
388 }
389
390 if ($module->isEnabled()) {
391 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
392
393 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
394 print $module->info($langs);
395 print '</td>';
396
397 // Show example of numbering model
398 print '<td class="nowrap">';
399 $tmp = $module->getExample();
400 if (preg_match('/^Error/', $tmp)) {
401 $langs->load("errors");
402 print '<div class="error">'.$langs->trans($tmp).'</div>';
403 } elseif ($tmp == 'NotConfigured') {
404 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
405 } else {
406 print $tmp;
407 }
408 print '</td>'."\n";
409
410 print '<td class="center">';
411 $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectArray['class']).'_ADDON';
412 if (getDolGlobalString($constforvar) == $file) {
413 print img_picto($langs->trans("Activated"), 'switch_on');
414 } else {
415 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectArray['class']).'&value='.urlencode($file).'">';
416 print img_picto($langs->trans("Disabled"), 'switch_off');
417 print '</a>';
418 }
419 print '</td>';
420
421 $className = $myTmpObjectArray['class'];
422 $mytmpinstance = new $className($db);
423 $mytmpinstance->initAsSpecimen();
424
425 // Info
426 $htmltooltip = '';
427 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
428
429 $nextval = $module->getNextValue($mytmpinstance);
430 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
431 $htmltooltip .= ''.$langs->trans("NextValue").': ';
432 if ($nextval) {
433 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
434 $nextval = $langs->trans($nextval);
435 }
436 $htmltooltip .= $nextval.'<br>';
437 } else {
438 $htmltooltip .= $langs->trans($module->error).'<br>';
439 }
440 }
441
442 print '<td class="center">';
443 print $form->textwithpicto('', $htmltooltip, 1, 0);
444 print '</td>';
445
446 print "</tr>\n";
447 }
448 }
449 }
450 closedir($handle);
451 }
452 }
453 }
454 print "</table><br>\n";
455 }
456
457 if (!empty($myTmpObjectArray['includedocgeneration'])) {
458 /*
459 * Document templates generators
460 */
461 $setupnotempty++;
462 $type = strtolower($myTmpObjectKey);
463
464 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
465
466 // Load array def with activated templates
467 $def = array();
468 $sql = "SELECT nom";
469 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
470 $sql .= " WHERE type = '".$db->escape($type)."'";
471 $sql .= " AND entity = ".$conf->entity;
472 $resql = $db->query($sql);
473 if ($resql) {
474 $i = 0;
475 $num_rows = $db->num_rows($resql);
476 while ($i < $num_rows) {
477 $array = $db->fetch_array($resql);
478 if (is_array($array)) {
479 array_push($def, $array[0]);
480 }
481 $i++;
482 }
483 } else {
484 dol_print_error($db);
485 }
486
487 print "<table class=\"noborder\" width=\"100%\">\n";
488 print "<tr class=\"liste_titre\">\n";
489 print '<td>'.$langs->trans("Name").'</td>';
490 print '<td>'.$langs->trans("Description").'</td>';
491 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
492 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
493 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
494 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
495 print "</tr>\n";
496
497 clearstatcache();
498
499 foreach ($dirmodels as $reldir) {
500 foreach (array('', '/doc') as $valdir) {
501 $realpath = $reldir."core/modules/".$moduledir.$valdir;
502 $dir = dol_buildpath($realpath);
503
504 if (is_dir($dir)) {
505 $handle = opendir($dir);
506 if (is_resource($handle)) {
507 $filelist = array();
508 while (($file = readdir($handle)) !== false) {
509 $filelist[] = $file;
510 }
511 closedir($handle);
512 arsort($filelist);
513
514 foreach ($filelist as $file) {
515 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
516 if (file_exists($dir.'/'.$file)) {
517 $name = substr($file, 4, dol_strlen($file) - 16);
518 $className = substr($file, 0, dol_strlen($file) - 12);
519
520 require_once $dir.'/'.$file;
521 $module = new $className($db);
522
523 $modulequalified = 1;
524 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
525 $modulequalified = 0;
526 }
527 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
528 $modulequalified = 0;
529 }
530
531 if ($modulequalified) {
532 print '<tr class="oddeven"><td width="100">';
533 print(empty($module->name) ? $name : $module->name);
534 print "</td><td>\n";
535 if (method_exists($module, 'info')) {
536 print $module->info($langs);
537 } else {
538 print $module->description;
539 }
540 print '</td>';
541
542 // Active
543 if (in_array($name, $def)) {
544 print '<td class="center">'."\n";
545 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
546 print img_picto($langs->trans("Enabled"), 'switch_on');
547 print '</a>';
548 print '</td>';
549 } else {
550 print '<td class="center">'."\n";
551 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
552 print "</td>";
553 }
554
555 // Default
556 print '<td class="center">';
557 $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
558 if (getDolGlobalString($constforvar) == $name) {
559 //print img_picto($langs->trans("Default"), 'on');
560 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
561 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>';
562 } else {
563 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>';
564 }
565 print '</td>';
566
567 // Info
568 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
569 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
570 if ($module->type == 'pdf') {
571 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
572 }
573 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
574
575 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
576 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
577 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
578
579 print '<td class="center">';
580 print $form->textwithpicto('', $htmltooltip, 1, 0);
581 print '</td>';
582
583 // Preview
584 print '<td class="center">';
585 if ($module->type == 'pdf') {
586 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
587 } else {
588 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
589 }
590 print '</td>';
591
592 print "</tr>\n";
593 }
594 }
595 }
596 }
597 }
598 }
599 }
600 }
601
602 print '</table>';
603 }
604}
605
606if (empty($setupnotempty)) {
607 print '<br>'.$langs->trans("NothingToSetup");
608}
609
610// Page end
611print dol_get_fiche_end();
612
613llxFooter();
614$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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
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)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
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.
knowledgemanagementAdminPrepareHead()
Prepare admin pages header.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.