dolibarr 18.0.6
eventorganization.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24// Load Dolibarr environment
25require '../main.inc.php';
26
27global $langs, $user;
28
29// Libraries
30require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
31require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
33
34// Translations
35$langs->loadLangs(array("admin", "eventorganization", "categories"));
36
37// Parameters
38$action = GETPOST('action', 'aZ09');
39$cancel = GETPOST('cancel', 'aZ09');
40$backtopage = GETPOST('backtopage', 'alpha');
41
42$value = GETPOST('value', 'alpha');
43$label = GETPOST('label', 'alpha');
44$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
45
46$scandir = GETPOST('scan_dir', 'alpha');
47$type = 'myobject';
48
49$arrayofparameters = array(
50 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1),
51 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
52 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
53 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
54 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1),
55 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
56 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
57 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
58 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
59 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
60 //'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:conferenceorbooth', 'enabled'=>1),
61 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1),
62 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1),
63 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
64);
65
66$error = 0;
67$setupnotempty = 0;
68
69$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
70
71// Access control
72if (empty($user->admin)) {
74}
75
76
77
78/*
79 * Actions
80 */
81
82if ($cancel) {
83 $action ='';
84}
85
86include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
87
88if ($action == 'updateMask') {
89 $maskconstorder = GETPOST('maskconstorder', 'aZ09');
90 $maskorder = GETPOST('maskorder', 'alpha');
91
92 if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
93 $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
94 if (!($res > 0)) {
95 $error++;
96 }
97 }
98
99 if (!$error) {
100 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
101 } else {
102 setEventMessages($langs->trans("Error"), null, 'errors');
103 }
104} elseif ($action == 'specimen') {
105 $modele = GETPOST('module', 'alpha');
106 $tmpobjectkey = GETPOST('object');
107
108 $tmpobject = new $tmpobjectkey($db);
109 $tmpobject->initAsSpecimen();
110
111 // Search template files
112 $file = ''; $classname = ''; $filefound = 0;
113 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
114 foreach ($dirmodels as $reldir) {
115 $file = dol_buildpath($reldir."core/modules/eventorganization/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
116 if (file_exists($file)) {
117 $filefound = 1;
118 $classname = "pdf_".$modele;
119 break;
120 }
121 }
122
123 if ($filefound) {
124 require_once $file;
125
126 $module = new $classname($db);
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 $tmpobjectkey = GETPOST('object');
142 if (!empty($tmpobjectkey)) {
143 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
144 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
145 }
146} elseif ($action == 'set') {
147 // Activate a model
148 $ret = addDocumentModel($value, $type, $label, $scandir);
149} elseif ($action == 'del') {
150 $ret = delDocumentModel($value, $type);
151 if ($ret > 0) {
152 $tmpobjectkey = GETPOST('object');
153 if (!empty($tmpobjectkey)) {
154 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
155 if ($conf->global->$constforval == "$value") {
156 dolibarr_del_const($db, $constforval, $conf->entity);
157 }
158 }
159 }
160}/* elseif ($action == 'setdoc') {
161 // Set or unset default model
162 $tmpobjectkey = GETPOST('object');
163 if (!empty($tmpobjectkey)) {
164 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
165 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
166 // The constant that was read before the new set
167 // We therefore requires a variable to have a coherent view
168 $conf->global->$constforval = $value;
169 }
170
171 // We disable/enable the document template (into llx_document_model table)
172 $ret = delDocumentModel($value, $type);
173 if ($ret > 0) {
174 $ret = addDocumentModel($value, $type, $label, $scandir);
175 }
176 }
177} elseif ($action == 'unsetdoc') {
178 $tmpobjectkey = GETPOST('object');
179 if (!empty($tmpobjectkey)) {
180 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
181 dolibarr_del_const($db, $constforval, $conf->entity);
182 }
183}*/
184
185
186
187/*
188 * View
189 */
190
191$form = new Form($db);
192
193$page_name = "EventOrganizationSetup";
194
195llxHeader('', $langs->trans($page_name));
196
197// Subheader
198$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
199
200print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
201
202// Configuration header
204print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
205
206// Setup page goes here
207echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
208
209
210if ($action == 'edit') {
211 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
212 print '<input type="hidden" name="token" value="'.newToken().'">';
213 print '<input type="hidden" name="action" value="update">';
214
215 print '<table class="noborder centpercent">';
216 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
217
218 foreach ($arrayofparameters as $constname => $val) {
219 if ($val['enabled']==1) {
220 $setupnotempty++;
221 print '<tr class="oddeven"><td><!-- '.$constname.' -->';
222 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
223 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
224 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
225 print '</td><td>';
226
227 if ($val['type'] == 'textarea') {
228 print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
229 print getDolGlobalString($constname);
230 print "</textarea>\n";
231 } elseif ($val['type']== 'html') {
232 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
233 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
234 $doleditor->Create();
235 } elseif ($val['type'] == 'yesno') {
236 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
237 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
238 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
239 $formmail = new FormMail($db);
240
241 $tmp = explode(':', $val['type']);
242 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
243 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
244 $arrayofmessagename = array();
245 if (is_array($formmail->lines_model)) {
246 foreach ($formmail->lines_model as $modelmail) {
247 //var_dump($modelmail);
248 $moreonlabel = '';
249 if (!empty($arrayofmessagename[$modelmail->label])) {
250 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
251 }
252 // The 'label' is the key that is unique if we exclude the language
253 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
254 }
255 }
256 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
257 } elseif (preg_match('/category:/', $val['type'])) {
258 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
259 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
260 $formother = new FormOther($db);
261
262 $tmp = explode(':', $val['type']);
263 print img_picto('', 'category', 'class="pictofixedwidth"');
264 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
265 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
266 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
267 $formcompany = new FormCompany($db);
268 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
269 } elseif ($val['type'] == 'securekey') {
270 print '<input type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : getDolGlobalString($constname)).'" size="40">';
271 if (!empty($conf->use_javascript_ajax)) {
272 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
273 }
274
275 // Add button to autosuggest a key
276 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
277 print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
278 } elseif ($val['type'] == 'product') {
279 if (isModEnabled("product") || isModEnabled("service")) {
280 $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
281 $form->select_produits($selected, $constname, '', 0);
282 }
283 } else {
284 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
285 }
286 print '</td></tr>';
287 }
288 }
289 print '</table>';
290
291 print $form->buttonsSaveCancel();
292
293 print '</form>';
294 print '<br>';
295} else {
296 if (!empty($arrayofparameters)) {
297 print '<table class="noborder centpercent">';
298 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
299
300 foreach ($arrayofparameters as $constname => $val) {
301 if ($val['enabled']==1) {
302 $setupnotempty++;
303 print '<tr class="oddeven">';
304 print '<td><!-- '.$constname.' -->';
305 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
306 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
307 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
308 print '</td><td>';
309
310 if ($val['type'] == 'textarea') {
311 print dol_nl2br(getDolGlobalString($constname));
312 } elseif ($val['type']== 'html') {
313 print getDolGlobalString($constname);
314 } elseif ($val['type'] == 'yesno') {
315 print ajax_constantonoff($constname);
316 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
317 if (getDolGlobalString($constname)) {
318 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
319 $formmail = new FormMail($db);
320
321 $tmp = explode(':', $val['type']);
322 $labelemailtemplate = getDolGlobalString($constname);
323 if ($labelemailtemplate && $labelemailtemplate != '-1') {
324 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
325 if (is_numeric($template) && $template < 0) {
326 setEventMessages($formmail->error, $formmail->errors, 'errors');
327 } else {
328 if ($template->label != 'default') {
329 print $langs->trans($template->label);
330 }
331 }
332 }
333 }
334 } elseif (preg_match('/category:/', $val['type'])) {
335 if (getDolGlobalString($constname)) {
336 $c = new Categorie($db);
337 $result = $c->fetch(getDolGlobalString($constname));
338 if ($result < 0) {
339 setEventMessages(null, $c->errors, 'errors');
340 }
341 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
342 $toprint = array();
343 foreach ($ways as $way) {
344 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
345 }
346 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
347 }
348 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
349 if (getDolGlobalString($constname)==2) {
350 print $langs->trans("Prospect");
351 } elseif (getDolGlobalString($constname)==3) {
352 print $langs->trans("ProspectCustomer");
353 } elseif (getDolGlobalString($constname)==1) {
354 print $langs->trans("Customer");
355 } elseif (getDolGlobalString($constname)==0) {
356 print $langs->trans("NorProspectNorCustomer");
357 }
358 } elseif ($val['type'] == 'product') {
359 $product = new Product($db);
360 $idproduct = getDolGlobalString($constname);
361 if ($idproduct > 0) {
362 $resprod = $product->fetch($idproduct);
363 if ($resprod > 0) {
364 print $product->getNomUrl(1);
365 } elseif ($resprod < 0) {
366 setEventMessages($product->error, $product->errors, "errors");
367 }
368 }
369 } else {
370 print getDolGlobalString($constname);
371 }
372 print '</td>';
373
374 print '</tr>';
375 }
376 }
377
378 print '</table>';
379
380 print '<div class="tabsAction">';
381 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
382 print '</div>';
383 } else {
384 print '<br>'.$langs->trans("NothingToSetup");
385 }
386}
387
388
389/*$moduledir = 'eventorganization';
390$myTmpObjects = array();
391$myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
392
393
394foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
395 if ($myTmpObjectKey == 'MyObject') {
396 continue;
397 }
398 if ($myTmpObjectArray['includerefgeneration']) {
399 $setupnotempty++;
400
401 print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
402
403 print '<table class="noborder centpercent">';
404 print '<tr class="liste_titre">';
405 print '<td>'.$langs->trans("Name").'</td>';
406 print '<td>'.$langs->trans("Description").'</td>';
407 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
408 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
409 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
410 print '</tr>'."\n";
411
412 clearstatcache();
413
414 foreach ($dirmodels as $reldir) {
415 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
416
417 if (is_dir($dir)) {
418 $handle = opendir($dir);
419 if (is_resource($handle)) {
420 while (($file = readdir($handle)) !== false) {
421 if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
422 $file = substr($file, 0, dol_strlen($file) - 4);
423
424 require_once $dir.'/'.$file.'.php';
425
426 $module = new $file($db);
427
428 // Show modules according to features level
429 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
430 continue;
431 }
432 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
433 continue;
434 }
435
436 if ($module->isEnabled()) {
437 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
438
439 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
440 print $module->info();
441 print '</td>';
442
443 // Show example of numbering model
444 print '<td class="nowrap">';
445 $tmp = $module->getExample();
446 if (preg_match('/^Error/', $tmp)) {
447 $langs->load("errors");
448 print '<div class="error">'.$langs->trans($tmp).'</div>';
449 } elseif ($tmp == 'NotConfigured') {
450 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
451 } else {
452 print $tmp;
453 }
454 print '</td>'."\n";
455
456 print '<td class="center">';
457 $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
458 if (getDolGlobalString($constforvar) == $file) {
459 print img_picto($langs->trans("Activated"), 'switch_on');
460 } else {
461 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
462 print img_picto($langs->trans("Disabled"), 'switch_off');
463 print '</a>';
464 }
465 print '</td>';
466
467 $mytmpinstance = new $myTmpObjectKey($db);
468 $mytmpinstance->initAsSpecimen();
469
470 // Info
471 $htmltooltip = '';
472 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
473
474 $nextval = $module->getNextValue($mytmpinstance);
475 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
476 $htmltooltip .= ''.$langs->trans("NextValue").': ';
477 if ($nextval) {
478 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
479 $nextval = $langs->trans($nextval);
480 }
481 $htmltooltip .= $nextval.'<br>';
482 } else {
483 $htmltooltip .= $langs->trans($module->error).'<br>';
484 }
485 }
486
487 print '<td class="center">';
488 print $form->textwithpicto('', $htmltooltip, 1, 0);
489 print '</td>';
490
491 print "</tr>\n";
492 }
493 }
494 }
495 closedir($handle);
496 }
497 }
498 }
499 print "</table><br>\n";
500 }
501
502 if ($myTmpObjectArray['includedocgeneration']) {
503
504 $setupnotempty++;
505 $type = strtolower($myTmpObjectKey);
506
507 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
508
509 // Load array def with activated templates
510 $def = array();
511 $sql = "SELECT nom";
512 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
513 $sql .= " WHERE type = '".$db->escape($type)."'";
514 $sql .= " AND entity = ".$conf->entity;
515 $resql = $db->query($sql);
516 if ($resql) {
517 $i = 0;
518 $num_rows = $db->num_rows($resql);
519 while ($i < $num_rows) {
520 $array = $db->fetch_array($resql);
521 array_push($def, $array[0]);
522 $i++;
523 }
524 } else {
525 dol_print_error($db);
526 }
527
528 print "<table class=\"noborder\" width=\"100%\">\n";
529 print "<tr class=\"liste_titre\">\n";
530 print '<td>'.$langs->trans("Name").'</td>';
531 print '<td>'.$langs->trans("Description").'</td>';
532 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
533 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
534 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
535 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
536 print "</tr>\n";
537
538 clearstatcache();
539
540 foreach ($dirmodels as $reldir) {
541 foreach (array('', '/doc') as $valdir) {
542 $realpath = $reldir."core/modules/".$moduledir.$valdir;
543 $dir = dol_buildpath($realpath);
544
545 if (is_dir($dir)) {
546 $handle = opendir($dir);
547 if (is_resource($handle)) {
548 while (($file = readdir($handle)) !== false) {
549 $filelist[] = $file;
550 }
551 closedir($handle);
552 arsort($filelist);
553
554 foreach ($filelist as $file) {
555 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
556 if (file_exists($dir.'/'.$file)) {
557 $name = substr($file, 4, dol_strlen($file) - 16);
558 $classname = substr($file, 0, dol_strlen($file) - 12);
559
560 require_once $dir.'/'.$file;
561 $module = new $classname($db);
562
563 $modulequalified = 1;
564 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
565 $modulequalified = 0;
566 }
567 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
568 $modulequalified = 0;
569 }
570
571 if ($modulequalified) {
572 print '<tr class="oddeven"><td width="100">';
573 print (empty($module->name) ? $name : $module->name);
574 print "</td><td>\n";
575 if (method_exists($module, 'info')) {
576 print $module->info($langs);
577 } else {
578 print $module->description;
579 }
580 print '</td>';
581
582 // Active
583 if (in_array($name, $def)) {
584 print '<td class="center">'."\n";
585 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
586 print img_picto($langs->trans("Enabled"), 'switch_on');
587 print '</a>';
588 print '</td>';
589 } else {
590 print '<td class="center">'."\n";
591 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.$name.'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
592 print "</td>";
593 }
594
595 // Default
596 print '<td class="center">';
597 $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
598 if (getDolGlobalString($constforvar) == $name) {
599 //print img_picto($langs->trans("Default"), 'on');
600 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
601 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>';
602 } else {
603 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>';
604 }
605 print '</td>';
606
607 // Info
608 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
609 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
610 if ($module->type == 'pdf') {
611 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
612 }
613 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
614
615 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
616 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
617 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
618
619 print '<td class="center">';
620 print $form->textwithpicto('', $htmltooltip, 1, 0);
621 print '</td>';
622
623 // Preview
624 print '<td class="center">';
625 if ($module->type == 'pdf') {
626 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
627 } else {
628 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
629 }
630 print '</td>';
631
632 print "</tr>\n";
633 }
634 }
635 }
636 }
637 }
638 }
639 }
640 }
641
642 print '</table>';
643 }
644}
645*/
646
647// Page end
648print dol_get_fiche_end();
649
650llxFooter();
651$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()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
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.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Classe permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
eventorganizationAdminPrepareHead()
Prepare admin pages header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.