dolibarr 24.0.0-beta
event-message.php
1<?php
2/*
3 * Copyright (C) 2024 Anthony Damhet <a.damhet@progiseize.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20// Load Dolibarr environment
21require '../../../../main.inc.php';
22
30// Protection if external user
31if ($user->socid > 0) {
33}
34
35// Includes
36require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php';
37
38// Load documentation translations
39$langs->load('uxdocumentation');
40
41$action = GETPOST('action', 'alpha');
42
43if ($action == 'displayeventmessage') {
44 setEventMessages($langs->trans('DocSetEventMessageUnique'), null);
45} elseif ($action == 'displayeventmessages') {
46 $messageArray = [$langs->trans('DocSetEventMessage', '1'),
47 $langs->trans('DocSetEventMessage', '2'),
48 $langs->trans('DocSetEventMessage', '3')];
49 setEventMessages(null, $messageArray);
50} elseif ($action == 'displayeventmessageok') {
51 setEventMessages($langs->trans('DocSetEventMessageOK'), null);
52} elseif ($action == 'displayeventmessagewarning') {
53 setEventMessages($langs->trans('DocSetEventMessageWarning'), null, 'warnings');
54} elseif ($action == 'displayeventmessageerror') {
55 setEventMessages($langs->trans('DocSetEventMessageError'), null, 'errors');
56}
57
58//
59$documentation = new Documentation($db);
60$morejs = [
61 '/includes/ace/src/ace.js',
62 '/includes/ace/src/ext-statusbar.js',
63 '/includes/ace/src/ext-language_tools.js',
64];
65// Output html head + body - Param is Title
66$documentation->docHeader('SetEventMessages', $morejs);
67
68// Set view for menu and breadcrumb
69// Menu must be set in constructor of documentation class
70$documentation->view = array('Components','Event Message');
71
72// Output sidebar
73$documentation->showSidebar(); ?>
74
75<div class="doc-wrapper">
76
77 <?php $documentation->showBreadCrumb(); ?>
78
79 <div class="doc-content-wrapper">
80
81 <h1 class="documentation-title"><?php echo $langs->trans('DocSetEventMessageTitle'); ?></h1>
82 <p class="documentation-text"><?php echo $langs->trans('DocSetEventMessageMainDescription'); ?></p>
83
84 <!-- Summary -->
85 <?php $documentation->showSummary(); ?>
86
87 <!-- Basic usage -->
88 <div class="documentation-section" id="seteventmessagesection-basicusage">
89 <h2 class="documentation-title"><?php echo $langs->trans('DocBasicUsage'); ?></h2>
90 <p class="documentation-text"><?php echo $langs->trans('DocSetEventMessageDescription'); ?></p>
91 <div class="documentation-example">
92 <?php
93 $label = 'My action label used for accessibility visually for impaired people';
94 $user_right = 1;
95
96 $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayMessage');
97 $action_type = 'displayeventmessage';
98 $url = $_SERVER["PHP_SELF"].'?action=displayeventmessage';
99 print dolGetButtonAction($label, $html, $action_type, $url, '', $user_right);
100
101 $label = 'My action label used for accessibility visually for impaired people';
102 $user_right = 1;
103
104 $html = '<span class="fa fa-comments paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayMessages');
105 $action_type = 'displayeventmessages';
106 $url = $_SERVER["PHP_SELF"].'?action=displayeventmessages';
107 print dolGetButtonAction($label, $html, $action_type, $url, '', $user_right); ?>
108 </div>
109 <?php
110 $lines = array(
111 '<?php',
112 '
125',
126 '',
127 'setEventMessages("message", null);',
128 'setEventMessages(null, messages[]);',
129 );
130 $documentation->showCode($lines, 'php'); ?>
131 </div>
132
133 <!-- Contextual variations -->
134 <div class="documentation-section" id="seteventmessagesection-contextvariations">
135 <h2 class="documentation-title"><?php echo $langs->trans('DocSetEventMessageContextualVariations'); ?></h2>
136 <p class="documentation-text"><?php echo $langs->trans('DocSetEventMessageContextualVariationsDescription'); ?></p>
137 <div class="documentation-example">
138 <?php
139 $params = [
140 'attr' => []
141 ];
142
143 $label = 'My action label used for accessibility visually for impaired people';
144 $user_right = 1;
145 $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayOKMessage');
146 $action_type = 'displayeventmessageok';
147 $url = $_SERVER["PHP_SELF"].'?action=displayeventmessageok#seteventmessagesection-contextvariations';
148 $params['attr']['style'] = 'background: #446548';
149 print dolGetButtonAction('', $html, $action_type, $url, '', $user_right, $params);
150
151 $label = 'My action label used for accessibility visually for impaired people';
152 $user_right = 1;
153 $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayWarningMessage');
154 $action_type = 'displayeventmessagewarning';
155 $url = $_SERVER["PHP_SELF"].'?action=displayeventmessagewarning#seteventmessagesection-contextvariations';
156 $params['attr']['style'] = 'background: #a28918';
157 print dolGetButtonAction($label, $html, $action_type, $url, '', $user_right, $params);
158
159 $label = 'My action label used for accessibility visually for impaired people';
160 $user_right = 1;
161 $html = '<span class="fa fa-comment paddingright"></span>'.$langs->trans('DocSetEventMessageDisplayErrorMessage');
162 $action_type = 'displayeventmessageerror';
163 $url = $_SERVER["PHP_SELF"].'?action=displayeventmessageerror#seteventmessagesection-contextvariations';
164 $params['attr']['style'] = 'background: #a72947';
165 print dolGetButtonAction($label, $html, $action_type, $url, '', $user_right, $params); ?>
166 </div>
167 <?php
168 $lines = array(
169 '<?php',
170 'setEventMessages("message", null);',
171 'setEventMessages("message", null, "warnings");',
172 'setEventMessages("message", null, "errors");'
173 );
174 $documentation->showCode($lines, 'php'); ?>
175 </div>
176
177
178
179 <?php
180 $setEventMessageJsContextTitle = $langs->trans('DocSetEventMessageJsContext');
181 include __DIR__ . '/../dolibarr-context/inc_seteventmessage.php';
182 ?>
183
184
185
186 </div>
187
188</div>
189
190<?php
191// Output close body + html
192$documentation->docFooter();
193
194?>
Class to manage UI documentation.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.