26require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
32require_once
'../lib/bookcal.lib.php';
36$langs->loadLangs(array(
"admin",
"agenda"));
39$hookmanager->initHooks(array(
'bookcalsetup',
'globalsetup'));
47$action =
GETPOST(
'action',
'aZ09');
48$backtopage =
GETPOST(
'backtopage',
'alpha');
49$modulepart =
GETPOST(
'modulepart',
'aZ09');
51$value =
GETPOST(
'value',
'alpha');
52$label =
GETPOST(
'label',
'alpha');
53$scandir =
GETPOST(
'scan_dir',
'alpha');
63if (!class_exists(
'FormSetup')) {
65 if (floatval(DOL_VERSION) < 16.0 && !class_exists(
'FormSetup')) {
66 require_once __DIR__.
'/../backport/v16/core/class/html.formsetup.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
76$item = $formSetup->newItem(
'NO_PARAM_JUST_TEXT');
77$item->fieldOverride = (empty($_SERVER[
'HTTPS']) ?
'http://' :
'https://') . $_SERVER[
'HTTP_HOST'];
78$item->cssClass =
'minwidth500';
81$item = $formSetup->newItem(
'BOOKCAL_MYPARAM1');
82$item->defaultFieldValue =
'default value';
85$item = $formSetup->newItem(
'BOOKCAL_MYPARAM2');
86$item->nameText = $item->getNameText().
' more html text ';
89$item = $formSetup->newItem(
'BOOKCAL_MYPARAM3');
90$item->setAsThirdpartyType();
93$formSetup->newItem(
'BOOKCAL_MYPARAM4')->setAsYesNo();
96$formSetup->newItem(
'BOOKCAL_MYPARAM5')->setAsEmailTemplate(
'thirdparty');
99$formSetup->newItem(
'BOOKCAL_MYPARAM6')->setAsSecureKey()->enabled = 0;
102$formSetup->newItem(
'BOOKCAL_MYPARAM7')->setAsProduct();
104$formSetup->newItem(
'Title')->setAsTitle();
107$item = $formSetup->newItem(
'BOOKCAL_MYPARAM8');
109 'test01' => $langs->trans(
'test01'),
110 'test02' => $langs->trans(
'test02'),
111 'test03' => $langs->trans(
'test03'),
112 'test04' => $langs->trans(
'test04'),
113 'test05' => $langs->trans(
'test05'),
114 'test06' => $langs->trans(
'test06'),
116$item->setAsMultiSelect($TField);
117$item->helpText = $langs->transnoentities(
'BOOKCAL_MYPARAM8');
121$formSetup->newItem(
'BOOKCAL_MYPARAM9')->setAsSelect($TField);
125$item = $formSetup->newItem(
'BOOKCAL_MYPARAM10');
127$item->defaultFieldValue =
'#FF0000';
128$item->nameText = $item->getNameText().
' more html text ';
129$item->fieldInputOverride =
'';
130$item->helpText = $langs->transnoentities(
'AnHelpMessage');
138$setupnotempty =+ count($formSetup->items);
141$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
149if (
versioncompare(explode(
'.', DOL_VERSION), array(15)) < 0 && $action ==
'update' && !empty($user->admin)) {
150 $formSetup->saveConfFromPost();
153include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
155if ($action ==
'updateMask') {
156 $maskconst =
GETPOST(
'maskconst',
'aZ09');
157 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
159 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
160 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
171} elseif ($action ==
'specimen') {
172 $modele =
GETPOST(
'module',
'alpha');
173 $tmpobjectkey =
GETPOST(
'object');
175 $tmpobject =
new $tmpobjectkey($db);
176 $tmpobject->initAsSpecimen();
179 $file =
''; $classname =
''; $filefound = 0;
180 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
181 foreach ($dirmodels as $reldir) {
182 $file =
dol_buildpath($reldir.
"core/modules/bookcal/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
183 if (file_exists($file)) {
185 $classname =
"pdf_".$modele.
"_".strtolower($tmpobjectkey);
193 $module =
new $classname($db);
195 if ($module->write_file($tmpobject, $langs) > 0) {
196 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=bookcal-".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
204 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
206} elseif ($action ==
'setmod') {
208 $tmpobjectkey =
GETPOST(
'object');
209 if (!empty($tmpobjectkey)) {
210 $constforval =
'BOOKCAL_'.strtoupper($tmpobjectkey).
"_ADDON";
213} elseif ($action ==
'set') {
216} elseif ($action ==
'del') {
219 $tmpobjectkey =
GETPOST(
'object');
220 if (!empty($tmpobjectkey)) {
221 $constforval =
'BOOKCAL_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
222 if ($conf->global->$constforval ==
"$value") {
227} elseif ($action ==
'setdoc') {
229 $tmpobjectkey =
GETPOST(
'object');
230 if (!empty($tmpobjectkey)) {
231 $constforval =
'BOOKCAL_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
235 $conf->global->$constforval = $value;
244} elseif ($action ==
'unsetdoc') {
245 $tmpobjectkey =
GETPOST(
'object');
246 if (!empty($tmpobjectkey)) {
247 $constforval =
'BOOKCAL_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
258$form =
new Form($db);
261$page_name =
"BookCalSetup";
263llxHeader(
'', $langs->trans($page_name), $help_url);
266$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
272print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"fa-calendar-check");
275echo
'<span class="opacitymedium">'.$langs->trans(
"BookCalSetupPage").
'</span><br><br>';
278if ($action ==
'edit') {
279 print $formSetup->generateOutput(
true);
281} elseif (!empty($formSetup->items)) {
282 print $formSetup->generateOutput();
283 print
'<div class="tabsAction">';
284 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
287 print
'<br>'.$langs->trans(
"NothingToSetup");
291$moduledir =
'bookcal';
292$myTmpObjects = array();
293$myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
296foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
297 if ($myTmpObjectKey ==
'MyObject') {
300 if ($myTmpObjectArray[
'includerefgeneration']) {
306 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
308 print
'<table class="noborder centpercent">';
309 print
'<tr class="liste_titre">';
310 print
'<td>'.$langs->trans(
"Name").
'</td>';
311 print
'<td>'.$langs->trans(
"Description").
'</td>';
312 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
313 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
314 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
319 foreach ($dirmodels as $reldir) {
323 $handle = opendir($dir);
324 if (is_resource($handle)) {
325 while (($file = readdir($handle)) !==
false) {
326 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
327 $file = substr($file, 0,
dol_strlen($file) - 4);
329 require_once $dir.
'/'.$file.
'.php';
331 $module =
new $file($db);
334 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
337 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
341 if ($module->isEnabled()) {
342 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
344 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
345 print $module->info();
349 print
'<td class="nowrap">';
350 $tmp = $module->getExample();
351 if (preg_match(
'/^Error/', $tmp)) {
352 $langs->load(
"errors");
353 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
354 } elseif ($tmp ==
'NotConfigured') {
355 print $langs->trans($tmp);
361 print
'<td class="center">';
362 $constforvar =
'BOOKCAL_'.strtoupper($myTmpObjectKey).
'_ADDON';
364 print
img_picto($langs->trans(
"Activated"),
'switch_on');
366 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
367 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
372 $mytmpinstance =
new $myTmpObjectKey($db);
373 $mytmpinstance->initAsSpecimen();
377 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
379 $nextval = $module->getNextValue($mytmpinstance);
380 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
381 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
383 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
384 $nextval = $langs->trans($nextval);
386 $htmltooltip .= $nextval.
'<br>';
388 $htmltooltip .= $langs->trans($module->error).
'<br>';
392 print
'<td class="center">';
393 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
404 print
"</table><br>\n";
407 if ($myTmpObjectArray[
'includedocgeneration']) {
412 $type = strtolower($myTmpObjectKey);
414 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
419 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
420 $sql .=
" WHERE type = '".$db->escape($type).
"'";
421 $sql .=
" AND entity = ".$conf->entity;
422 $resql = $db->query($sql);
425 $num_rows = $db->num_rows($resql);
426 while ($i < $num_rows) {
427 $array = $db->fetch_array($resql);
428 array_push($def, $array[0]);
435 print
"<table class=\"noborder\" width=\"100%\">\n";
436 print
"<tr class=\"liste_titre\">\n";
437 print
'<td>'.$langs->trans(
"Name").
'</td>';
438 print
'<td>'.$langs->trans(
"Description").
'</td>';
439 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
440 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
441 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
442 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
447 foreach ($dirmodels as $reldir) {
448 foreach (array(
'',
'/doc') as $valdir) {
449 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
453 $handle = opendir($dir);
454 if (is_resource($handle)) {
455 while (($file = readdir($handle)) !==
false) {
461 foreach ($filelist as $file) {
462 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
463 if (file_exists($dir.
'/'.$file)) {
464 $name = substr($file, 4,
dol_strlen($file) - 16);
465 $classname = substr($file, 0,
dol_strlen($file) - 12);
467 require_once $dir.
'/'.$file;
468 $module =
new $classname($db);
470 $modulequalified = 1;
471 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
472 $modulequalified = 0;
474 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
475 $modulequalified = 0;
478 if ($modulequalified) {
479 print
'<tr class="oddeven"><td width="100">';
480 print (empty($module->name) ? $name : $module->
name);
482 if (method_exists($module,
'info')) {
483 print $module->info($langs);
485 print $module->description;
490 if (in_array($name, $def)) {
491 print
'<td class="center">'.
"\n";
492 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
493 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
497 print
'<td class="center">'.
"\n";
498 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>';
503 print
'<td class="center">';
504 $constforvar =
'BOOKCAL_'.strtoupper($myTmpObjectKey).
'_ADDON';
508 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
510 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
515 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
516 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
517 if ($module->type ==
'pdf') {
518 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
520 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
522 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
523 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
524 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
526 print
'<td class="center">';
527 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
531 print
'<td class="center">';
532 if ($module->type ==
'pdf') {
533 $newname = preg_replace(
'/_'.preg_quote(strtolower($myTmpObjectKey),
'/').
'/',
'', $name);
534 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($newname).
'&object='.urlencode($myTmpObjectKey).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
536 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
554if (empty($setupnotempty)) {
555 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.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
bookcalAdminPrepareHead()
Prepare admin pages header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
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.
$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.