dolibarr 25.0.0-alpha
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('NOREQUIREHTML')) {
28 define('NOREQUIREHTML', 1);
29}
30if (!defined('NOREQUIREAJAX')) {
31 define('NOREQUIREAJAX', '1');
32}
33if (!defined('NOSESSION')) {
34 define('NOSESSION', '1');
35}
36if (!defined('NOREQUIREMENU')) {
37 define('NOREQUIREMENU', '1');
38}
39session_cache_limiter('public');
40
41require '../../../../main.inc.php';
42
52// Security
53if ($dolibarr_main_prod) {
55}
56
57
58/*
59 * View
60 */
61
62llxHeader('', 'Documentation and examples for theme');
63?>
64<main role="main" >
65 <h1 class="bd-title" id="content">Button for action</h1>
66 <p class="bd-lead">Documentation and examples for buttons.</p>
67
68 <h2 id="example01">Example of simple usage</h2>
69
70 <p>Buttons for user allowed to click.</p>
71
72 <div class="bd-example">
73 <?php
74 $n = 1;
75 $label = 'My action label used for accessibility visually for impaired people';
76 $html = '<span class="fa fa-clone" ></span> My default action';
77 $actionType = 'default';
78 $n++;
79 $id = 'mybuttonid'.$n;
80 $url = '#'.$id;
81 $userRight = 1;
82 $params = array();
83
84 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
85
86
87 $html = '<span class="fa fa-clone" ></span> My delete action';
88 $actionType = 'delete';
89 $n++;
90 $id = 'mybuttonid'.$n;
91 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
92 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
93
94
95 $html = '<span class="fa fa-clone" ></span> My danger action';
96 $actionType = 'danger';
97 $n++;
98 $id = 'mybuttonid'.$n;
99 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
100 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
101
102 ?>
103 </div>
104
105 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
106
107 <div class="bd-example">
108 <?php
109 $label = 'My action label used for accessibility visually for impaired people';
110 $html = '<span class="fa fa-clone" ></span> My default action';
111 $actionType = 'default';
112 $n++;
113 $id = 'mybuttonid'.$n;
114 $url = '#'.$id;
115 $userRight = 0;
116
117 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
118
119
120 $html = '<span class="fa fa-clone" ></span> My delete action';
121 $actionType = 'delete';
122 $n++;
123 $id = 'mybuttonid'.$n;
124 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
125 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
126
127
128 $html = '<span class="fa fa-clone" ></span> My danger action';
129 $actionType = 'danger';
130 $n++;
131 $id = 'mybuttonid'.$n;
132 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
133 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
134
135 ?>
136 </div>
137
138
139 <h2 id="example01">Example of confirm dialog</h2>
140
141 <p>Buttons for user allowed to click.</p>
142
143 <div class="bd-example">
144 <?php
145 $label = 'My action label used for accessibility visually for impaired people';
146 $html = '<span class="fa fa-clone" ></span> My default action';
147 $actionType = 'default';
148 $n++;
149 $id = 'mybuttonid'.$n;
150 $url = '#'.$id;
151 $userRight = 1;
152 $params = array(
153 'confirm' => [],
154 );
155
156 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
157
158
159 $html = '<span class="fa fa-clone" ></span> My delete action';
160 $actionType = 'delete';
161 $n++;
162 $id = 'mybuttonid'.$n;
163 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
164
165 $params = array(
166 'confirm' => array(
167 'url' => 'your confirm action url',
168 'title' => 'Your title to display',
169 'action-btn-label' => 'Your confirm label',
170 'cancel-btn-label' => 'Your cancel label',
171 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>',
172 )
173 );
174
175 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
176
177 ?>
178 </div>
179
180 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
181
182 <div class="bd-example">
183 <?php
184 $label = 'My action label used for accessibility visually for impaired people';
185 $html = '<span class="fa fa-clone" ></span> My default action';
186 $actionType = 'default';
187 $n++;
188 $id = 'mybuttonid'.$n;
189 $url = '#'.$id;
190 $userRight = 0;
191 $params = array(
192 'confirm' => [],
193 );
194
195 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
196
197
198 $html = '<span class="fa fa-clone" ></span> My delete action';
199 $actionType = 'delete';
200 $n++;
201 $id = 'mybuttonid'.$n;
202 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
203
204 $params = array(
205 'confirm' => array(
206 'url' => 'your confirm action url',
207 'title' => 'Your title to display',
208 'action-btn-label' => 'Your confirm label',
209 'cancel-btn-label' => 'Your cancel label',
210 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>',
211 )
212 );
213
214 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
215
216 ?>
217 </div>
218
219
220</main>
221
222<?php llxFooter();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage UI documentation.
$conf db user
Active Directory does not allow anonymous connections.
Definition repair.php:141
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.