dolibarr 18.0.6
test_buttons.php
1<?php
2if (!defined('NOREQUIRESOC')) {
3 define('NOREQUIRESOC', '1');
4}
5if (!defined('NOCSRFCHECK')) {
6 define('NOCSRFCHECK', 1);
7}
8if (!defined('NOTOKENRENEWAL')) {
9 define('NOTOKENRENEWAL', 1);
10}
11if (!defined('NOLOGIN')) {
12 define('NOLOGIN', 1); // File must be accessed by logon page so without login
13}
14if (!defined('NOREQUIREHTML')) {
15 define('NOREQUIREHTML', 1);
16}
17if (!defined('NOREQUIREAJAX')) {
18 define('NOREQUIREAJAX', '1');
19}
20if (!defined('NOSESSION')) {
21 define('NOSESSION', '1');
22}
23if (!defined('NOREQUIREMENU')) {
24 define('NOREQUIREMENU', '1');
25}
26session_cache_limiter('public');
27
28require_once '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
30
31// Security
32if ($dolibarr_main_prod) {
34}
35
36
37/*
38 * View
39 */
40
41llxHeader('', 'Documentation and examples for theme');
42?>
43<main role="main" >
44 <h1 class="bd-title" id="content">Button for action</h1>
45 <p class="bd-lead">Documentation and examples for buttons.</p>
46
47 <h2 id="example01">Example of simple usage</h2>
48
49 <p>Buttons for user allowed to click.</p>
50
51 <div class="bd-example">
52 <?php
53 $n = 1;
54 $label = 'My action label used for accessibility visually for impaired people';
55 $html = '<span class="fa fa-clone" ></span> My default action';
56 $actionType = 'default';
57 $n++;
58 $id = 'mybuttonid'.$n;
59 $url = '#'.$id;
60 $userRight = 1;
61 $params = array();
62
63 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
64
65
66 $html = '<span class="fa fa-clone" ></span> My delete action';
67 $actionType = 'delete';
68 $n++;
69 $id = 'mybuttonid'.$n;
70 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
71 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
72
73
74 $html = '<span class="fa fa-clone" ></span> My danger action';
75 $actionType = 'danger';
76 $n++;
77 $id = 'mybuttonid'.$n;
78 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
79 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
80
81 ?>
82 </div>
83
84 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
85
86 <div class="bd-example">
87 <?php
88 $label = 'My action label used for accessibility visually for impaired people';
89 $html = '<span class="fa fa-clone" ></span> My default action';
90 $actionType = 'default';
91 $n++;
92 $id = 'mybuttonid'.$n;
93 $url = '#'.$id;
94 $userRight = 0;
95
96 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
97
98
99 $html = '<span class="fa fa-clone" ></span> My delete action';
100 $actionType = 'delete';
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 $html = '<span class="fa fa-clone" ></span> My danger action';
108 $actionType = 'danger';
109 $n++;
110 $id = 'mybuttonid'.$n;
111 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
112 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
113
114 ?>
115 </div>
116
117
118 <h2 id="example01">Example of confirm dialog</h2>
119
120 <p>Buttons for user allowed to click.</p>
121
122 <div class="bd-example">
123 <?php
124 $label = 'My action label used for accessibility visually for impaired people';
125 $html = '<span class="fa fa-clone" ></span> My default action';
126 $actionType = 'default';
127 $n++;
128 $id = 'mybuttonid'.$n;
129 $url = '#'.$id;
130 $userRight = 1;
131 $params = array(
132 'confirm' => true
133 );
134
135 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
136
137
138 $html = '<span class="fa fa-clone" ></span> My delete action';
139 $actionType = 'delete';
140 $n++;
141 $id = 'mybuttonid'.$n;
142 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
143
144 $params = array(
145 'confirm' => array(
146 'url' => 'your confirm action url',
147 'title' => 'Your title to display',
148 'action-btn-label' => 'Your confirm label',
149 'cancel-btn-label' => 'Your cancel label',
150 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
151 )
152 );
153
154 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
155
156 ?>
157 </div>
158
159 <p>Buttons for user <strong>NOT</strong> allowed to click.</p>
160
161 <div class="bd-example">
162 <?php
163 $label = 'My action label used for accessibility visually for impaired people';
164 $html = '<span class="fa fa-clone" ></span> My default action';
165 $actionType = 'default';
166 $n++;
167 $id = 'mybuttonid'.$n;
168 $url = '#'.$id;
169 $userRight = 0;
170 $params = array(
171 'confirm' => true
172 );
173
174 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
175
176
177 $html = '<span class="fa fa-clone" ></span> My delete action';
178 $actionType = 'delete';
179 $n++;
180 $id = 'mybuttonid'.$n;
181 $url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
182
183 $params = array(
184 'confirm' => array(
185 'url' => 'your confirm action url',
186 'title' => 'Your title to display',
187 'action-btn-label' => 'Your confirm label',
188 'cancel-btn-label' => 'Your cancel label',
189 'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
190 )
191 );
192
193 print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
194
195 ?>
196 </div>
197
198
199</main>
200
201<?php llxFooter();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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:93
$conf db user
Definition repair.php:124
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.