dolibarr  18.0.0
webhook.php
1 <?php
2 /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
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 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
27 require_once DOL_DOCUMENT_ROOT.'/webhook/lib/webhook.lib.php';
28 
29 // Translations
30 $langs->loadLangs(array("admin", "webhook"));
31 
32 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
33 $hookmanager->initHooks(array('webhooksetup', 'globalsetup'));
34 
35 // Access control
36 if (!$user->admin) {
38 }
39 
40 // Parameters
41 $action = GETPOST('action', 'aZ09');
42 $backtopage = GETPOST('backtopage', 'alpha');
43 $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
44 
45 $value = GETPOST('value', 'alpha');
46 $label = GETPOST('label', 'alpha');
47 $scandir = GETPOST('scan_dir', 'alpha');
48 $type = 'myobject';
49 
50 
51 $error = 0;
52 $setupnotempty = 0;
53 
54 // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
55 $useFormSetup = 1;
56 
57 if (!class_exists('FormSetup')) {
58  // For retrocompatibility Dolibarr < 16.0
59  if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) {
60  require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php';
61  } else {
62  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
63  }
64 }
65 
66 $formSetup = new FormSetup($db);
67 
68 
69 $setupnotempty = count($formSetup->items);
70 
71 
72 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
73 
74 
75 /*
76  * Actions
77  */
78 
79 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
80 
81 if ($action == 'updateMask') {
82  $maskconst = GETPOST('maskconst', 'aZ09');
83  $maskvalue = GETPOST('maskvalue', 'alpha');
84 
85  if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
86  $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
87  if (!($res > 0)) {
88  $error++;
89  }
90  }
91 
92  if (!$error) {
93  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
94  } else {
95  setEventMessages($langs->trans("Error"), null, 'errors');
96  }
97 } elseif ($action == 'specimen') {
98  $modele = GETPOST('module', 'alpha');
99  $tmpobjectkey = GETPOST('object');
100 
101  $tmpobject = new $tmpobjectkey($db);
102  $tmpobject->initAsSpecimen();
103 
104  // Search template files
105  $file = ''; $classname = ''; $filefound = 0;
106  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
107  foreach ($dirmodels as $reldir) {
108  $file = dol_buildpath($reldir."core/modules/webhook/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
109  if (file_exists($file)) {
110  $filefound = 1;
111  $classname = "pdf_".$modele."_".strtolower($tmpobjectkey);
112  break;
113  }
114  }
115 
116  if ($filefound) {
117  require_once $file;
118 
119  $module = new $classname($db);
120 
121  if ($module->write_file($tmpobject, $langs) > 0) {
122  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=webhook-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
123  return;
124  } else {
125  setEventMessages($module->error, null, 'errors');
126  dol_syslog($module->error, LOG_ERR);
127  }
128  } else {
129  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
130  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
131  }
132 } elseif ($action == 'setmod') {
133  // TODO Check if numbering module chosen can be activated by calling method canBeActivated
134  $tmpobjectkey = GETPOST('object');
135  if (!empty($tmpobjectkey)) {
136  $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey)."_ADDON";
137  dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
138  }
139 } elseif ($action == 'set') {
140  // Activate a model
141  $ret = addDocumentModel($value, $type, $label, $scandir);
142 } elseif ($action == 'del') {
143  $ret = delDocumentModel($value, $type);
144  if ($ret > 0) {
145  $tmpobjectkey = GETPOST('object');
146  if (!empty($tmpobjectkey)) {
147  $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
148  if ($conf->global->$constforval == "$value") {
149  dolibarr_del_const($db, $constforval, $conf->entity);
150  }
151  }
152  }
153 } elseif ($action == 'setdoc') {
154  // Set or unset default model
155  $tmpobjectkey = GETPOST('object');
156  if (!empty($tmpobjectkey)) {
157  $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
158  if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
159  // The constant that was read before the new set
160  // We therefore requires a variable to have a coherent view
161  $conf->global->$constforval = $value;
162  }
163 
164  // We disable/enable the document template (into llx_document_model table)
165  $ret = delDocumentModel($value, $type);
166  if ($ret > 0) {
167  $ret = addDocumentModel($value, $type, $label, $scandir);
168  }
169  }
170 } elseif ($action == 'unsetdoc') {
171  $tmpobjectkey = GETPOST('object');
172  if (!empty($tmpobjectkey)) {
173  $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
174  dolibarr_del_const($db, $constforval, $conf->entity);
175  }
176 }
177 
178 
179 
180 /*
181  * View
182  */
183 
184 $form = new Form($db);
185 
186 $help_url = '';
187 $page_name = "WebhookSetup";
188 
189 llxHeader('', $langs->trans($page_name), $help_url);
190 
191 // Subheader
192 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
193 
194 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
195 
196 // Configuration header
197 $head = webhookAdminPrepareHead();
198 print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "webhook");
199 
200 // Setup page goes here
201 echo '<span class="opacitymedium">'.$langs->trans("WebhookSetupPage").'</span><br><br>';
202 
203 
204 if ($action == 'edit') {
205  if ($useFormSetup && (float) DOL_VERSION >= 15) {
206  print $formSetup->generateOutput(true);
207  } else {
208  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
209  print '<input type="hidden" name="token" value="'.newToken().'">';
210  print '<input type="hidden" name="action" value="update">';
211 
212  print '<table class="noborder centpercent">';
213  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
214 
215  foreach ($arrayofparameters as $constname => $val) {
216  if ($val['enabled']==1) {
217  $setupnotempty++;
218  print '<tr class="oddeven"><td>';
219  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
220  print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
221  print '</td><td>';
222 
223  if ($val['type'] == 'textarea') {
224  print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
225  print getDolGlobalString($constname);
226  print "</textarea>\n";
227  } elseif ($val['type']== 'html') {
228  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
229  $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
230  $doleditor->Create();
231  } elseif ($val['type'] == 'yesno') {
232  print $form->selectyesno($constname, getDolGlobalString($constname), 1);
233  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
234  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
235  $formmail = new FormMail($db);
236 
237  $tmp = explode(':', $val['type']);
238  $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
239  //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
240  $arrayofmessagename = array();
241  if (is_array($formmail->lines_model)) {
242  foreach ($formmail->lines_model as $modelmail) {
243  //var_dump($modelmail);
244  $moreonlabel = '';
245  if (!empty($arrayofmessagename[$modelmail->label])) {
246  $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
247  }
248  // The 'label' is the key that is unique if we exclude the language
249  $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
250  }
251  }
252  print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
253  } elseif (preg_match('/category:/', $val['type'])) {
254  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
255  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
256  $formother = new FormOther($db);
257 
258  $tmp = explode(':', $val['type']);
259  print img_picto('', 'category', 'class="pictofixedwidth"');
260  print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
261  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
262  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
263  $formcompany = new FormCompany($db);
264  print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
265  } elseif ($val['type'] == 'securekey') {
266  print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
267  if (!empty($conf->use_javascript_ajax)) {
268  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
269  }
270 
271  // Add button to autosuggest a key
272  include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
273  print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
274  } elseif ($val['type'] == 'product') {
275  if (isModEnabled("product") || isModEnabled("service")) {
276  $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
277  $form->select_produits($selected, $constname, '', 0);
278  }
279  } else {
280  print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
281  }
282  print '</td></tr>';
283  }
284  }
285  print '</table>';
286 
287  print '<br><div class="center">';
288  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
289  print '</div>';
290 
291  print '</form>';
292  }
293 
294  print '<br>';
295 } else {
296  if ($useFormSetup && (float) DOL_VERSION >= 15) {
297  if (!empty($formSetup->items)) {
298  print $formSetup->generateOutput();
299  }
300  } else {
301  if (!empty($arrayofparameters)) {
302  print '<table class="noborder centpercent">';
303  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
304 
305  foreach ($arrayofparameters as $constname => $val) {
306  if ($val['enabled']==1) {
307  $setupnotempty++;
308  print '<tr class="oddeven"><td>';
309  $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
310  print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
311  print '</td><td>';
312 
313  if ($val['type'] == 'textarea') {
314  print dol_nl2br(getDolGlobalString($constname));
315  } elseif ($val['type']== 'html') {
316  print getDolGlobalString($constname);
317  } elseif ($val['type'] == 'yesno') {
318  print ajax_constantonoff($constname);
319  } elseif (preg_match('/emailtemplate:/', $val['type'])) {
320  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
321  $formmail = new FormMail($db);
322 
323  $tmp = explode(':', $val['type']);
324 
325  $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
326  if ($template<0) {
327  setEventMessages(null, $formmail->errors, 'errors');
328  }
329  print $langs->trans($template->label);
330  } elseif (preg_match('/category:/', $val['type'])) {
331  $c = new Categorie($db);
332  $result = $c->fetch(getDolGlobalString($constname));
333  if ($result < 0) {
334  setEventMessages(null, $c->errors, 'errors');
335  } elseif ($result > 0 ) {
336  $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
337  $toprint = array();
338  foreach ($ways as $way) {
339  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
340  }
341  print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
342  }
343  } elseif (preg_match('/thirdparty_type/', $val['type'])) {
344  if (getDolGlobalInt($constname)==2) {
345  print $langs->trans("Prospect");
346  } elseif (getDolGlobalInt($constname)==3) {
347  print $langs->trans("ProspectCustomer");
348  } elseif (getDolGlobalInt($constname)==1) {
349  print $langs->trans("Customer");
350  } elseif (getDolGlobalInt($constname)==0) {
351  print $langs->trans("NorProspectNorCustomer");
352  }
353  } elseif ($val['type'] == 'product') {
354  $product = new Product($db);
355  $resprod = $product->fetch(getDolGlobalInt($constname));
356  if ($resprod > 0) {
357  print $product->ref;
358  } elseif ($resprod < 0) {
359  setEventMessages(null, $object->errors, "errors");
360  }
361  } else {
362  print getDolGlobalString($constname);
363  }
364  print '</td></tr>';
365  }
366  }
367 
368  print '</table>';
369  }
370  }
371 
372  if ($setupnotempty) {
373  print '<div class="tabsAction">';
374  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
375  print '</div>';
376  } else {
377  //print '<br>'.$langs->trans("NothingToSetup");
378  }
379 }
380 
381 
382 $moduledir = 'webhook';
383 $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
384 
385 
386 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
387  if ($myTmpObjectKey == 'MyObject') {
388  continue;
389  }
390  if ($myTmpObjectArray['includerefgeneration']) {
391  /*
392  * Orders Numbering model
393  */
394  $setupnotempty++;
395 
396  print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
397 
398  print '<table class="noborder centpercent">';
399  print '<tr class="liste_titre">';
400  print '<td>'.$langs->trans("Name").'</td>';
401  print '<td>'.$langs->trans("Description").'</td>';
402  print '<td class="nowrap">'.$langs->trans("Example").'</td>';
403  print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
404  print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
405  print '</tr>'."\n";
406 
407  clearstatcache();
408 
409  foreach ($dirmodels as $reldir) {
410  $dir = dol_buildpath($reldir."core/modules/".$moduledir);
411 
412  if (is_dir($dir)) {
413  $handle = opendir($dir);
414  if (is_resource($handle)) {
415  while (($file = readdir($handle)) !== false) {
416  if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
417  $file = substr($file, 0, dol_strlen($file) - 4);
418 
419  require_once $dir.'/'.$file.'.php';
420 
421  $module = new $file($db);
422 
423  // Show modules according to features level
424  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
425  continue;
426  }
427  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
428  continue;
429  }
430 
431  if ($module->isEnabled()) {
432  dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
433 
434  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
435  print $module->info();
436  print '</td>';
437 
438  // Show example of numbering model
439  print '<td class="nowrap">';
440  $tmp = $module->getExample();
441  if (preg_match('/^Error/', $tmp)) {
442  $langs->load("errors");
443  print '<div class="error">'.$langs->trans($tmp).'</div>';
444  } elseif ($tmp == 'NotConfigured') {
445  print $langs->trans($tmp);
446  } else {
447  print $tmp;
448  }
449  print '</td>'."\n";
450 
451  print '<td class="center">';
452  $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON';
453  if ($conf->global->$constforvar == $file) {
454  print img_picto($langs->trans("Activated"), 'switch_on');
455  } else {
456  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
457  print img_picto($langs->trans("Disabled"), 'switch_off');
458  print '</a>';
459  }
460  print '</td>';
461 
462  $mytmpinstance = new $myTmpObjectKey($db);
463  $mytmpinstance->initAsSpecimen();
464 
465  // Info
466  $htmltooltip = '';
467  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
468 
469  $nextval = $module->getNextValue($mytmpinstance);
470  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
471  $htmltooltip .= ''.$langs->trans("NextValue").': ';
472  if ($nextval) {
473  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
474  $nextval = $langs->trans($nextval);
475  }
476  $htmltooltip .= $nextval.'<br>';
477  } else {
478  $htmltooltip .= $langs->trans($module->error).'<br>';
479  }
480  }
481 
482  print '<td class="center">';
483  print $form->textwithpicto('', $htmltooltip, 1, 0);
484  print '</td>';
485 
486  print "</tr>\n";
487  }
488  }
489  }
490  closedir($handle);
491  }
492  }
493  }
494  print "</table><br>\n";
495  }
496 
497  if ($myTmpObjectArray['includedocgeneration']) {
498  /*
499  * Document templates generators
500  */
501  $setupnotempty++;
502  $type = strtolower($myTmpObjectKey);
503 
504  print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
505 
506  // Load array def with activated templates
507  $def = array();
508  $sql = "SELECT nom";
509  $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
510  $sql .= " WHERE type = '".$db->escape($type)."'";
511  $sql .= " AND entity = ".$conf->entity;
512  $resql = $db->query($sql);
513  if ($resql) {
514  $i = 0;
515  $num_rows = $db->num_rows($resql);
516  while ($i < $num_rows) {
517  $array = $db->fetch_array($resql);
518  array_push($def, $array[0]);
519  $i++;
520  }
521  } else {
522  dol_print_error($db);
523  }
524 
525  print "<table class=\"noborder\" width=\"100%\">\n";
526  print "<tr class=\"liste_titre\">\n";
527  print '<td>'.$langs->trans("Name").'</td>';
528  print '<td>'.$langs->trans("Description").'</td>';
529  print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
530  print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
531  print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
532  print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
533  print "</tr>\n";
534 
535  clearstatcache();
536 
537  foreach ($dirmodels as $reldir) {
538  foreach (array('', '/doc') as $valdir) {
539  $realpath = $reldir."core/modules/".$moduledir.$valdir;
540  $dir = dol_buildpath($realpath);
541 
542  if (is_dir($dir)) {
543  $handle = opendir($dir);
544  if (is_resource($handle)) {
545  while (($file = readdir($handle)) !== false) {
546  $filelist[] = $file;
547  }
548  closedir($handle);
549  arsort($filelist);
550 
551  foreach ($filelist as $file) {
552  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
553  if (file_exists($dir.'/'.$file)) {
554  $name = substr($file, 4, dol_strlen($file) - 16);
555  $classname = substr($file, 0, dol_strlen($file) - 12);
556 
557  require_once $dir.'/'.$file;
558  $module = new $classname($db);
559 
560  $modulequalified = 1;
561  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
562  $modulequalified = 0;
563  }
564  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
565  $modulequalified = 0;
566  }
567 
568  if ($modulequalified) {
569  print '<tr class="oddeven"><td width="100">';
570  print (empty($module->name) ? $name : $module->name);
571  print "</td><td>\n";
572  if (method_exists($module, 'info')) {
573  print $module->info($langs);
574  } else {
575  print $module->description;
576  }
577  print '</td>';
578 
579  // Active
580  if (in_array($name, $def)) {
581  print '<td class="center">'."\n";
582  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
583  print img_picto($langs->trans("Enabled"), 'switch_on');
584  print '</a>';
585  print '</td>';
586  } else {
587  print '<td class="center">'."\n";
588  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>';
589  print "</td>";
590  }
591 
592  // Default
593  print '<td class="center">';
594  $constforvar = 'WEBHOOK_'.strtoupper($myTmpObjectKey).'_ADDON';
595  if ($conf->global->$constforvar == $name) {
596  //print img_picto($langs->trans("Default"), 'on');
597  // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
598  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).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
599  } else {
600  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>';
601  }
602  print '</td>';
603 
604  // Info
605  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
606  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
607  if ($module->type == 'pdf') {
608  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
609  }
610  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
611 
612  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
613  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
614  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
615 
616  print '<td class="center">';
617  print $form->textwithpicto('', $htmltooltip, 1, 0);
618  print '</td>';
619 
620  // Preview
621  print '<td class="center">';
622  if ($module->type == 'pdf') {
623  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
624  } else {
625  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
626  }
627  print '</td>';
628 
629  print "</tr>\n";
630  }
631  }
632  }
633  }
634  }
635  }
636  }
637  }
638 
639  print '</table>';
640  }
641 }
642 
643 if (empty($setupnotempty)) {
644  print '<br>'.$langs->trans("NothingToSetup");
645 }
646 
647 // Page end
648 print dol_get_fiche_end();
649 
650 llxFooter();
651 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6824
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
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:609
dol_nl2br
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
Definition: functions.lib.php:7339
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5107
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1129
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1158
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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:4135
llxHeader
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
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
Definition: ajax.lib.php:630
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1949
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
FormSetup
This class help you create setup render.
Definition: html.formsetup.class.php:22
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3997
dolJSToSetRandomPassword
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
Definition: security2.lib.php:573
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
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.
Definition: functions.lib.php:1979
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
webhookAdminPrepareHead
webhookAdminPrepareHead()
Prepare admin pages header.
Definition: webhook.lib.php:29
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:638
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1918
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:53
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4473
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1164
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:40
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30