dolibarr 19.0.4
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 = '';
113 $classname = '';
114 $filefound = 0;
115 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
116 foreach ($dirmodels as $reldir) {
117 $file = dol_buildpath($reldir."core/modules/eventorganization/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
118 if (file_exists($file)) {
119 $filefound = 1;
120 $classname = "pdf_".$modele;
121 break;
122 }
123 }
124
125 if ($filefound) {
126 require_once $file;
127
128 $module = new $classname($db);
129
130 if ($module->write_file($tmpobject, $langs) > 0) {
131 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
132 return;
133 } else {
134 setEventMessages($module->error, null, 'errors');
135 dol_syslog($module->error, LOG_ERR);
136 }
137 } else {
138 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
139 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
140 }
141} elseif ($action == 'setmod') {
142 // TODO Check if numbering module chosen can be activated by calling method canBeActivated
143 $tmpobjectkey = GETPOST('object');
144 if (!empty($tmpobjectkey)) {
145 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON";
146 dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
147 }
148} elseif ($action == 'set') {
149 // Activate a model
150 $ret = addDocumentModel($value, $type, $label, $scandir);
151} elseif ($action == 'del') {
152 $ret = delDocumentModel($value, $type);
153 if ($ret > 0) {
154 $tmpobjectkey = GETPOST('object');
155 if (!empty($tmpobjectkey)) {
156 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
157 if (getDolGlobalString($constforval) == "$value") {
158 dolibarr_del_const($db, $constforval, $conf->entity);
159 }
160 }
161 }
162}/* elseif ($action == 'setdoc') {
163 // Set or unset default model
164 $tmpobjectkey = GETPOST('object');
165 if (!empty($tmpobjectkey)) {
166 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
167 if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
168 // The constant that was read before the new set
169 // We therefore requires a variable to have a coherent view
170 $conf->global->$constforval = $value;
171 }
172
173 // We disable/enable the document template (into llx_document_model table)
174 $ret = delDocumentModel($value, $type);
175 if ($ret > 0) {
176 $ret = addDocumentModel($value, $type, $label, $scandir);
177 }
178 }
179} elseif ($action == 'unsetdoc') {
180 $tmpobjectkey = GETPOST('object');
181 if (!empty($tmpobjectkey)) {
182 $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
183 dolibarr_del_const($db, $constforval, $conf->entity);
184 }
185}*/
186
187
188
189/*
190 * View
191 */
192
193$form = new Form($db);
194
195$page_name = "EventOrganizationSetup";
196
197llxHeader('', $langs->trans($page_name));
198
199// Subheader
200$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
201
202print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
203
204// Configuration header
206print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
207
208// Setup page goes here
209echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
210
211
212if ($action == 'edit') {
213 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
214 print '<input type="hidden" name="token" value="'.newToken().'">';
215 print '<input type="hidden" name="action" value="update">';
216
217 print '<table class="noborder centpercent">';
218 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
219
220 foreach ($arrayofparameters as $constname => $val) {
221 if ($val['enabled']==1) {
222 $setupnotempty++;
223 print '<tr class="oddeven"><td><!-- '.$constname.' -->';
224 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
225 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
226 print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
227 print '</td><td>';
228
229 if ($val['type'] == 'textarea') {
230 print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
231 print getDolGlobalString($constname);
232 print "</textarea>\n";
233 } elseif ($val['type']== 'html') {
234 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
235 $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
236 $doleditor->Create();
237 } elseif ($val['type'] == 'yesno') {
238 print $form->selectyesno($constname, getDolGlobalString($constname), 1);
239 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
240 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
241 $formmail = new FormMail($db);
242
243 $tmp = explode(':', $val['type']);
244 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
245 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
246 $arrayofmessagename = array();
247 if (is_array($formmail->lines_model)) {
248 foreach ($formmail->lines_model as $modelmail) {
249 //var_dump($modelmail);
250 $moreonlabel = '';
251 if (!empty($arrayofmessagename[$modelmail->label])) {
252 $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
253 }
254 // The 'label' is the key that is unique if we exclude the language
255 $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\‍(|\‍)/', '', $modelmail->label)) . $moreonlabel;
256 }
257 }
258 print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
259 } elseif (preg_match('/category:/', $val['type'])) {
260 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
261 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
262 $formother = new FormOther($db);
263
264 $tmp = explode(':', $val['type']);
265 print img_picto('', 'category', 'class="pictofixedwidth"');
266 print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
267 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
268 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
269 $formcompany = new FormCompany($db);
270 print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
271 } elseif ($val['type'] == 'securekey') {
272 print '<input type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ? GETPOST($constname, 'alpha') : getDolGlobalString($constname)).'" size="40">';
273 if (!empty($conf->use_javascript_ajax)) {
274 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
275 }
276
277 // Add button to autosuggest a key
278 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
279 print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
280 } elseif ($val['type'] == 'product') {
281 if (isModEnabled("product") || isModEnabled("service")) {
282 $selected = getDolGlobalString($constname);
283 $form->select_produits($selected, $constname, '', 0);
284 }
285 } else {
286 print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
287 }
288 print '</td></tr>';
289 }
290 }
291 print '</table>';
292
293 print $form->buttonsSaveCancel();
294
295 print '</form>';
296 print '<br>';
297} else {
298 if (!empty($arrayofparameters)) {
299 print '<table class="noborder centpercent">';
300 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
301
302 foreach ($arrayofparameters as $constname => $val) {
303 if ($val['enabled']==1) {
304 $setupnotempty++;
305 print '<tr class="oddeven">';
306 print '<td><!-- '.$constname.' -->';
307 $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
308 $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
309 print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
310 print '</td><td>';
311
312 if ($val['type'] == 'textarea') {
313 print dol_nl2br(getDolGlobalString($constname));
314 } elseif ($val['type']== 'html') {
315 print getDolGlobalString($constname);
316 } elseif ($val['type'] == 'yesno') {
317 print ajax_constantonoff($constname);
318 } elseif (preg_match('/emailtemplate:/', $val['type'])) {
319 if (getDolGlobalString($constname)) {
320 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
321 $formmail = new FormMail($db);
322
323 $tmp = explode(':', $val['type']);
324 $labelemailtemplate = getDolGlobalString($constname);
325 if ($labelemailtemplate && $labelemailtemplate != '-1') {
326 $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
327 if (is_numeric($template) && $template < 0) {
328 setEventMessages($formmail->error, $formmail->errors, 'errors');
329 } else {
330 if ($template->label != 'default') {
331 print $langs->trans($template->label);
332 }
333 }
334 }
335 }
336 } elseif (preg_match('/category:/', $val['type'])) {
337 if (getDolGlobalString($constname)) {
338 $c = new Categorie($db);
339 $result = $c->fetch(getDolGlobalString($constname));
340 if ($result < 0) {
341 setEventMessages(null, $c->errors, 'errors');
342 }
343 $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
344 $toprint = array();
345 foreach ($ways as $way) {
346 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
347 }
348 print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
349 }
350 } elseif (preg_match('/thirdparty_type/', $val['type'])) {
351 if (getDolGlobalString($constname)==2) {
352 print $langs->trans("Prospect");
353 } elseif (getDolGlobalString($constname)==3) {
354 print $langs->trans("ProspectCustomer");
355 } elseif (getDolGlobalString($constname)==1) {
356 print $langs->trans("Customer");
357 } elseif (getDolGlobalString($constname)==0) {
358 print $langs->trans("NorProspectNorCustomer");
359 }
360 } elseif ($val['type'] == 'product') {
361 $product = new Product($db);
362 $idproduct = getDolGlobalString($constname);
363 if ($idproduct > 0) {
364 $resprod = $product->fetch($idproduct);
365 if ($resprod > 0) {
366 print $product->getNomUrl(1);
367 } elseif ($resprod < 0) {
368 setEventMessages($product->error, $product->errors, "errors");
369 }
370 }
371 } else {
372 print getDolGlobalString($constname);
373 }
374 print '</td>';
375
376 print '</tr>';
377 }
378 }
379
380 print '</table>';
381
382 print '<div class="tabsAction">';
383 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
384 print '</div>';
385 } else {
386 print '<br>'.$langs->trans("NothingToSetup");
387 }
388}
389
390
391/*$moduledir = 'eventorganization';
392$myTmpObjects = array();
393$myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
394
395
396foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
397 if ($myTmpObjectKey == 'MyObject') {
398 continue;
399 }
400 if ($myTmpObjectArray['includerefgeneration']) {
401 $setupnotempty++;
402
403 print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
404
405 print '<table class="noborder centpercent">';
406 print '<tr class="liste_titre">';
407 print '<td>'.$langs->trans("Name").'</td>';
408 print '<td>'.$langs->trans("Description").'</td>';
409 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
410 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
411 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
412 print '</tr>'."\n";
413
414 clearstatcache();
415
416 foreach ($dirmodels as $reldir) {
417 $dir = dol_buildpath($reldir."core/modules/".$moduledir);
418
419 if (is_dir($dir)) {
420 $handle = opendir($dir);
421 if (is_resource($handle)) {
422 while (($file = readdir($handle)) !== false) {
423 if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
424 $file = substr($file, 0, dol_strlen($file) - 4);
425
426 require_once $dir.'/'.$file.'.php';
427
428 $module = new $file($db);
429
430 // Show modules according to features level
431 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
432 continue;
433 }
434 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
435 continue;
436 }
437
438 if ($module->isEnabled()) {
439 dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
440
441 print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
442 print $module->info($langs);
443 print '</td>';
444
445 // Show example of numbering model
446 print '<td class="nowrap">';
447 $tmp = $module->getExample();
448 if (preg_match('/^Error/', $tmp)) {
449 $langs->load("errors");
450 print '<div class="error">'.$langs->trans($tmp).'</div>';
451 } elseif ($tmp == 'NotConfigured') {
452 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
453 } else {
454 print $tmp;
455 }
456 print '</td>'."\n";
457
458 print '<td class="center">';
459 $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
460 if (getDolGlobalString($constforvar) == $file) {
461 print img_picto($langs->trans("Activated"), 'switch_on');
462 } else {
463 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
464 print img_picto($langs->trans("Disabled"), 'switch_off');
465 print '</a>';
466 }
467 print '</td>';
468
469 $mytmpinstance = new $myTmpObjectKey($db);
470 $mytmpinstance->initAsSpecimen();
471
472 // Info
473 $htmltooltip = '';
474 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
475
476 $nextval = $module->getNextValue($mytmpinstance);
477 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
478 $htmltooltip .= ''.$langs->trans("NextValue").': ';
479 if ($nextval) {
480 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
481 $nextval = $langs->trans($nextval);
482 }
483 $htmltooltip .= $nextval.'<br>';
484 } else {
485 $htmltooltip .= $langs->trans($module->error).'<br>';
486 }
487 }
488
489 print '<td class="center">';
490 print $form->textwithpicto('', $htmltooltip, 1, 0);
491 print '</td>';
492
493 print "</tr>\n";
494 }
495 }
496 }
497 closedir($handle);
498 }
499 }
500 }
501 print "</table><br>\n";
502 }
503
504 if ($myTmpObjectArray['includedocgeneration']) {
505
506 $setupnotempty++;
507 $type = strtolower($myTmpObjectKey);
508
509 print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
510
511 // Load array def with activated templates
512 $def = array();
513 $sql = "SELECT nom";
514 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
515 $sql .= " WHERE type = '".$db->escape($type)."'";
516 $sql .= " AND entity = ".$conf->entity;
517 $resql = $db->query($sql);
518 if ($resql) {
519 $i = 0;
520 $num_rows = $db->num_rows($resql);
521 while ($i < $num_rows) {
522 $array = $db->fetch_array($resql);
523 array_push($def, $array[0]);
524 $i++;
525 }
526 } else {
527 dol_print_error($db);
528 }
529
530 print "<table class=\"noborder\" width=\"100%\">\n";
531 print "<tr class=\"liste_titre\">\n";
532 print '<td>'.$langs->trans("Name").'</td>';
533 print '<td>'.$langs->trans("Description").'</td>';
534 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
535 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
536 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
537 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
538 print "</tr>\n";
539
540 clearstatcache();
541
542 foreach ($dirmodels as $reldir) {
543 foreach (array('', '/doc') as $valdir) {
544 $realpath = $reldir."core/modules/".$moduledir.$valdir;
545 $dir = dol_buildpath($realpath);
546
547 if (is_dir($dir)) {
548 $handle = opendir($dir);
549 if (is_resource($handle)) {
550 while (($file = readdir($handle)) !== false) {
551 $filelist[] = $file;
552 }
553 closedir($handle);
554 arsort($filelist);
555
556 foreach ($filelist as $file) {
557 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
558 if (file_exists($dir.'/'.$file)) {
559 $name = substr($file, 4, dol_strlen($file) - 16);
560 $classname = substr($file, 0, dol_strlen($file) - 12);
561
562 require_once $dir.'/'.$file;
563 $module = new $classname($db);
564
565 $modulequalified = 1;
566 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
567 $modulequalified = 0;
568 }
569 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
570 $modulequalified = 0;
571 }
572
573 if ($modulequalified) {
574 print '<tr class="oddeven"><td width="100">';
575 print (empty($module->name) ? $name : $module->name);
576 print "</td><td>\n";
577 if (method_exists($module, 'info')) {
578 print $module->info($langs);
579 } else {
580 print $module->description;
581 }
582 print '</td>';
583
584 // Active
585 if (in_array($name, $def)) {
586 print '<td class="center">'."\n";
587 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
588 print img_picto($langs->trans("Enabled"), 'switch_on');
589 print '</a>';
590 print '</td>';
591 } else {
592 print '<td class="center">'."\n";
593 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>';
594 print "</td>";
595 }
596
597 // Default
598 print '<td class="center">';
599 $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
600 if (getDolGlobalString($constforvar) == $name) {
601 //print img_picto($langs->trans("Default"), 'on');
602 // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
603 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>';
604 } else {
605 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>';
606 }
607 print '</td>';
608
609 // Info
610 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
611 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
612 if ($module->type == 'pdf') {
613 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
614 }
615 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
616
617 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
618 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
619 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
620
621 print '<td class="center">';
622 print $form->textwithpicto('', $htmltooltip, 1, 0);
623 print '</td>';
624
625 // Preview
626 print '<td class="center">';
627 if ($module->type == 'pdf') {
628 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
629 } else {
630 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
631 }
632 print '</td>';
633
634 print "</tr>\n";
635 }
636 }
637 }
638 }
639 }
640 }
641 }
642 }
643
644 print '</table>';
645 }
646}
647*/
648
649// Page end
650print dol_get_fiche_end();
651
652llxFooter();
653$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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.