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