dolibarr  16.0.5
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
25 require '../main.inc.php';
26 
27 global $langs, $user;
28 
29 // Libraries
30 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php';
32 require_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
72 if (empty($user->admin)) {
74 }
75 
76 
77 
78 /*
79  * Actions
80  */
81 
82 if ($cancel) {
83  $action ='';
84 }
85 
86 if ((float) DOL_VERSION >= 6) {
87  include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
88 }
89 
90 if ($action == 'updateMask') {
91  $maskconstorder = GETPOST('maskconstorder', 'alpha');
92  $maskorder = GETPOST('maskorder', 'alpha');
93 
94  if ($maskconstorder) {
95  $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
96  if (!($res > 0)) {
97  $error++;
98  }
99  }
100 
101  if (!$error) {
102  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
103  } else {
104  setEventMessages($langs->trans("Error"), null, 'errors');
105  }
106 } elseif ($action == 'specimen') {
107  $modele = GETPOST('module', 'alpha');
108  $tmpobjectkey = GETPOST('object');
109 
110  $tmpobject = new $tmpobjectkey($db);
111  $tmpobject->initAsSpecimen();
112 
113  // Search template files
114  $file = ''; $classname = ''; $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 ($conf->global->$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 
197 llxHeader('', $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 
202 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
203 
204 // Configuration header
206 print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'eventorganization');
207 
208 // Setup page goes here
209 echo '<span class="opacitymedium">'.$langs->trans("EventOrganizationSetupPage").'</span><br><br>';
210 
211 
212 if ($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, $conf->fckeditor->enabled, 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  if (!empty($conf->use_javascript_ajax)) {
277  print "\n".'<script type="text/javascript">';
278  print '$(document).ready(function () {
279  $("#generate_token'.$constname.'").click(function() {
280  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
281  action: \'getrandompassword\',
282  generic: true
283  },
284  function(token) {
285  $("#'.$constname.'").val(token);
286  });
287  });
288  });';
289  print '</script>';
290  }
291  } elseif ($val['type'] == 'product') {
292  if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
293  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
294  $form->select_produits($selected, $constname, '', 0);
295  }
296  } else {
297  print '<input name="' . $constname . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($constname) . '">';
298  }
299  print '</td></tr>';
300  }
301  }
302  print '</table>';
303 
304  print $form->buttonsSaveCancel();
305 
306  print '</form>';
307  print '<br>';
308 } else {
309  if (!empty($arrayofparameters)) {
310  print '<table class="noborder centpercent">';
311  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
312 
313  foreach ($arrayofparameters as $constname => $val) {
314  if ($val['enabled']==1) {
315  $setupnotempty++;
316  print '<tr class="oddeven">';
317  print '<td><!-- '.$constname.' -->';
318  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
319  $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
320  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
321  print '</td><td>';
322 
323  if ($val['type'] == 'textarea') {
324  print dol_nl2br(getDolGlobalString($constname));
325  } elseif ($val['type']== 'html') {
326  print getDolGlobalString($constname);
327  } elseif ($val['type'] == 'yesno') {
328  print ajax_constantonoff($constname);
329  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
330  if (getDolGlobalString($constname)) {
331  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
332  $formmail = new FormMail($db);
333 
334  $tmp = explode(':', $val['type']);
335  $labelemailtemplate = getDolGlobalString($constname);
336  if ($labelemailtemplate && $labelemailtemplate != '-1') {
337  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
338  if (is_numeric($template) && $template < 0) {
339  setEventMessages($formmail->error, $formmail->errors, 'errors');
340  } else {
341  if ($template->label != 'default') {
342  print $langs->trans($template->label);
343  }
344  }
345  }
346  }
347  } elseif (preg_match('/category:/', $val['type'])) {
348  if (getDolGlobalString($constname)) {
349  $c = new Categorie($db);
350  $result = $c->fetch(getDolGlobalString($constname));
351  if ($result < 0) {
352  setEventMessages(null, $c->errors, 'errors');
353  }
354  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
355  $toprint = array();
356  foreach ($ways as $way) {
357  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
358  }
359  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
360  }
361  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
362  if (getDolGlobalString($constname)==2) {
363  print $langs->trans("Prospect");
364  } elseif (getDolGlobalString($constname)==3) {
365  print $langs->trans("ProspectCustomer");
366  } elseif (getDolGlobalString($constname)==1) {
367  print $langs->trans("Customer");
368  } elseif (getDolGlobalString($constname)==0) {
369  print $langs->trans("NorProspectNorCustomer");
370  }
371  } elseif ($val['type'] == 'product') {
372  $product = new Product($db);
373  $idproduct = getDolGlobalString($constname);
374  if ($idproduct > 0) {
375  $resprod = $product->fetch($idproduct);
376  if ($resprod > 0) {
377  print $product->getNomUrl(1);
378  } elseif ($resprod < 0) {
379  setEventMessages($product->error, $product->errors, "errors");
380  }
381  }
382  } else {
383  print getDolGlobalString($constname);
384  }
385  print '</td>';
386 
387  print '</tr>';
388  }
389  }
390 
391  print '</table>';
392 
393  print '<div class="tabsAction">';
394  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
395  print '</div>';
396  } else {
397  print '<br>'.$langs->trans("NothingToSetup");
398  }
399 }
400 
401 
402 /*$moduledir = 'eventorganization';
403 $myTmpObjects = array();
404 $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
405 
406 
407 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
408  if ($myTmpObjectKey == 'MyObject') {
409  continue;
410  }
411  if ($myTmpObjectArray['includerefgeneration']) {
412  $setupnotempty++;
413 
414  print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
415 
416  print '<table class="noborder centpercent">';
417  print '<tr class="liste_titre">';
418  print '<td>'.$langs->trans("Name").'</td>';
419  print '<td>'.$langs->trans("Description").'</td>';
420  print '<td class="nowrap">'.$langs->trans("Example").'</td>';
421  print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
422  print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
423  print '</tr>'."\n";
424 
425  clearstatcache();
426 
427  foreach ($dirmodels as $reldir) {
428  $dir = dol_buildpath($reldir."core/modules/".$moduledir);
429 
430  if (is_dir($dir)) {
431  $handle = opendir($dir);
432  if (is_resource($handle)) {
433  while (($file = readdir($handle)) !== false) {
434  if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
435  $file = substr($file, 0, dol_strlen($file) - 4);
436 
437  require_once $dir.'/'.$file.'.php';
438 
439  $module = new $file($db);
440 
441  // Show modules according to features level
442  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
443  continue;
444  }
445  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
446  continue;
447  }
448 
449  if ($module->isEnabled()) {
450  dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
451 
452  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
453  print $module->info();
454  print '</td>';
455 
456  // Show example of numbering model
457  print '<td class="nowrap">';
458  $tmp = $module->getExample();
459  if (preg_match('/^Error/', $tmp)) {
460  $langs->load("errors");
461  print '<div class="error">'.$langs->trans($tmp).'</div>';
462  } elseif ($tmp == 'NotConfigured') {
463  print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
464  } else {
465  print $tmp;
466  }
467  print '</td>'."\n";
468 
469  print '<td class="center">';
470  $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
471  if (getDolGlobalString($constforvar) == $file) {
472  print img_picto($langs->trans("Activated"), 'switch_on');
473  } else {
474  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
475  print img_picto($langs->trans("Disabled"), 'switch_off');
476  print '</a>';
477  }
478  print '</td>';
479 
480  $mytmpinstance = new $myTmpObjectKey($db);
481  $mytmpinstance->initAsSpecimen();
482 
483  // Info
484  $htmltooltip = '';
485  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
486 
487  $nextval = $module->getNextValue($mytmpinstance);
488  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
489  $htmltooltip .= ''.$langs->trans("NextValue").': ';
490  if ($nextval) {
491  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
492  $nextval = $langs->trans($nextval);
493  }
494  $htmltooltip .= $nextval.'<br>';
495  } else {
496  $htmltooltip .= $langs->trans($module->error).'<br>';
497  }
498  }
499 
500  print '<td class="center">';
501  print $form->textwithpicto('', $htmltooltip, 1, 0);
502  print '</td>';
503 
504  print "</tr>\n";
505  }
506  }
507  }
508  closedir($handle);
509  }
510  }
511  }
512  print "</table><br>\n";
513  }
514 
515  if ($myTmpObjectArray['includedocgeneration']) {
516 
517  $setupnotempty++;
518  $type = strtolower($myTmpObjectKey);
519 
520  print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
521 
522  // Load array def with activated templates
523  $def = array();
524  $sql = "SELECT nom";
525  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
526  $sql .= " WHERE type = '".$db->escape($type)."'";
527  $sql .= " AND entity = ".$conf->entity;
528  $resql = $db->query($sql);
529  if ($resql) {
530  $i = 0;
531  $num_rows = $db->num_rows($resql);
532  while ($i < $num_rows) {
533  $array = $db->fetch_array($resql);
534  array_push($def, $array[0]);
535  $i++;
536  }
537  } else {
538  dol_print_error($db);
539  }
540 
541  print "<table class=\"noborder\" width=\"100%\">\n";
542  print "<tr class=\"liste_titre\">\n";
543  print '<td>'.$langs->trans("Name").'</td>';
544  print '<td>'.$langs->trans("Description").'</td>';
545  print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
546  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
547  print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
548  print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
549  print "</tr>\n";
550 
551  clearstatcache();
552 
553  foreach ($dirmodels as $reldir) {
554  foreach (array('', '/doc') as $valdir) {
555  $realpath = $reldir."core/modules/".$moduledir.$valdir;
556  $dir = dol_buildpath($realpath);
557 
558  if (is_dir($dir)) {
559  $handle = opendir($dir);
560  if (is_resource($handle)) {
561  while (($file = readdir($handle)) !== false) {
562  $filelist[] = $file;
563  }
564  closedir($handle);
565  arsort($filelist);
566 
567  foreach ($filelist as $file) {
568  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
569  if (file_exists($dir.'/'.$file)) {
570  $name = substr($file, 4, dol_strlen($file) - 16);
571  $classname = substr($file, 0, dol_strlen($file) - 12);
572 
573  require_once $dir.'/'.$file;
574  $module = new $classname($db);
575 
576  $modulequalified = 1;
577  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
578  $modulequalified = 0;
579  }
580  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
581  $modulequalified = 0;
582  }
583 
584  if ($modulequalified) {
585  print '<tr class="oddeven"><td width="100">';
586  print (empty($module->name) ? $name : $module->name);
587  print "</td><td>\n";
588  if (method_exists($module, 'info')) {
589  print $module->info($langs);
590  } else {
591  print $module->description;
592  }
593  print '</td>';
594 
595  // Active
596  if (in_array($name, $def)) {
597  print '<td class="center">'."\n";
598  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">';
599  print img_picto($langs->trans("Enabled"), 'switch_on');
600  print '</a>';
601  print '</td>';
602  } else {
603  print '<td class="center">'."\n";
604  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>';
605  print "</td>";
606  }
607 
608  // Default
609  print '<td class="center">';
610  $constforvar = 'EVENTORGANIZATION_'.strtoupper($myTmpObjectKey).'_ADDON';
611  if (getDolGlobalString($constforvar) == $name) {
612  //print img_picto($langs->trans("Default"), 'on');
613  // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
614  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>';
615  } else {
616  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>';
617  }
618  print '</td>';
619 
620  // Info
621  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
622  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
623  if ($module->type == 'pdf') {
624  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
625  }
626  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
627 
628  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
629  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
630  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
631 
632  print '<td class="center">';
633  print $form->textwithpicto('', $htmltooltip, 1, 0);
634  print '</td>';
635 
636  // Preview
637  print '<td class="center">';
638  if ($module->type == 'pdf') {
639  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
640  } else {
641  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
642  }
643  print '</td>';
644 
645  print "</tr>\n";
646  }
647  }
648  }
649  }
650  }
651  }
652  }
653  }
654 
655  print '</table>';
656  }
657 }
658 */
659 
660 // Page end
661 print dol_get_fiche_end();
662 
663 llxFooter();
664 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_nl2br
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
Definition: functions.lib.php:6963
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Categorie
Class to manage categories.
Definition: categorie.class.php:47
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1894
eventorganizationAdminPrepareHead
eventorganizationAdminPrepareHead()
Prepare admin pages header.
Definition: eventorganization.lib.php:29
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
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).
Definition: admin.lib.php:627
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1863
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30