dolibarr 21.0.0-beta
test_buttons.php
1<?php
2/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
18if (!defined('NOREQUIRESOC')) {
19 define('NOREQUIRESOC', '1');
20}
21if (!defined('NOCSRFCHECK')) {
22 define('NOCSRFCHECK', 1);
23}
24if (!defined('NOTOKENRENEWAL')) {
25 define('NOTOKENRENEWAL', 1);
26}
27if (!defined('NOLOGIN')) {
28 define('NOLOGIN', 1); // File must be accessed by logon page so without login
29}
30if (!defined('NOREQUIREHTML')) {
31 define('NOREQUIREHTML', 1);
32}
33if (!defined('NOREQUIREAJAX')) {
34 define('NOREQUIREAJAX', '1');
35}
36if (!defined('NOSESSION')) {
37 define('NOSESSION', '1');
38}
39if (!defined('NOREQUIREMENU')) {
40 define('NOREQUIREMENU', '1');
41}
42session_cache_limiter('public');
43
44require '../../../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
46
56// Security
57if ($dolibarr_main_prod) {
59}
60
61
62/*
63 * View
64 */
65
66llxHeader('', 'Documentation and examples for theme');
67?>
68<main role="main" >
69 <h1 class="bd-title" id="content">Button for action</h1>
70 <p class="bd-lead">Documentation and examples for buttons.</p>
71
72 <h2 id="example01">Example of simple usage</h2>
73
74 <p>Buttons for user allowed to click.</p>
75
76 <div class="bd-example">
77 <?php
78 $n = 1;
79 $label = 'My action label used for accessibility visually for impaired people';
80 $html = '<span class="fa fa-clone" ></span> My default action';
81 $actionType = 'default';
82 $n++;
83 $id = 'mybuttonid'.$n;
84 $url = '#'.$id;
85 $userRight = 1;
86 $params = array();
87
88 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
89
90
91 $html = '<span class="fa fa-clone" ></span> My delete action';
92 $actionType = 'delete';
93 $n++;
94 $id = 'mybuttonid'.$n;
95 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
96 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
97
98
99 $html = '<span class="fa fa-clone" ></span> My danger action';
100 $actionType = 'danger';
101 $n++;
102 $id = 'mybuttonid'.$n;
103 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
104 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
105
106 ?>
107 </div>
108
109 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
110
111 <div class="bd-example">
112 <?php
113 $label = 'My action label used for accessibility visually for impaired people';
114 $html = '<span class="fa fa-clone" ></span> My default action';
115 $actionType = 'default';
116 $n++;
117 $id = 'mybuttonid'.$n;
118 $url = '#'.$id;
119 $userRight = 0;
120
121 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
122
123
124 $html = '<span class="fa fa-clone" ></span> My delete action';
125 $actionType = 'delete';
126 $n++;
127 $id = 'mybuttonid'.$n;
128 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
129 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
130
131
132 $html = '<span class="fa fa-clone" ></span> My danger action';
133 $actionType = 'danger';
134 $n++;
135 $id = 'mybuttonid'.$n;
136 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
137 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
138
139 ?>
140 </div>
141
142
143 <h2 id="example01">Example of confirm dialog</h2>
144
145 <p>Buttons for user allowed to click.</p>
146
147 <div class="bd-example">
148 <?php
149 $label = 'My action label used for accessibility visually for impaired people';
150 $html = '<span class="fa fa-clone" ></span> My default action';
151 $actionType = 'default';
152 $n++;
153 $id = 'mybuttonid'.$n;
154 $url = '#'.$id;
155 $userRight = 1;
156 $params = array(
157 'confirm' => [],
158 );
159
160 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
161
162
163 $html = '<span class="fa fa-clone" ></span> My delete action';
164 $actionType = 'delete';
165 $n++;
166 $id = 'mybuttonid'.$n;
167 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
168
169 $params = array(
170 'confirm' => array(
171 'url' => 'your confirm action url',
172 'title' => 'Your title to display',
173 'action-btn-label' => 'Your confirm label',
174 'cancel-btn-label' => 'Your cancel label',
175 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>',
176 )
177 );
178
179 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
180
181 ?>
182 </div>
183
184 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
185
186 <div class="bd-example">
187 <?php
188 $label = 'My action label used for accessibility visually for impaired people';
189 $html = '<span class="fa fa-clone" ></span> My default action';
190 $actionType = 'default';
191 $n++;
192 $id = 'mybuttonid'.$n;
193 $url = '#'.$id;
194 $userRight = 0;
195 $params = array(
196 'confirm' => [],
197 );
198
199 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
200
201
202 $html = '<span class="fa fa-clone" ></span> My delete action';
203 $actionType = 'delete';
204 $n++;
205 $id = 'mybuttonid'.$n;
206 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
207
208 $params = array(
209 'confirm' => array(
210 'url' => 'your confirm action url',
211 'title' => 'Your title to display',
212 'action-btn-label' => 'Your confirm label',
213 'cancel-btn-label' => 'Your cancel label',
214 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>',
215 )
216 );
217
218 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
219
220 ?>
221 </div>
222
223
224</main>
225
226<?php llxFooter();
$id
Definition account.php:48
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage UI documentation.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
usage($program, $header)
Print the usage when executing scripts from install/.
Definition inc.php:94
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:153
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.