dolibarr 21.0.0-alpha
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 ModelePDFKnowledgeRecord $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 // @phan-suppress-next-line PhanEmptyForeach
217 foreach ($arrayofparameters as $constname => $val) {
218 if ($val['enabled'] == 1) {
219 $setupnotempty++;
220 print '<tr class="oddeven"><td>';
221 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
222 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
223 print '</td><td>';
224
225 if ($val['type'] == 'textarea') {
226 print '<textarea class="flat" name="' . $constname . '" id="' . $constname . '" cols="50" rows="5" wrap="soft">' . "\n";
227 print getDolGlobalString($constname);
228 print "</textarea>\n";
229 } elseif ($val['type'] == 'html') {
230 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
231 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
232 $doleditor->Create();
233 } elseif ($val['type'] == 'yesno') {
234 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
235 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
236 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
237 $formmail = new FormMail($db);
238
239 $tmp = explode(':', $val['type']);
240 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
241 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
242 $arrayofmessagename = array();
243 if (is_array($formmail->lines_model)) {
244 foreach ($formmail->lines_model as $modelmail) {
245 //var_dump($modelmail);
246 $moreonlabel = '';
247 if (!empty($arrayofmessagename[$modelmail->label])) {
248 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
249 }
250 // The 'label' is the key that is unique if we exclude the language
251 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
252 }
253 }
254 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
255 } elseif (preg_match('/category:/', $val['type'])) {
256 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
257 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
258 $formother = new FormOther($db);
259
260 $tmp = explode(':', $val['type']);
261 print img_picto('', 'category', 'class="pictofixedwidth"');
262 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
263 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
264 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
265 $formcompany = new FormCompany($db);
266 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname);
267 } else {
268 print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($constname).'">';
269 }
270 print '</td></tr>';
271 }
272 }
273 print '</table>';
274
275 print $form->buttonsSaveCancel("Save", '');
276
277 print '</form>';
278 print '<br>';
279} else {
280 if (!empty($arrayofparameters)) {
281 print '<table class="noborder centpercent">';
282 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
283
284 // @phan-suppress-next-line PhanEmptyForeach
285 foreach ($arrayofparameters as $constname => $val) {
286 if ($val['enabled'] == 1) {
287 $setupnotempty++;
288 print '<tr class="oddeven"><td>';
289 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
290 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
291 print '</td><td>';
292
293 if ($val['type'] == 'textarea') {
294 print dol_nl2br(getDolGlobalString($constname));
295 } elseif ($val['type'] == 'html') {
296 print getDolGlobalString($constname);
297 } elseif ($val['type'] == 'yesno') {
298 print ajax_constantonoff($constname);
299 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
300 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
301 $formmail = new FormMail($db);
302
303 $tmp = explode(':', $val['type']);
304
305 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
306 if ($template < 0) {
307 setEventMessages(null, $formmail->errors, 'errors');
308 }
309 print $langs->trans($template->label);
310 } elseif (preg_match('/category:/', $val['type'])) {
311 $c = new Categorie($db);
312 $result = $c->fetch(getDolGlobalInt($constname));
313 if ($result < 0) {
314 setEventMessages(null, $c->errors, 'errors');
315 }
316 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
317 $toprint = array();
318 foreach ($ways as $way) {
319 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
320 }
321 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
322 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
323 if (getDolGlobalString($constname) == 2) {
324 print $langs->trans("Prospect");
325 } elseif (getDolGlobalString($constname) == 3) {
326 print $langs->trans("ProspectCustomer");
327 } elseif (getDolGlobalInt($constname) == 1) {
328 print $langs->trans("Customer");
329 } elseif (getDolGlobalInt($constname) == 0) {
330 print $langs->trans("NorProspectNorCustomer");
331 }
332 } else {
333 print getDolGlobalString($constname);
334 }
335 print '</td></tr>';
336 }
337 }
338
339 print '</table>';
340
341 print '<div class="tabsAction">';
342 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
343 print '</div>';
344 } else {
345 //print '<br>'.$langs->trans("NothingToSetup");
346 }
347}
348
349
350foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
351 if (!empty($myTmpObjectArray['includerefgeneration'])) {
352 /*
353 * Orders Numbering model
354 */
355 $setupnotempty++;
356
357 print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
358
359 print '<table class="noborder centpercent">';
360 print '<tr class="liste_titre">';
361 print '<td>'.$langs->trans("Name").'</td>';
362 print '<td>'.$langs->trans("Description").'</td>';
363 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
364 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
365 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
366 print '</tr>'."\n";
367
368 clearstatcache();
369
370 foreach ($dirmodels as $reldir) {
371 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
372
373 if (is_dir($dir)) {
374 $handle = opendir($dir);
375 if (is_resource($handle)) {
376 while (($file = readdir($handle)) !== false) {
377 if (strpos($file, 'mod_'.strtolower($myTmpObjectArray['class']).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
378 $file = substr($file, 0, dol_strlen($file) - 4);
379
380 require_once $dir.'/'.$file.'.php';
381
382 $module = new $file($db);
383
384 '@phan-var-force ModeleNumRefKnowledgeRecord $module';
385
386 // Show modules according to features level
387 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
388 continue;
389 }
390 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
391 continue;
392 }
393
394 if ($module->isEnabled()) {
395 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
396
397 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
398 print $module->info($langs);
399 print '</td>';
400
401 // Show example of numbering model
402 print '<td class="nowrap">';
403 $tmp = $module->getExample();
404 if (preg_match('/^Error/', $tmp)) {
405 $langs->load("errors");
406 print '<div class="error">'.$langs->trans($tmp).'</div>';
407 } elseif ($tmp == 'NotConfigured') {
408 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
409 } else {
410 print $tmp;
411 }
412 print '</td>'."\n";
413
414 print '<td class="center">';
415 $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectArray['class']).'_ADDON';
416 if (getDolGlobalString($constforvar) == $file) {
417 print img_picto($langs->trans("Activated"), 'switch_on');
418 } else {
419 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectArray['class']).'&value='.urlencode($file).'">';
420 print img_picto($langs->trans("Disabled"), 'switch_off');
421 print '</a>';
422 }
423 print '</td>';
424
425 $className = $myTmpObjectArray['class'];
426 $mytmpinstance = new $className($db);
427 $mytmpinstance->initAsSpecimen();
428
429 // Info
430 $htmltooltip = '';
431 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
432
433 $nextval = $module->getNextValue($mytmpinstance);
434 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
435 $htmltooltip .= ''.$langs->trans("NextValue").': ';
436 if ($nextval) {
437 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
438 $nextval = $langs->trans($nextval);
439 }
440 $htmltooltip .= $nextval.'<br>';
441 } else {
442 $htmltooltip .= $langs->trans($module->error).'<br>';
443 }
444 }
445
446 print '<td class="center">';
447 print $form->textwithpicto('', $htmltooltip, 1, 0);
448 print '</td>';
449
450 print "</tr>\n";
451 }
452 }
453 }
454 closedir($handle);
455 }
456 }
457 }
458 print "</table><br>\n";
459 }
460
461 if (!empty($myTmpObjectArray['includedocgeneration'])) {
462 /*
463 * Document templates generators
464 */
465 $setupnotempty++;
466 $type = strtolower($myTmpObjectKey);
467
468 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
469
470 // Load array def with activated templates
471 $def = array();
472 $sql = "SELECT nom";
473 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
474 $sql .= " WHERE type = '".$db->escape($type)."'";
475 $sql .= " AND entity = ".$conf->entity;
476 $resql = $db->query($sql);
477 if ($resql) {
478 $i = 0;
479 $num_rows = $db->num_rows($resql);
480 while ($i < $num_rows) {
481 $array = $db->fetch_array($resql);
482 if (is_array($array)) {
483 array_push($def, $array[0]);
484 }
485 $i++;
486 }
487 } else {
488 dol_print_error($db);
489 }
490
491 print "<table class=\"noborder\" width=\"100%\">\n";
492 print "<tr class=\"liste_titre\">\n";
493 print '<td>'.$langs->trans("Name").'</td>';
494 print '<td>'.$langs->trans("Description").'</td>';
495 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
496 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
497 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
498 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
499 print "</tr>\n";
500
501 clearstatcache();
502
503 foreach ($dirmodels as $reldir) {
504 foreach (array('', '/doc') as $valdir) {
505 $realpath = $reldir."core/modules/".$moduledir.$valdir;
506 $dir = dol_buildpath($realpath);
507
508 if (is_dir($dir)) {
509 $handle = opendir($dir);
510 if (is_resource($handle)) {
511 $filelist = array();
512 while (($file = readdir($handle)) !== false) {
513 $filelist[] = $file;
514 }
515 closedir($handle);
516 arsort($filelist);
517
518 foreach ($filelist as $file) {
519 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
520 if (file_exists($dir.'/'.$file)) {
521 $name = substr($file, 4, dol_strlen($file) - 16);
522 $className = substr($file, 0, dol_strlen($file) - 12);
523
524 require_once $dir.'/'.$file;
525 $module = new $className($db);
526
527 '@phan-var-force ModelePDFKnowledgeRecord $module';
528
529 $modulequalified = 1;
530 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
531 $modulequalified = 0;
532 }
533 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
534 $modulequalified = 0;
535 }
536
537 if ($modulequalified) {
538 print '<tr class="oddeven"><td width="100">';
539 print(empty($module->name) ? $name : $module->name);
540 print "</td><td>\n";
541 if (method_exists($module, 'info')) {
542 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
543 } else {
544 print $module->description;
545 }
546 print '</td>';
547
548 // Active
549 if (in_array($name, $def)) {
550 print '<td class="center">'."\n";
551 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
552 print img_picto($langs->trans("Enabled"), 'switch_on');
553 print '</a>';
554 print '</td>';
555 } else {
556 print '<td class="center">'."\n";
557 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>';
558 print "</td>";
559 }
560
561 // Default
562 print '<td class="center">';
563 $constforvar = 'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).'_ADDON';
564 if (getDolGlobalString($constforvar) == $name) {
565 //print img_picto($langs->trans("Default"), 'on');
566 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
567 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>';
568 } else {
569 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>';
570 }
571 print '</td>';
572
573 // Info
574 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
575 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
576 if ($module->type == 'pdf') {
577 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
578 }
579 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
580
581 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
582 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
583 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
584
585 print '<td class="center">';
586 print $form->textwithpicto('', $htmltooltip, 1, 0);
587 print '</td>';
588
589 // Preview
590 print '<td class="center">';
591 if ($module->type == 'pdf') {
592 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
593 } else {
594 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
595 }
596 print '</td>';
597
598 print "</tr>\n";
599 }
600 }
601 }
602 }
603 }
604 }
605 }
606 }
607
608 print '</table>';
609 }
610}
611
612if (empty($setupnotempty)) {
613 print '<br>'.$langs->trans("NothingToSetup");
614}
615
616// Page end
617print dol_get_fiche_end();
618
619llxFooter();
620$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: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.
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)
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.
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.
$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.