dolibarr 24.0.0-beta
tables.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';
37require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
38
39// Load documentation translations
40$langs->load('uxdocumentation');
41
42// Hooks
43$hookmanager->initHooks(array('uidocumentation'));
44
45//
46$documentation = new Documentation($db);
47$form = new Form($db);
48
49$morejs = [
50 '/includes/ace/src/ace.js',
51 '/includes/ace/src/ext-statusbar.js',
52 '/includes/ace/src/ext-language_tools.js',
53];
54// Output html head + body - Param is Title
55$documentation->docHeader('Tables', $morejs);
56
57// Set view for menu and breadcrumb
58// Menu must be set in constructor of documentation class
59$documentation->view = array('Content','Tables');
60
61// Output sidebar
62$documentation->showSidebar(); ?>
63
64<div class="doc-wrapper">
65
66 <?php $documentation->showBreadCrumb(); ?>
67
68 <div class="doc-content-wrapper">
69
70 <h1 class="documentation-title"><?php echo $langs->trans('DocTableTitle'); ?></h1>
71 <p class="documentation-text"><?php echo $langs->trans('DocTableMainDescription'); ?></p>
72 <p class="documentation-text"><?php echo $langs->trans('DocTableMainDescriptionNote'); ?></p>
73
74 <!-- Summary -->
75 <?php $documentation->showSummary(); ?>
76
77 <!-- Basic usage -->
78 <div class="documentation-section" id="tablesection-basicusage">
79
80 <h2 class="documentation-title"><?php echo $langs->trans('DocTableBasic'); ?></h2>
81
82 <p class="documentation-text"><?php echo $langs->trans('DocTableBasicDescription'); ?></p>
83 <div class="documentation-example">
84 <div class="div-table-responsive">
85 <table class="tagtable liste" id="we-recommend-always-adding-a-unique-identifier">
86 <thead>
87 <tr class="liste_titre">
88 <th class="wrapcolumntitle left liste_titre" data-col="ProductRef" title="<?php echo dol_escape_htmltag($langs->trans('ProductRef')); ?>"><?php echo $langs->trans('ProductRef'); ?></th>
89 <th class="wrapcolumntitle center liste_titre" data-col="qty" title="<?php echo dol_escape_htmltag($langs->trans('Qty')); ?>"><?php echo $langs->trans('Qty'); ?></th>
90 <th class="wrapcolumntitle right liste_titre" data-col="amount-no-tax" title="<?php echo dol_escape_htmltag($langs->trans('AmountHT')); ?>"><?php echo $langs->trans('AmountHT'); ?></th>
91 <th class="wrapcolumntitle right liste_titre" data-col="total-no-tax" title="<?php echo dol_escape_htmltag($langs->trans('TotalHT')); ?>"><?php echo $langs->trans('TotalHT'); ?></th>
92 </tr>
93 </thead>
94 <tbody>
95 <tr class="oddeven">
96 <td class="left" data-col="ProductRef" >My Product A</td>
97 <td class="center" data-col="qty" >13</td>
98 <td class="right amount" data-col="amount-no-tax" ><?php echo price(9.99, 0, '', 1, -1, -1, 'auto'); ?></td>
99 <td class="right amount" data-col="total-no-tax" ><?php echo price(129.87, 0, '', 1, -1, -1, 'auto'); ?></td>
100 </tr>
101 <tr class="oddeven">
102 <td class="left" data-col="ProductRef" >My Product B</td>
103 <td class="center" data-col="qty" >21</td>
104 <td class="right amount" data-col="amount-no-tax" ><?php echo price(13.37, 0, '', 1, -1, -1, 'auto'); ?></td>
105 <td class="right amount" data-col="total-no-tax" ><?php echo price(280.77, 0, '', 1, -1, -1, 'auto'); ?></td>
106 </tr>
107 <tr class="oddeven">
108 <td class="left" data-col="ProductRef" >My Product C</td>
109 <td class="center" data-col="qty" >7</td>
110 <td class="right amount" data-col="amount-no-tax" ><?php echo price(16.66, 0, '', 1, -1, -1, 'auto'); ?></td>
111 <td class="right amount" data-col="total-no-tax" ><?php echo price(116.62, 0, '', 1, -1, -1, 'auto'); ?></td>
112 </tr>
113 </tbody>
114 <tfoot>
115 <tr class="liste_total">
116 <td class="left" data-col="ProductRef" >Total</td>
117 <td class="center" data-col="qty" >41</td>
118 <td class="right amount" data-col="amount-no-tax" >--</td>
119 <td class="right amount" data-col="total-no-tax" ><?php echo price(527.26, 0, '', 1, -1, -1, 'auto'); ?></td>
120 </tr>
121 </tfoot>
122 </table>
123 </div>
124 </div>
125 <?php
126 $lines = array(
127 '<table class="tagtable liste" id="we-recommend-always-adding-a-unique-identifier" >',
128 '',
129 ' <!-- Table header -->',
130 ' <thead>',
131 ' <tr class="liste_titre">',
132 ' <th class="wrapcolumntitle left liste_titre" data-col="ProductRef" title="<?php echo dol_escape_htmltag($langs->trans(\'ProductRef\')); ?>"><?php echo $langs->trans(\'ProductRef\'); ?></th>',
133 ' <th class="wrapcolumntitle left liste_titre" data-col="qty" title="<?php echo dol_escape_htmltag($langs->trans(\'Qty\')); ?>"><?php echo $langs->trans(\'Qty\'); ?></th>',
134 ' <th class="wrapcolumntitle center liste_titre" data-col="amount-no-tax" title="<?php echo dol_escape_htmltag($langs->trans(\'AmountHT\')); ?>"><?php echo $langs->trans(\'AmountHT\'); ?></th>',
135 ' <th class="wrapcolumntitle right liste_titre" data-col="total-no-tax" title="<?php echo dol_escape_htmltag($langs->trans(\'TotalHT\')); ?>"><?php echo $langs->trans(\'TotalHT\'); ?></th>',
136 ' </tr>',
137 ' </thead>',
138 '',
139 ' <tbody>',
140 ' <!-- Data lines -->',
141 ' <tr class="oddeven">',
142 ' <td class="left" data-col="ProductRef" >My Product A</td>',
143 ' <td class="left" data-col="qty" >13</td>',
144 ' <td class="center amount" data-col="amount-no-tax" >9,99 &euro;</td>',
145 ' <td class="right amount" data-col="total-no-tax" >129,87 &euro;</td>',
146 ' </tr>',
147 ' <tr class="oddeven">',
148 ' <td class="left" data-col="ProductRef" >My Product B</td>',
149 ' <td class="left" data-col="qty" >21</td>',
150 ' <td class="center amount" data-col="amount-no-tax" >13,37 &euro;</td>',
151 ' <td class="right amount" data-col="total-no-tax" >280,77 &euro;</td>',
152 ' </tr>',
153 ' </tbody>',
154 '',
155 ' <!-- Total -->',
156 ' <tfoot>',
157 ' <tr class="liste_total">',
158 ' <td class="left" data-col="ProductRef" >Total</td>',
159 ' <td class="left" data-col="qty" >58</td>',
160 ' <td class="center amount" data-col="amount-no-tax" >--</td>',
161 ' <td class="right amount" data-col="total-no-tax" >1178,87 &euro;</td>',
162 ' </tr>',
163 ' </tfoot>',
164 '',
165 '</table>',
166 );
167 $documentation->showCode($lines, 'php'); ?>
168 </div>
169
170 <!-- Table with filters -->
171 <div class="documentation-section" id="tablesection-withfilters">
172
173 <h2 class="documentation-title"><?php echo $langs->trans('DocTableWithFilters'); ?></h2>
174
175 <p class="documentation-text"><?php echo $langs->trans('DocTableWithFiltersDescription', dol_buildpath('admin/tools/ui/components/inputs.php', 1)); ?></p>
176 <div class="documentation-example">
177 <div class="div-table-responsive">
178 <table class="tagtable liste">
179 <tr class="liste_titre_filter">
180 <td class="liste_titre center maxwidthsearch">
181 <div class="nowraponall">
182 <button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x">
183 <span class="fas fa-search"></span>
184 </button>
185 <button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x">
186 <span class="fas fa-times"></span>
187 </button>
188 </div>
189 </td>
190 <td><input class="flat" type="text" name="search_firstname" value=""></td>
191 <td><input class="flat" type="text" name="search_lasttname" value=""></td>
192 <td class="center"><input class="maxwidth50 flat" type="text" name="search_age" value=""></td>
193 <td class="right"><input class="flat" type="text" name="search_country" value=""></td>
194 </tr>
195 <tr class="liste_titre">
196 <th>
197 <dl class="dropdown" style="opacity: 0.5;">
198 <dt><span class="fas fa-list" style=""></span></dt>
199 <dd class="dropdowndd">
200 <div class="multiselectcheckboxselectedfields">
201 <ul class="selectedfieldsleft"></ul>
202 </div>
203 </dd>
204 </dl>
205 <div class="inline-block checkallactions"><input type="checkbox" id="checkforselects" name="checkforselects" class="checkallactions" disabled></div>
206 </th>
207 <th class="wrapcolumntitle left liste_titre" title="First Name">First Name</th>
208 <th class="wrapcolumntitle left liste_titre" title="Last Name">Last Name</th>
209 <th class="wrapcolumntitle center liste_titre" title="Age">Age</th>
210 <th class="wrapcolumntitle right liste_titre" title="Country">Country</th>
211 </tr>
212 <tr class="oddeven">
213 <td><input type="checkbox" name="" value="" disabled></td>
214 <td class="left">John</td>
215 <td class="left">Doe</td>
216 <td class="center">37</td>
217 <td class="right">U.S.A</td>
218 </tr>
219 <tr class="oddeven">
220 <td><input type="checkbox" name="" value="" disabled></td>
221 <td class="left">Jack</td>
222 <td class="left">Sparrow</td>
223 <td class="center">29</td>
224 <td class="right">Caribbean</td>
225 </tr>
226 <tr class="oddeven">
227 <td><input type="checkbox" name="" value="" disabled></td>
228 <td class="left">Sacha</td>
229 <td class="left">Ketchum</td>
230 <td class="center">16</td>
231 <td class="right">Kanto</td>
232 </tr>
233 <tr class="oddeven">
234 <td><input type="checkbox" name="" value="" disabled></td>
235 <td class="left">Albert</td>
236 <td class="left">Einstein</td>
237 <td class="center">72</td>
238 <td class="right">Germany</td>
239 </tr>
240 </table>
241 </div>
242 </div>
243 <?php
244 $lines = array(
245 '<form method="POST" id="FORMID" action="ACTION_URL">',
246 '',
247 ' <input type="hidden" name="token" value="TOKEN_VALUE">',
248 ' <input type="hidden" name="action" value="ACTION_VALUE">',
249 ' <!-- other hidden fields like sortfield, sortorder, page, ... -->',
250 ' ',
251 ' <table class="tagtable liste" id="we-recommend-always-adding-a-unique-identifier">',
252 ' ',
253 ' <!-- Filters row -->',
254 ' <tr class="liste_titre_filter">',
255 ' <td class="liste_titre center maxwidthsearch">',
256 ' <div class="nowraponall">',
257 ' <button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x">',
258 ' <span class="fas fa-search"></span>',
259 ' </button>',
260 ' <button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x">',
261 ' <span class="fas fa-times"></span>',
262 ' </button>',
263 ' </div>',
264 ' </td>',
265 ' <td>',
266 ' <input class="flat" type="text" name="search_firstname" value="">',
267 ' </td>',
268 ' <td>',
269 ' <input class="flat" type="text" name="search_lasttname" value="">',
270 ' </td>',
271 ' <td class="center">',
272 ' <input class="maxwidth50 flat" type="text" name="search_age" value="">',
273 ' </td>',
274 ' <td class="right">',
275 ' <input class="flat" type="text" name="search_country" value="">',
276 ' </td>',
277 ' </tr>',
278 ' ',
279 ' <!-- Table header -->',
280 ' <!-- Data lines -->',
281 ' <!-- Total -->',
282 ' ',
283 ' </table>',
284 '</form>',
285 );
286 $documentation->showCode($lines); ?>
287 </div>
288
289 <!-- Add a row before filters -->
290 <div class="documentation-section" id="tablesection-beforefilters">
291
292 <h2 class="documentation-title"><?php echo $langs->trans('DocTableBeforeFilters'); ?></h2>
293
294 <p class="documentation-text"><?php echo $langs->trans('DocTableBeforeFiltersDescription'); ?></p>
295 <div class="documentation-example">
296 <div class="div-table-responsive">
297 <div class="liste_titre liste_titre_bydiv centpercent">
298 <div class="divsearchfield">
299 <span class="fas fa-tag pictofixedwidth" style="" title="TitleOfMySelectBeforeFilter"></span>
300 <?php echo $form->selectarray('myselectbeforefilter', array('ValueFilterA', 'ValueFilterB', 'ValueFilterC'), '', 1); ?>
301 </div>
302 </div>
303 <table class="tagtable liste listwithfilterbefore">
304 <tr class="liste_titre_filter">
305 <td class="liste_titre center maxwidthsearch">
306 <div class="nowraponall">
307 <button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x">
308 <span class="fas fa-search"></span>
309 </button>
310 <button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x">
311 <span class="fas fa-times"></span>
312 </button>
313 </div>
314 </td>
315 <td><input class="flat" type="text" name="search_firstname" value=""></td>
316 <td><input class="flat" type="text" name="search_lasttname" value=""></td>
317 <td class="center"><input class="maxwidth50 flat" type="text" name="search_age" value=""></td>
318 <td class="right"><input class="flat" type="text" name="search_country" value=""></td>
319 </tr>
320 <tr class="liste_titre">
321 <th>
322 <dl class="dropdown" style="opacity: 0.5;">
323 <dt><span class="fas fa-list" style=""></span></dt>
324 <dd class="dropdowndd">
325 <div class="multiselectcheckboxselectedfields">
326 <ul class="selectedfieldsleft"></ul>
327 </div>
328 </dd>
329 </dl>
330 <div class="inline-block checkallactions"><input type="checkbox" id="checkforselects" name="checkforselects" class="checkallactions" disabled></div>
331 </th>
332 <th class="wrapcolumntitle left liste_titre" title="First Name">First Name</th>
333 <th class="wrapcolumntitle left liste_titre" title="Last Name">Last Name</th>
334 <th class="wrapcolumntitle center liste_titre" title="Age">Age</th>
335 <th class="wrapcolumntitle right liste_titre" title="Country">Country</th>
336 </tr>
337 <tr class="oddeven">
338 <td><input type="checkbox" name="" value="" disabled></td>
339 <td class="left">John</td>
340 <td class="left">Doe</td>
341 <td class="center">37</td>
342 <td class="right">U.S.A</td>
343 </tr>
344 <tr class="oddeven">
345 <td><input type="checkbox" name="" value="" disabled></td>
346 <td class="left">Jack</td>
347 <td class="left">Sparrow</td>
348 <td class="center">29</td>
349 <td class="right">Caribbean</td>
350 </tr>
351 <tr class="oddeven">
352 <td><input type="checkbox" name="" value="" disabled></td>
353 <td class="left">Sacha</td>
354 <td class="left">Ketchum</td>
355 <td class="center">16</td>
356 <td class="right">Kanto</td>
357 </tr>
358 <tr class="oddeven">
359 <td><input type="checkbox" name="" value="" disabled></td>
360 <td class="left">Albert</td>
361 <td class="left">Einstein</td>
362 <td class="center">72</td>
363 <td class="right">Germany</td>
364 </tr>
365 </table>
366 </div>
367 </div>
368 <?php
369 $lines = array(
370 '<div class="liste_titre liste_titre_bydiv centpercent">',
371 ' <div class="divsearchfield">',
372 ' <span class="fas fa-tag pictofixedwidth" style="" title="TitleOfMySelectBeforeFilter"></span>',
373 ' <!-- Use Form Class to show a select, see Inputs section. Select below is for example -->',
374 ' <select name="myselectbeforefilter">',
375 ' <option value="-1"></option>',
376 ' <option value="ValueFilterA">ValueFilterA</option>',
377 ' <option value="ValueFilterB">ValueFilterB</option>',
378 ' <option value="ValueFilterC">ValueFilterC</option>',
379 ' </select>',
380 ' </div>',
381 '</div>',
382 '<table class="tagtable liste listwithfilterbefore" id="we-recommend-always-adding-a-unique-identifier">',
383 ' <!-- Filters row -->',
384 ' <!-- Table header -->',
385 ' <!-- Data lines -->',
386 ' <!-- Total -->',
387 '</table>',
388 );
389 $documentation->showCode($lines); ?>
390 </div>
391
392 <!-- CSS classes for tables -->
393 <div class="documentation-section" id="tablesection-cssclasses">
394
395 <h2 class="documentation-title"><?php echo $langs->trans('DocTableCSSClass'); ?></h2>
396
397 <p class="documentation-text"><?php echo $langs->transnoentities('DocTableCSSClassDescription'); ?></p>
398
399 <p class="documentation-text"><?php echo $langs->transnoentities('DocTableTABLECSSClassDescription'); ?></p>
400 <ul>
401 <li><?php echo $langs->transnoentities('DocTableCSSClass_tagtable'); ?></li>
402 <li><?php echo $langs->transnoentities('DocTableCSSClass_liste'); ?></li>
403 <li><?php echo $langs->transnoentities('DocTableCSSClass_listwithfilterbefore'); ?></li>
404 </ul>
405
406 <p class="documentation-text"><?php echo $langs->transnoentities('DocTableTRCSSClassDescription'); ?></p>
407 <ul>
408 <li><?php echo $langs->transnoentities('DocTableCSSClass_liste_titre'); ?></li>
409 <li><?php echo $langs->transnoentities('DocTableCSSClass_liste_titre_filter'); ?></li>
410 <li><?php echo $langs->transnoentities('DocTableCSSClass_liste_total'); ?></li>
411 <li><?php echo $langs->transnoentities('DocTableCSSClass_oddeven'); ?></li>
412 </ul>
413 </div>
414
415 </div>
416
417 </div>
418
419<?php
420// Output close body + html
421$documentation->docFooter();
422?>
Class to manage UI documentation.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
a disabled
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.