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