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 CommonDocGenerator $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>';
216 foreach ($arrayofparameters as $constname => $val) {
217 if ($val[
'enabled'] == 1) {
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>';
224 if ($val[
'type'] ==
'textarea') {
225 print
'<textarea class="flat" name="' . $constname .
'" id="' . $constname .
'" cols="50" rows="5" wrap="soft">' .
"\n";
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') {
234 } elseif (preg_match(
'/emailtemplate:/', $val[
'type'])) {
235 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
238 $tmp = explode(
':', $val[
'type']);
239 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
241 $arrayofmessagename = array();
242 if (is_array($formmail->lines_model)) {
243 foreach ($formmail->lines_model as $modelmail) {
246 if (!empty($arrayofmessagename[$modelmail->label])) {
247 $moreonlabel =
' <span class="opacitymedium">(' . $langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
250 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)) . $moreonlabel;
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';
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';
265 print $formcompany->selectProspectCustomerType(
getDolGlobalString($constname), $constname);
267 print
'<input name="'.$constname.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.
getDolGlobalString($constname).
'">';
274 print $form->buttonsSaveCancel(
"Save",
'');
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>';
283 foreach ($arrayofparameters as $constname => $val) {
284 if ($val[
'enabled'] == 1) {
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);
291 if ($val[
'type'] ==
'textarea') {
293 } elseif ($val[
'type'] ==
'html') {
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';
301 $tmp = explode(
':', $val[
'type']);
303 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs,
getDolGlobalString($constname));
307 print $langs->trans($template->label);
308 } elseif (preg_match(
'/category:/', $val[
'type'])) {
314 $ways = $c->print_all_ways(
' >> ',
'none', 0, 1);
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>';
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'])) {
322 print $langs->trans(
"Prospect");
324 print $langs->trans(
"ProspectCustomer");
326 print $langs->trans(
"Customer");
328 print $langs->trans(
"NorProspectNorCustomer");
339 print
'<div class="tabsAction">';
340 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
348foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
349 if (!empty($myTmpObjectArray[
'includerefgeneration'])) {
355 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
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>';
368 foreach ($dirmodels as $reldir) {
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);
378 require_once $dir.
'/'.$file.
'.php';
380 $module =
new $file($db);
383 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
386 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
390 if ($module->isEnabled()) {
391 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
393 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
394 print $module->info($langs);
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>';
410 print
'<td class="center">';
411 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectArray[
'class']).
'_ADDON';
413 print
img_picto($langs->trans(
"Activated"),
'switch_on');
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');
421 $className = $myTmpObjectArray[
'class'];
422 $mytmpinstance =
new $className($db);
423 $mytmpinstance->initAsSpecimen();
427 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
429 $nextval = $module->getNextValue($mytmpinstance);
430 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
431 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
433 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
434 $nextval = $langs->trans($nextval);
436 $htmltooltip .= $nextval.
'<br>';
438 $htmltooltip .= $langs->trans($module->error).
'<br>';
442 print
'<td class="center">';
443 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
454 print
"</table><br>\n";
457 if (!empty($myTmpObjectArray[
'includedocgeneration'])) {
462 $type = strtolower($myTmpObjectKey);
464 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
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);
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]);
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>';
499 foreach ($dirmodels as $reldir) {
500 foreach (array(
'',
'/doc') as $valdir) {
501 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
505 $handle = opendir($dir);
506 if (is_resource($handle)) {
508 while (($file = readdir($handle)) !==
false) {
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);
520 require_once $dir.
'/'.$file;
521 $module =
new $className($db);
523 $modulequalified = 1;
524 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
525 $modulequalified = 0;
527 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
528 $modulequalified = 0;
531 if ($modulequalified) {
532 print
'<tr class="oddeven"><td width="100">';
533 print(empty($module->name) ? $name : $module->
name);
535 if (method_exists($module,
'info')) {
536 print $module->info($langs);
538 print $module->description;
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');
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>';
556 print
'<td class="center">';
557 $constforvar =
'KNOWLEDGEMANAGEMENT_'.strtoupper($myTmpObjectKey).
'_ADDON';
561 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>';
563 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>';
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;
573 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
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);
579 print
'<td class="center">';
580 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
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>';
588 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
606if (empty($setupnotempty)) {
607 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()
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)
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.