dolibarr 21.0.0-beta
test_arrays.php
1<?php
2/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
3 */
4
5
6// Load Dolibarr environment
7@include '../../main.inc.php';
8
9// Security
10if ($dolibarr_main_prod) {
11 accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1');
12}
13
14
15
16/*
17 * View
18 */
19
20$form = new Form($db);
21
22$usedolheader = 1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header
23
24// HEADER
25//--------
26
27if (empty($usedolheader)) {
28 header("Content-type: text/html; charset=UTF8");
29
30 // Security options
31 header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
32 header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
33 ?>
34 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
35 <html>
36 <head>
37 <meta name="robots" content="noindex,nofollow" />
38 <meta name="author" content="Dolibarr Development Team">
39 <title>Test page</title>
40 <!-- Includes for JQuery (Ajax library) -->
41 <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/base/jquery-ui.css" />
42 <!-- <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css" /> -->
43 <link rel="stylesheet" type="text/css" title="default" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php<?php echo (GETPOST("dol_use_jmobile") == 1) ? '?dol_use_jmobile=1&dol_optimize_smallscreen=1' : ''; ?>" />
44 <!-- Includes JS for JQuery -->
45 <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery.min.js"></script>
46 <!-- migration fixes for removed Jquery functions -->
47 <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-migrate.min.js"></script>
48 <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script>
49 <!-- <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js"></script> -->
50 <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/select2/select2.min.js?version=4.0.0-beta"></script>
51 </head>
52
53 <body style="padding: 10px;">
54
55
56 <?php
57} else {
58 $arraycss = array();
59 $arrayjs = array();
60 /*
61 $arraycss=array('/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css',
62 '/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css',
63 '/includes/jquery/plugins/datatables/extensions/ColReorder/css/colReorder.dataTables.min.css'
64 );
65 $arrayjs=array('/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js',
66 '/includes/jquery/plugins/datatables/extensions/Buttons/js/dataTables.buttons.js',
67 '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.colVis.min.js',
68 '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.html5.min.js',
69 '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.flash.min.js',
70 '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.print.min.js',
71 '/includes/jquery/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.min.js',
72 '/includes/jszip/jszip.min.js',
73 '/includes/pdfmake/pdfmake.min.js',
74 '/includes/pdfmake/vfs_fonts.js'
75 );
76 */
77
78 llxHeader('', '', '', '', 0, 0, $arrayjs, $arraycss);
79}
80
81
82// CONTENT
83//---------
84?>
85
86<h2>
87This page is a sample of page using tables. It is designed to make test with<br>
88</h2>
89<div class="wordbreak">
90- css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
91- jmobile (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?dol_use_jmobile=1&dol_optimize_smallscreen=1'; ?>">dol_use_jmobile=1&amp;dol_optimize_smallscreen=1</a> and switch to small screen < 570 to enable with emulated jmobile)<br>
92- no javascript / usage for blind people (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
93- tablednd<br>
94</div>
95
96
97<br><hr><br>Example 0a : Table with div+div+div containing a select that should be overflowed and truncated => Use this to align text or form<br>
98
99<div class="tagtable centpercent">
100 <div class="tagtr">
101 <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
102 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
103 </div>
104 <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
105 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
106 </div>
107 </div>
108</div>
109
110<br><hr><br>Example 0b: Table with div+form+div containing a select that should be overflowed and truncated => Use this to align text or form<br>
111
112<div class="tagtable centpercent">
113 <form action="xxx" method="POST" class="tagtr">
114 <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
115 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
116 </div>
117 <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
118 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
119 </div>
120 </form>
121</div>
122
123<br><hr><br>Example 0c: Table with table+tr+td containing a select that should be overflowed and truncated => Use this to align text or form<br>
124
125<table class="centpercent">
126 <tr>
127 <td class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
128 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
129 </td>
130 <td class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
131 <select name="hidedetails" class="centpercentonsmartphone"><option>aaaaaaaaaaaaaaafd sf sf gfd gfds fsd gfd fhfg hf dhfg hg fhfgdhfgdh gh gfdhdgf h gfdh dfhg dfgh dfgh fdgh gfd hfd hfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select>
132 </td>
133 </tr>
134</table>
135
136
137
138
139<br><hr><br>Example 1 : Standard table/thead/tbody/tr/th-td (no class pair/impair on td) => Use this if you need the drag and drop for lines or for long result tables<br>
140
141
142<script type="text/javascript">
143/*jQuery(document).ready(function() {
144$(document).ready(function() {
145 var table = $('#tablelines3').DataTable( {
146 scrollY: "300px",
147 scrollX: true,
148 scrollCollapse: true,
149 paging: false,
150 fixedColumns: {
151 leftColumns: 1,
152 rightColumns: 1
153 }
154 } );
155} );
156});*/
157</script>
158
159
160<?php
161include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
162$productspecimen = new Product($db);
163$productspecimen->initAsSpecimen();
164$object = $productspecimen;
165$param = '';
166$actioncode = '';
167$status = '';
168$filter = '';
169$filtert = '';
170$socid = 0;
171$type = 0;
172$usergroup = 0;
173
174$sortfield = 'aaa';
175$sortorder = 'ASC';
176$tasksarray = array(1, 2, 3); // To force having several lines
177$tagidfortablednd = 'tablelines3';
178if (!isset($moreforfilter)) {
179 $moreforfilter = '';
180}
181if (!empty($conf->use_javascript_ajax)) {
182 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
183}
184
185$nav = '';
186$nav .= '<form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?mode=show_peruser'.$param.'">';
187if ($actioncode || GETPOSTISSET('actioncode')) {
188 $nav .= '<input type="hidden" name="actioncode" value="'.$actioncode.'">';
189}
190if ($status || GETPOSTISSET('status')) {
191 $nav .= '<input type="hidden" name="status" value="'.$status.'">';
192}
193if ($filter) {
194 $nav .= '<input type="hidden" name="filter" value="'.$filter.'">';
195}
196if ($filtert) {
197 $nav .= '<input type="hidden" name="filtert" value="'.$filtert.'">';
198}
199if ($socid) {
200 $nav .= '<input type="hidden" name="socid" value="'.$socid.'">';
201}
202if (isset($showbirthday) && $showbirthday) {
203 $nav .= '<input type="hidden" name="showbirthday" value="1">';
204}
205if (isset($pid) && $pid) {
206 $nav .= '<input type="hidden" name="projectid" value="'.$pid.'">';
207}
208if ($type) {
209 $nav .= '<input type="hidden" name="type" value="'.$type.'">';
210}
211if ($usergroup) {
212 $nav .= '<input type="hidden" name="usergroup" value="'.$usergroup.'">';
213}
214$nav .= $form->selectDate($dateselect ?? '', 'dateselect', 0, 0, 1, '', 1, 0);
215$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
216$nav .= '</form>';
217
218$limit = 10;
219print_barre_liste('Title of my list', 12, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 500, '', 0, $nav, '', $limit, 0, 0, 1);
220
221$moreforfilter .= '<div class="divsearchfield">';
222$moreforfilter .= $langs->trans('This is a select list for a filter A (no combo forced)').': ';
223$cate_arbo = array('field1' => 'value1a into the select list A', 'field2' => 'value2a');
224$moreforfilter .= $form->selectarray('search_aaa', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 0); // List with no js combo
225$moreforfilter .= '</div>';
226
227$moreforfilter .= '<div class="divsearchfield">';
228$moreforfilter .= $langs->trans('This is a select list for a filter B (auto combo)').': ';
229$cate_arbo = array('field1' => 'value1b into the select list B', 'field2' => 'value2b');
230$moreforfilter .= $form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', -1); // List with js combo auto
231$moreforfilter .= '</div>';
232
233$moreforfilter .= '<div class="divsearchfield">';
234$moreforfilter .= $langs->trans('This is a select list for a filter C (combo forced)').': ';
235$cate_arbo = array('field1' => 'value1c into the select list C', 'field2' => 'value2c');
236$moreforfilter .= $form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 1); // List with js combo forced
237$moreforfilter .= '</div>';
238
239$moreforfilter .= '<div class="divsearchfield">';
240$moreforfilter .= $langs->trans('This is a select list for a filter D (combo forced)').': ';
241$cate_arbo = array('field1' => 'value1d into the select list D', 'field2' => 'value2d');
242$moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth300', 1); // List with js combo forced
243$moreforfilter .= '</div>';
244
245if (!empty($moreforfilter)) {
246 print '<div class="liste_titre liste_titre_bydiv centpercent">';
247 print $moreforfilter;
248 $parameters = array();
249 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
250 print $hookmanager->resPrint;
251 print '</div>';
252}
253
254?>
255
256<table class="stripe row-border order-column centpercent tagtable liste<?php echo $moreforfilter ? " listwithfilterbefore" : ""; ?>" id="tablelines3">
257<thead>
258<tr class="liste_titre">
259<?php print getTitleFieldOfList($langs->trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder); ?>
260<?php print getTitleFieldOfList($langs->trans('title2'), 0, $_SERVER["PHP_SELF"], 'bbb', '', '', 'align="center"', $sortfield, $sortorder); ?>
261<?php print getTitleFieldOfList($langs->trans('title3'), 0, $_SERVER["PHP_SELF"], 'ccc', '', '', 'align="right"', $sortfield, $sortorder); ?>
262</tr>
263</thead>
264<tbody>
265<tr class="pair"><td><?php echo $productspecimen->getNomUrl(1); ?></td><td class="center">b1</td><td class="tdlineupdown right">c1</td></tr>
266<tr class="impair nowrap"><td>a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2 a2</td><td align="center">b2</td><td class="tdlineupdown right">c2</td></tr>
267<tr class="pair"><td>a3</td><td class="center">b3</td><td class="tdlineupdown right">c3</td></tr>
268</tbody>
269</table>
270
271
272<br>
273
274
275<!--
276<br><hr><br>Example 1b : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>
277
278<script type="text/javascript">
279$(document).ready(function(){
280 $('#idtableexample2').dataTable( {
281 <?php
282 if ($optioncss == 'print') {
283 print '\'dom\': \'lfrtip\',';
284 } else {
285 print '\'dom\': \'Blfrtip\',';
286 }
287 ?>
288 "colReorder": true,
289 'buttons': [
290 'colvis','copy', 'csv', 'excel', 'pdf', 'print'
291 ],
292 "sPaginationType": "full_numbers",
293 "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "<?php echo $langs->trans('All'); ?>"]],
294 "oLanguage": {
295 "sLengthMenu": "<?php echo $langs->trans('Show'); ?> _MENU_ <?php echo $langs->trans('Entries'); ?>",
296 "sSearch": "<?php echo $langs->trans('Search'); ?>:",
297 "sZeroRecords": "<?php echo $langs->trans('NoRecordsToDisplay'); ?>",
298 "sInfoEmpty": "<?php echo $langs->trans('NoEntriesToShow'); ?>",
299 "sInfoFiltered": "(<?php echo $langs->trans('FilteredFrom'); ?> _MAX_ <?php echo $langs->trans('TotalEntries'); ?>)",
300 "sInfo": "<?php echo $langs->trans('Showing'); ?> _START_ <?php echo $langs->trans('To'); ?> _END_ <?php echo $langs->trans('WTOf'); ?> _TOTAL_ <?php echo $langs->trans('Entries'); ?>",
301 "oPaginate": {
302 "sFirst": "<?php echo $langs->transnoentities('First'); ?>",
303 "sLast": "<?php echo $langs->transnoentities('Last'); ?>",
304 "sPrevious": "<?php echo $langs->transnoentities('Previous'); ?>",
305 "sNext": "<?php echo $langs->transnoentities('Next'); ?>"
306 }
307 },
308 "aaSorting": [[0,'desc']],
309/* To use in ajax mode
310 "bProcessing": true,
311 "stateSave": true,
312 "bServerSide": true,
313 "sAjaxSource": "../ajax.php",
314 "aoColumnDefs": [
315 { "bSortable": false, "aTargets": [ 2,3,4 ] }
316 ],
317*/
318 })
319});
320</script>
321 -->
322
323
324<br><hr><br>Example 2 : Table using tags: div.tagtable+(div|form).tagtr+div[.tagtd] => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)<br><br>
325
326
327<?php
328 $tasksarray = array(1, 2, 3); // To force having several lines
329$tagidfortablednd = 'tablelines';
330if (!empty($conf->use_javascript_ajax)) {
331 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
332}
333?>
334<div class="tagtable centpercent liste_titre_bydiv" id="tablelines">
335 <div class="tagtr liste_titre">
336 <div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div>
337 <div class="tagtd">title B</div>
338 <div class="tagtd">title C</div>
339 <div class="tagtd">title D</div>
340 </div>
341 <div class="pair tagtr">
342 <div class="tagtd">line4<input type="hidden" name="cartitem" value="3"></div>
343 <div class="tagtd">dfsdf</div>
344 <div class="tagtd"><input name="count" value="4" class="maxwidth50"></div>
345 <div class="tagtd tdlineupdown">bbbb</div>
346 </div>
347 <div class="impair tagtr">
348 <div class="tagtd">line5<input type="hidden" name="cartitemb" value="3"></div>
349 <div class="tagtd">dfsdf</div>
350 <div class="tagtd"><input name="countb" value="4" class="maxwidth50"></div>
351 <div class="tagtd tdlineupdown">bbbb</div>
352 </div>
353 <div class="pair tagtr">
354 <div class="tagtd">line6<input type="hidden" name="cartitem" value="3"></div>
355 <div class="tagtd">jghjgh</div>
356 <div class="tagtd">5</div>
357 <div class="tagtd tdlineupdown">lll</div>
358 </div>
359<!-- Using form into div make Firefox crazy (page loading does not end) -->
360<!-- <form class="liste_titre" method="POST" action="1.php">
361 <div>line1<input type="hidden" name="cartitem" value="1"></div>
362 <div><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></div>
363 <div><input name="count" value="4"></div>
364 <div><input type="submit" name="count2" class="button noshadow" value="aaa"></div>
365 </form>
366 <form class="impair" method="POST" action="2.php">
367 <div>line2<input type="hidden" name="cartitem" value="2"></div>
368 <div><select name="hidedetails"><option>aaaaaaaaaaaaaaafd sf sf gfd gfd gs fgdf gaaaa</option><option>gdfs gdf g sdfg dfg fdsg dsfg dfs gdfs gds fgs gdfdf gd</option></select></div>
369 <div><input name="countb" value="4"></div>
370 <div class="tdlineupdown"><input type="submit" value="xxx" class="button"></div>
371 </form>-->
372</div>
373
374
375
376
377<?php
378if (!empty($usedolheader)) {
379 llxFooter();
380} else { ?>
381</body>
382<?php } ?>
383
384</html>
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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 generation of HTML components Only common components must be here.
Class to manage products or services.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
treeview li table
No Email.
usage($program, $header)
Print the usage when executing scripts from install/.
Definition inc.php:94
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.