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