dolibarr 24.0.0-beta
setup.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 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) ---Replace with your own copyright and developer email---
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
27$res = 0;
28// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
29if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
30 $res = @include str_replace("..", "", $_SERVER["CONTEXT_DOCUMENT_ROOT"])."/main.inc.php";
31}
32// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
33$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
34$tmp2 = realpath(__FILE__);
35$i = strlen($tmp) - 1;
36$j = strlen($tmp2) - 1;
37while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
38 $i--;
39 $j--;
40}
41if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
42 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
43}
44if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
45 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
46}
47// Try main.inc.php using relative path
48if (!$res && file_exists("../../main.inc.php")) {
49 $res = @include "../../main.inc.php";
50}
51if (!$res && file_exists("../../../main.inc.php")) {
52 $res = @include "../../../main.inc.php";
53}
54if (!$res) {
55 die("Include of main fails");
56}
57
58// Libraries
59require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
60require_once '../lib/mymodule.lib.php';
61//require_once "../class/myclass.class.php";
62
71// Translations
72$langs->loadLangs(array("admin", "mymodule@mymodule"));
73
74// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
76$hookmanager->initHooks(array('mymodulesetup', 'globalsetup'));
77
78// Parameters
79$action = GETPOST('action', 'aZ09');
80$backtopage = GETPOST('backtopage', 'alpha');
81$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
82
83$value = GETPOST('value', 'alpha');
84$label = GETPOST('label', 'alpha');
85$scandir = GETPOST('scan_dir', 'alpha');
86$type = 'myobject';
87
88$error = 0;
89$setupnotempty = 0;
90
91// Access control
92if (!$user->admin) {
94}
95
96
97// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
98$useFormSetup = 1;
99
100if (!class_exists('FormSetup')) {
101 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
102}
103$formSetup = new FormSetup($db);
104
105// Enter here all parameters in your setup page
106
107// Setup conf for selection of an URL
108$item = $formSetup->newItem('MYMODULE_MYPARAM1');
109$item->fieldParams['isMandatory'] = 1;
110$item->fieldAttr['placeholder'] = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'];
111$item->cssClass = 'minwidth500';
112
113// Setup conf for selection of a simple string input
114$item = $formSetup->newItem('MYMODULE_MYPARAM2');
115$item->defaultFieldValue = 'default value';
116$item->fieldAttr['placeholder'] = 'A placeholder here';
117$item->helpText = 'Tooltip text';
118
119// Setup conf for selection of a simple textarea input but we replace the text of field title
120$item = $formSetup->newItem('MYMODULE_MYPARAM3');
121$item->nameText = $item->getNameText().' more html text ';
122
123// Setup conf for a selection of a Thirdparty
124$item = $formSetup->newItem('MYMODULE_MYPARAM4');
125$item->setAsThirdpartyType();
126
127// Setup conf for a selection of a boolean
128$formSetup->newItem('MYMODULE_MYPARAM5')->setAsYesNo(); // ->fieldParams['alertifoff'] = 1 or ->fieldParams['alertifon'] = 1;
129
130// Setup conf for a selection of an Email template of type thirdparty
131$formSetup->newItem('MYMODULE_MYPARAM6')->setAsEmailTemplate('thirdparty');
132
133// Setup conf for a selection of a secured key
134//$formSetup->newItem('MYMODULE_MYPARAM7')->setAsSecureKey();
135
136// Setup conf for a selection of a Product
137$formSetup->newItem('MYMODULE_MYPARAM8')->setAsProduct();
138
139// Add a title for a new section
140$formSetup->newItem('NewSection')->setAsTitle();
141
142$TField = array(
143 'test01' => $langs->trans('test01'),
144 'test02' => $langs->trans('test02'),
145 'test03' => $langs->trans('test03'),
146 'test04' => $langs->trans('test04'),
147 'test05' => $langs->trans('test05'),
148 'test06' => $langs->trans('test06'),
149);
150
151// Setup conf for a simple combo list
152$formSetup->newItem('MYMODULE_MYPARAM9')->setAsSelect($TField);
153
154// Setup conf for a multiselect combo list
155$item = $formSetup->newItem('MYMODULE_MYPARAM10');
156$item->setAsMultiSelect($TField);
157$item->helpText = $langs->transnoentities('MYMODULE_MYPARAM10');
158
159// Setup conf for a category selection
160$formSetup->newItem('MYMODULE_CATEGORY_ID_XXX')->setAsCategory('product');
161
162// Setup conf MYMODULE_MYPARAM10
163$item = $formSetup->newItem('MYMODULE_MYPARAM10');
164$item->setAsColor();
165$item->defaultFieldValue = '#FF0000';
166//$item->fieldValue = '';
167//$item->fieldAttr = array() ; // fields attribute only for compatible fields like input text
168//$item->fieldOverride = false; // set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too
169//$item->fieldInputOverride = false; // set this var to override field input
170//$item->fieldOutputOverride = false; // set this var to override field output
171
172$item = $formSetup->newItem('MYMODULE_MYPARAM11')->setAsHtml();
173$item->nameText = $item->getNameText().' more html text ';
174$item->fieldInputOverride = '';
175$item->helpText = $langs->transnoentities('HelpMessage');
176$item->cssClass = 'minwidth500';
177
178$item = $formSetup->newItem('MYMODULE_MYPARAM12');
179$item->fieldOverride = "Value forced, can't be modified";
180$item->cssClass = 'minwidth500';
181
182//$item = $formSetup->newItem('MYMODULE_MYPARAM13')->setAsDate(); // Not yet implemented
183
184// End of definition of parameters
185
186
187$setupnotempty += count($formSetup->items);
188
189
190$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
191
192$moduledir = 'mymodule';
193$myTmpObjects = array();
194// TODO Scan list of objects to fill this array
195$myTmpObjects['myobject'] = array('label' => 'MyObject', 'includerefgeneration' => 0, 'includedocgeneration' => 0, 'class' => 'MyObject');
196
197$tmpobjectkey = GETPOST('object', 'aZ09');
198if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) {
199 accessforbidden('Bad value for object. Hack attempt ?');
200}
201
202
203/*
204 * Actions
205 */
206
207// For retrocompatibility Dolibarr < 15.0
208if (versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) {
209 $formSetup->saveConfFromPost();
210}
211
212include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
213
214if ($action == 'updateMask') {
215 $maskconst = GETPOST('maskconst', 'aZ09');
216 $maskvalue = GETPOST('maskvalue', 'alpha');
217
218 if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
219 $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
220 if (!($res > 0)) {
221 $error++;
222 }
223 }
224
225 if (!$error) {
226 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
227 } else {
228 setEventMessages($langs->trans("Error"), null, 'errors');
229 }
230} elseif ($action == 'specimen' && $tmpobjectkey) {
231 $modele = GETPOST('module', 'alpha');
232
233 $className = $myTmpObjects[$tmpobjectkey]['class'];
234 $tmpobject = new $className($db);
235 '@phan-var-force MyObject $tmpobject';
236 $tmpobject->initAsSpecimen();
237
238 // Search template files
239 $file = '';
240 $className = '';
241 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
242 foreach ($dirmodels as $reldir) {
243 $file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
244 if (file_exists($file)) {
245 $className = "pdf_".$modele."_".strtolower($tmpobjectkey);
246 break;
247 }
248 }
249
250 if ($className !== '') {
251 require_once $file;
252
253 $module = new $className($db);
254 '@phan-var-force ModelePDFMyObject $module';
255
256 '@phan-var-force ModelePDFMyObject $module';
257
258 if ($module->write_file($tmpobject, $langs) > 0) {
259 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mymodule-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
260 exit;
261 } else {
262 setEventMessages($module->error, null, 'errors');
263 dol_syslog($module->error, LOG_ERR);
264 }
265 } else {
266 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
267 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
268 }
269} elseif ($action == 'setmod') {
270 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
271 if (!empty($tmpobjectkey)) {
272 $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey)."_ADDON";
273 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
274 }
275} elseif ($action == 'set') {
276 // Activate a model
277 $ret = addDocumentModel($value, $type, $label, $scandir);
278} elseif ($action == 'del') {
279 $ret = delDocumentModel($value, $type);
280 if ($ret > 0) {
281 if (!empty($tmpobjectkey)) {
282 $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
283 if (getDolGlobalString($constforval) == "$value") {
284 dolibarr_del_const($db, $constforval, $conf->entity);
285 }
286 }
287 }
288} elseif ($action == 'setdoc') {
289 // Set or unset default model
290 if (!empty($tmpobjectkey)) {
291 $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
292 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
293 // The constant that was read before the new set
294 // We therefore requires a variable to have a coherent view
295 $conf->global->{$constforval} = $value;
296 }
297
298 // We disable/enable the document template (into llx_document_model table)
299 $ret = delDocumentModel($value, $type);
300 if ($ret > 0) {
301 $ret = addDocumentModel($value, $type, $label, $scandir);
302 }
303 }
304} elseif ($action == 'unsetdoc') {
305 if (!empty($tmpobjectkey)) {
306 $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
307 dolibarr_del_const($db, $constforval, $conf->entity);
308 }
309}
310
311$action = 'edit';
312
313
314/*
315 * View
316 */
317
318$form = new Form($db);
319
320$help_url = '';
321$title = "MyModuleSetup";
322
323llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', '', '', 'mod-mymodule page-admin');
324
325// Subheader
326$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
327
328print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
329
330// Configuration header
332print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "mymodule@mymodule");
333
334// Setup page goes here
335echo '<span class="opacitymedium">'.$langs->trans("MyModuleSetupPage").'</span><br><br>';
336
337
338/*if ($action == 'edit') {
339 print $formSetup->generateOutput(true);
340 print '<br>';
341 } elseif (!empty($formSetup->items)) {
342 print $formSetup->generateOutput();
343 print '<div class="tabsAction">';
344 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
345 print '</div>';
346 }
347 */
348if (!empty($formSetup->items)) {
349 print $formSetup->generateOutput(true);
350 print '<br>';
351}
352
353
354$refGenerationObjects = array();
355$docGenerationObjects = array();
356
357foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
358 if (!empty($myTmpObjectArray['includerefgeneration'])) {
359 $refGenerationObjects[$myTmpObjectKey] = $myTmpObjectArray;
360 }
361
362 if (!empty($myTmpObjectArray['includedocgeneration'])) {
363 $docGenerationObjects[$myTmpObjectKey] = $myTmpObjectArray;
364 }
365}
366
367// Numbering models
368if (!empty($refGenerationObjects)) {
369 $setupnotempty++;
370
371 print load_fiche_titre($langs->trans("NumberingModules"), '', '');
372
373 print '<table class="noborder centpercent">';
374 print '<tr class="liste_titre">';
375 print '<td>'.$langs->trans("Name").'</td>';
376 print '<td>'.$langs->trans("Description").'</td>';
377 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
378 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
379 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
380 print '</tr>'."\n";
381
382 clearstatcache();
383
384 foreach ($refGenerationObjects as $myTmpObjectKey => $myTmpObjectArray) {
385 if (empty($myTmpObjectArray['includerefgeneration'])) {
386 continue;
387 }
388
389 print '<tr class="liste_titre">';
390 print '<td colspan="5"><strong>'.$langs->trans($myTmpObjectArray['label']).'</strong></td>';
391 print '</tr>'."\n";
392
393 foreach ($dirmodels as $reldir) {
394 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
395
396 if (!is_dir($dir)) {
397 continue;
398 }
399
400 $handle = opendir($dir);
401 if (!is_resource($handle)) {
402 continue;
403 }
404
405 while (($file = readdir($handle)) !== false) {
406 if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') !== 0 || substr($file, dol_strlen($file) - 3, 3) != 'php') {
407 continue;
408 }
409
410 $file = substr($file, 0, dol_strlen($file) - 4);
411
412 require_once $dir.'/'.$file.'.php';
413
414 $module = new $file($db);
415 '@phan-var-force ModeleNumRefMyObject $module';
416
417 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
418 continue;
419 }
420 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
421 continue;
422 }
423 if (!$module->isEnabled()) {
424 continue;
425 }
426
427 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
428
429 print '<tr class="oddeven"><td>'.$module->getName($langs)."</td><td>\n";
430 print $module->info($langs);
431 print '</td>';
432
433 print '<td class="nowrap">';
434 $tmp = $module->getExample();
435 if (preg_match('/^Error/', $tmp)) {
436 $langs->load("errors");
437 print '<div class="error">'.$langs->trans($tmp).'</div>';
438 } elseif ($tmp == 'NotConfigured') {
439 print $langs->trans($tmp);
440 } else {
441 print $tmp;
442 }
443 print '</td>'."\n";
444
445 print '<td class="center">';
446 $constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON';
447 $defaultifnotset = 'thevaluetousebydefault';
448 $activenumberingmodel = getDolGlobalString($constforvar, $defaultifnotset);
449
450 if ($activenumberingmodel == $file) {
451 print img_picto($langs->trans("Activated"), 'switch_on');
452 } else {
453 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($file).'">';
454 print img_picto($langs->trans("Disabled"), 'switch_off');
455 print '</a>';
456 }
457 print '</td>';
458
459 $className = $myTmpObjectArray['class'];
460 $mytmpinstance = new $className($db);
461 '@phan-var-force MyObject $mytmpinstance';
462 $mytmpinstance->initAsSpecimen();
463
464 $htmltooltip = '';
465 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
466
467 $nextval = $module->getNextValue($mytmpinstance);
468 if ("$nextval" != $langs->trans("NotAvailable")) {
469 $htmltooltip .= ''.$langs->trans("NextValue").': ';
470 if ($nextval) {
471 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
472 $nextval = $langs->trans($nextval);
473 }
474 $htmltooltip .= $nextval.'<br>';
475 } else {
476 $htmltooltip .= $langs->trans($module->error).'<br>';
477 }
478 }
479
480 print '<td class="center">';
481 print $form->textwithpicto('', $htmltooltip, 1, 'info');
482 print '</td>';
483
484 print "</tr>\n";
485 }
486
487 closedir($handle);
488 }
489
490 print '<tr><td colspan="5"><br></td></tr>'."\n";
491 }
492
493 print "</table><br>\n";
494}
495
496// Document templates generators
497if (!empty($docGenerationObjects)) {
498 $setupnotempty++;
499
500 print load_fiche_titre($langs->trans("DocumentModules"), '', '');
501
502 print '<table class="noborder centpercent">'."\n";
503 print '<tr class="liste_titre">'."\n";
504 print '<td>'.$langs->trans("Name").'</td>';
505 print '<td>'.$langs->trans("Description").'</td>';
506 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
507 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
508 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
509 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
510 print "</tr>\n";
511
512 clearstatcache();
513
514 foreach ($docGenerationObjects as $myTmpObjectKey => $myTmpObjectArray) {
515 if (empty($myTmpObjectArray['includedocgeneration'])) {
516 continue;
517 }
518
519 $type = strtolower($myTmpObjectKey);
520
521 print '<tr class="liste_titre">';
522 print '<td colspan="6"><strong>'.$langs->trans($myTmpObjectArray['label']).'</strong></td>';
523 print '</tr>'."\n";
524
525 $def = array();
526
527 $sql = "SELECT nom";
528 $sql .= " FROM ".$db->prefix()."document_model";
529 $sql .= " WHERE type = '".$db->escape($type)."'";
530 $sql .= " AND entity = ".$conf->entity;
531
532 $resql = $db->query($sql);
533 if ($resql) {
534 $i = 0;
535 $num_rows = $db->num_rows($resql);
536 while ($i < $num_rows) {
537 $array = $db->fetch_array($resql);
538 array_push($def, $array[0]);
539 $i++;
540 }
541 } else {
543 }
544
545 foreach ($dirmodels as $reldir) {
546 foreach (array('', '/doc') as $valdir) {
547 $realpath = $reldir."core/modules/".$moduledir.$valdir;
548 $dir = dol_buildpath($realpath);
549
550 if (!is_dir($dir)) {
551 continue;
552 }
553
554 $handle = opendir($dir);
555 if (!is_resource($handle)) {
556 continue;
557 }
558
559 $filelist = array();
560
561 while (($file = readdir($handle)) !== false) {
562 $filelist[] = $file;
563 }
564 closedir($handle);
565
566 arsort($filelist);
567
568 foreach ($filelist as $file) {
569 if (!preg_match('/\.modules\.php$/i', $file) || !preg_match('/^(pdf_|doc_)/', $file)) {
570 continue;
571 }
572
573 if (!preg_match('/_'.preg_quote($type, '/').'(_odt)?\.modules\.php$/i', $file)) {
574 continue;
575 }
576
577 if (!file_exists($dir.'/'.$file)) {
578 continue;
579 }
580
581 $name = substr($file, 4, dol_strlen($file) - 16);
582 $className = substr($file, 0, dol_strlen($file) - 12);
583
584 require_once $dir.'/'.$file;
585
586 $module = new $className($db);
587 '@phan-var-force ModelePDFMyObject $module';
588
589 $modulequalified = 1;
590 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
591 $modulequalified = 0;
592 }
593 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
594 $modulequalified = 0;
595 }
596
597 if (!$modulequalified) {
598 continue;
599 }
600
601 print '<tr class="oddeven"><td width="100">';
602 print(empty($module->name) ? $name : $module->name);
603 print "</td><td>\n";
604
605 if (method_exists($module, 'info')) {
606 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
607 } else {
608 print $module->description;
609 }
610
611 print '</td>';
612
613 if (in_array($name, $def)) {
614 print '<td class="center">'."\n";
615 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&type='.urlencode($type).'">';
616 print img_picto($langs->trans("Enabled"), 'switch_on');
617 print '</a>';
618 print '</td>';
619 } else {
620 print '<td class="center">'."\n";
621 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'">';
622 print img_picto($langs->trans("Disabled"), 'switch_off');
623 print '</a>';
624 print "</td>";
625 }
626
627 print '<td class="center">';
628 $constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON_PDF';
629
630 if (getDolGlobalString($constforvar) == $name) {
631 print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">';
632 print img_picto($langs->trans("Enabled"), 'on');
633 print '</a>';
634 } else {
635 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&object='.urlencode($type).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Default").'">';
636 print img_picto($langs->trans("Disabled"), 'off');
637 print '</a>';
638 }
639
640 print '</td>';
641
642 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
643 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
644
645 if ($module->type == 'pdf') {
646 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
647 }
648
649 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
650 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
651 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
652 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
653
654 print '<td class="center">';
655 print $form->textwithpicto('', $htmltooltip, 1, 'info');
656 print '</td>';
657
658 print '<td class="center">';
659 if ($module->type == 'pdf') {
660 $newname = preg_replace('/_'.preg_quote($type, '/').'/', '', $name);
661 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.urlencode($newname).'&object='.urlencode($type).'">';
662 print img_object($langs->trans("Preview"), 'pdf');
663 print '</a>';
664 } else {
665 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"), 'generic');
666 }
667 print '</td>';
668
669 print "</tr>\n";
670 }
671 }
672 }
673
674 print '<tr><td colspan="6"><br></td></tr>'."\n";
675 }
676
677 print '</table>';
678}
679
680if (empty($setupnotempty)) {
681 print '<br>'.$langs->trans("NothingToSetup");
682}
683
684// Page end
685print dol_get_fiche_end();
686
687llxFooter();
688$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.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:72
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
mymoduleAdminPrepareHead()
Prepare admin pages header.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.