27require
'../main.inc.php';
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";
37$langs->loadLangs(array(
"admin",
"knowledgemanagement"));
40$action =
GETPOST(
'action',
'aZ09');
41$backtopage =
GETPOST(
'backtopage',
'alpha');
42$value =
GETPOST(
'value',
'alpha');
43$modulepart =
GETPOST(
'modulepart',
'aZ09');
45$label =
GETPOST(
'label',
'alpha');
46$scandir =
GETPOST(
'scan_dir',
'alpha');
47$type =
'knowledgemanagement';
49$arrayofparameters = array(
67 $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON =
'mod_knowledgerecord_standard';
70$moduledir =
'knowledgemanagement';
71$myTmpObjects = array();
73$myTmpObjects[
'knowledgemanagement'] = array(
'label' =>
'KnowledgeManagement',
'includerefgeneration' => 1,
'includedocgeneration' => 0,
'class' =>
'KnowledgeRecord');
75$tmpobjectkey =
GETPOST(
'object',
'aZ09');
76if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
85include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
87if ($action ==
'updateMask') {
88 $maskconst =
GETPOST(
'maskconst',
'aZ09');
89 $maskdata =
GETPOST(
'maskKnowledgeRecord',
'alpha');
91 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
103} elseif ($action ==
'specimen' && $tmpobjectkey) {
104 $modele =
GETPOST(
'module',
'alpha');
106 $className = $myTmpObjects[$tmpobjectkey][
'class'];
107 $tmpobject =
new $className($db);
108 $tmpobject->initAsSpecimen();
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;
122 if ($className !==
'') {
125 $module =
new $className($db);
126 '@phan-var-force ModelePDFKnowledgeRecord $module';
128 if ($module->write_file($tmpobject, $langs) > 0) {
129 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
137 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
139} elseif ($action ==
'setmod') {
141 if (!empty($tmpobjectkey)) {
142 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
"_ADDON";
145} elseif ($action ==
'set') {
148} elseif ($action ==
'del') {
151 $tmpobjectkey =
GETPOST(
'object',
'aZ09');
152 if (!empty($tmpobjectkey)) {
153 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
159} elseif ($action ==
'setdoc') {
161 if (!empty($tmpobjectkey)) {
162 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
166 $conf->global->$constforval = $value;
175} elseif ($action ==
'unsetdoc') {
176 if (!empty($tmpobjectkey)) {
177 $constforval =
'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
188$form =
new Form($db);
190$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
192$page_name =
"KnowledgeManagementSetup";
193llxHeader(
'', $langs->trans($page_name),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-knowledgemanagement');
196$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
202print
dol_get_fiche_head($head,
'setup', $langs->trans(
'ModuleKnowledgeManagementName'), -1,
"knowledgemanagement");
205echo
'<span class="opacitymedium">'.$langs->trans(
"KnowledgeManagementSetupPage").
'</span><br><br>';
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">';
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>';
217 foreach ($arrayofparameters as $constname => $val) {
218 if ($val[
'enabled'] == 1) {
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>';
225 if ($val[
'type'] ==
'textarea') {
226 print
'<textarea class="flat" name="' . $constname .
'" id="' . $constname .
'" cols="50" rows="5" wrap="soft">' .
"\n";
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') {
235 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
236 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
239 $tmp = explode(
':', $val[
'type']);
240 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
242 $arrayofmessagename = array();
243 if (is_array($formmail->lines_model)) {
244 foreach ($formmail->lines_model as $modelmail) {
247 if (!empty($arrayofmessagename[$modelmail->label])) {
248 $moreonlabel =
' <span class="opacitymedium">(' . $langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
251 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)) . $moreonlabel;
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';
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';
266 print $formcompany->selectProspectCustomerType(
getDolGlobalString($constname), $constname);
268 print
'<input name="'.$constname.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($constname).
'">';
275 print $form->buttonsSaveCancel(
"Save",
'');
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>';
285 foreach ($arrayofparameters as $constname => $val) {
286 if ($val[
'enabled'] == 1) {
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);
293 if ($val[
'type'] ==
'textarea') {
295 } elseif ($val[
'type'] ==
'html') {
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';
303 $tmp = explode(
':', $val[
'type']);
305 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs,
getDolGlobalString($constname));
309 print $langs->trans($template->label);
310 } elseif (preg_match(
'/category:/', $val[
'type'])) {
316 $ways = $c->print_all_ways(
' >> ',
'none', 0, 1);
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>';
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'])) {
324 print $langs->trans(
"Prospect");
326 print $langs->trans(
"ProspectCustomer");
328 print $langs->trans(
"Customer");
330 print $langs->trans(
"NorProspectNorCustomer");
341 print
'<div class="tabsAction">';
342 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
350foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
351 if (!empty($myTmpObjectArray[
'includerefgeneration'])) {
357 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
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>';
370 foreach ($dirmodels as $reldir) {
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);
380 require_once $dir.
'/'.$file.
'.php';
382 $module =
new $file($db);
384 '@phan-var-force ModeleNumRefKnowledgeRecord $module';
387 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
390 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
394 if ($module->isEnabled()) {
395 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
397 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
398 print $module->info($langs);
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>';
414 print
'<td class="center">';
415 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectArray[
'class']).
'_ADDON';
417 print
img_picto($langs->trans(
"Activated"),
'switch_on');
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');
425 $className = $myTmpObjectArray[
'class'];
426 $mytmpinstance =
new $className($db);
427 $mytmpinstance->initAsSpecimen();
431 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
433 $nextval = $module->getNextValue($mytmpinstance);
434 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
435 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
437 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
438 $nextval = $langs->trans($nextval);
440 $htmltooltip .= $nextval.
'<br>';
442 $htmltooltip .= $langs->trans($module->error).
'<br>';
446 print
'<td class="center">';
447 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
458 print
"</table><br>\n";
461 if (!empty($myTmpObjectArray[
'includedocgeneration'])) {
466 $type = strtolower($myTmpObjectKey);
468 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
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);
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]);
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>';
503 foreach ($dirmodels as $reldir) {
504 foreach (array(
'',
'/doc') as $valdir) {
505 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
509 $handle = opendir($dir);
510 if (is_resource($handle)) {
512 while (($file = readdir($handle)) !==
false) {
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);
524 require_once $dir.
'/'.$file;
525 $module =
new $className($db);
527 '@phan-var-force ModelePDFKnowledgeRecord $module';
529 $modulequalified = 1;
530 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
531 $modulequalified = 0;
533 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
534 $modulequalified = 0;
537 if ($modulequalified) {
538 print
'<tr class="oddeven"><td width="100">';
539 print(empty($module->name) ? $name : $module->
name);
541 if (method_exists($module,
'info')) {
542 print $module->info($langs);
544 print $module->description;
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');
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>';
562 print
'<td class="center">';
563 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
567 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
569 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
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;
579 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
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);
585 print
'<td class="center">';
586 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
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>';
594 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
612if (empty($setupnotempty)) {
613 print
'<br>'.$langs->trans(
"NothingToSetup");
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.
Class to manage categories.
Class to manage a WYSIWYG editor.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.