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