dolibarr 21.0.0-beta
footer.tpl.php
1<!-- file footer.tpl.php -->
2<?php
3/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 */
5// Protection to avoid direct call of template
6if (empty($context) || !is_object($context)) {
7 print "Error, template page can't be called as URL";
8 exit(1);
9}
10'@phan-var-force Context $context';
11
12global $langs;
13
14// load messages
15$html = '';
16$htmlSuccess = '';
17$htmlWarning = '';
18$htmlError = '';
19$jsOut = '';
20$jsSuccess = '';
21$jsWarning = '';
22$jsError = '';
23//$useJNotify = false;
24//if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) {
25//$useJNotify = true;
26//}
27$useJNotify = true;
28$context->loadEventMessages();
29// alert success
30if (!empty($context->eventMessages['mesgs'])) {
31 $htmlSuccess = $useJNotify ? '' : '<div class="success" role="alert">';
32 $msgNum = 0;
33 foreach ($context->eventMessages['mesgs'] as $mesg) {
34 if ($msgNum > 0) {
35 $htmlSuccess .= '<br>';
36 }
37 $htmlSuccess .= $langs->trans($mesg);
38 $msgNum++;
39 }
40 $htmlSuccess .= $useJNotify ? '' : '</div>';
41 if ($useJNotify) {
42 $jsSuccess = '
43 jQuery.jnotify("' . dol_escape_js($htmlSuccess) . '",
44 "success",
45 3000
46 );';
47 }
48}
49// alert warning
50if (!empty($context->eventMessages['warnings'])) {
51 $htmlWarning = $useJNotify ? '' : '<div class="warning" role="alert">';
52 $msgNum = 0;
53 foreach ($context->eventMessages['warnings'] as $mesg) {
54 if ($msgNum > 0) {
55 $htmlWarning .= '<br>';
56 }
57 $htmlWarning .= $langs->trans($mesg);
58 $msgNum++;
59 }
60 $htmlWarning .= $useJNotify ? '' : '</div>';
61 if ($useJNotify) {
62 $jsWarning .= 'jQuery.jnotify("' . dol_escape_js($htmlWarning) . '", "warning", true);';
63 }
64}
65// alert error
66if (!empty($context->eventMessages['errors'])) {
67 $htmlError = $useJNotify ? '' : '<div class="error" role="alert">';
68 $msgNum = 0;
69 foreach ($context->eventMessages['errors'] as $mesg) {
70 if ($msgNum > 0) {
71 $htmlError .= '<br>';
72 }
73 $htmlError .= $langs->trans($mesg);
74 $msgNum++;
75 }
76 $htmlError .= $useJNotify ? '' : '</div>';
77 if ($useJNotify) {
78 $jsError .= 'jQuery.jnotify("' . dol_escape_js($htmlError) . '", "error", true );';
79 }
80}
81$html .= $htmlError . $htmlWarning . $htmlSuccess;
82if ($html) {
83 $jsOut = $jsSuccess . $jsWarning . $jsError;
84 if ($jsOut == '') {
85 print $html;
86 }
87}
88$context->clearEventMessages();
89
90if ($context->getErrors()) {
91 include __DIR__ . '/errors.tpl.php';
92}
93if ($jsOut) {
94 $js = '<script nonce="' . getNonce() . '">';
95 $js .= 'jQuery(document).ready(function() {';
96 $js .= $jsOut;
97 $js .= '});';
98 $js .= '</script>';
99 print $js;
100}
101
102print '<script src="'.$context->getControllerUrl().'/js/theme.js"></script>';
103?>
104
105</body>
106</html>
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
getNonce()
Return a random string to be used as a nonce value for js.
$context
@method int call_trigger(string $triggerName, User $user)
Definition logout.php:42