test_arrays.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?php
  2. //define("NOLOGIN",1); // This means this output page does not require to be logged.
  3. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  4. require '../../main.inc.php';
  5. if ($dolibarr_main_prod) {
  6. accessforbidden();
  7. }
  8. $usedolheader = 1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header
  9. $form = new Form($db);
  10. // HEADER
  11. //--------
  12. if (empty($usedolheader))
  13. {
  14. header("Content-type: text/html; charset=UTF8");
  15. ?>
  16. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  17. <html>
  18. <head>
  19. <meta name="robots" content="noindex,nofollow" />
  20. <meta name="author" content="Dolibarr Development Team">
  21. <title>Test page</title>
  22. <!-- Includes for JQuery (Ajax library) -->
  23. <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/base/jquery-ui.css" />
  24. <!-- <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css" /> -->
  25. <link rel="stylesheet" type="text/css" title="default" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php<?php echo ($_GET["dol_use_jmobile"] == 1) ? '?dol_use_jmobile=1&dol_optimize_smallscreen=1' : ''; ?>" />
  26. <!-- Includes JS for JQuery -->
  27. <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery.min.js"></script>
  28. <!-- migration fixes for removed Jquery functions -->
  29. <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-migrate.min.js"></script>
  30. <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script>
  31. <!-- <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js"></script> -->
  32. <script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/select2/select2.min.js?version=4.0.0-beta"></script>
  33. </head>
  34. <body style="padding: 10px;">
  35. <?php
  36. }
  37. else
  38. {
  39. $arraycss = array();
  40. $arrayjs = array();
  41. /*
  42. $arraycss=array('/includes/jquery/plugins/datatables/media/css/jquery.dataTables.css',
  43. '/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css',
  44. '/includes/jquery/plugins/datatables/extensions/ColReorder/css/colReorder.dataTables.min.css'
  45. );
  46. $arrayjs=array('/includes/jquery/plugins/datatables/media/js/jquery.dataTables.js',
  47. '/includes/jquery/plugins/datatables/extensions/Buttons/js/dataTables.buttons.js',
  48. '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.colVis.min.js',
  49. '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.html5.min.js',
  50. '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.flash.min.js',
  51. '/includes/jquery/plugins/datatables/extensions/Buttons/js/buttons.print.min.js',
  52. '/includes/jquery/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.min.js',
  53. '/includes/jszip/jszip.min.js',
  54. '/includes/pdfmake/pdfmake.min.js',
  55. '/includes/pdfmake/vfs_fonts.js'
  56. );
  57. */
  58. llxHeader('', '', '', '', 0, 0, $arrayjs, $arraycss);
  59. }
  60. // CONTENT
  61. //---------
  62. ?>
  63. <h2>
  64. This page is a sample of page using tables. It is designed to make test with<br>
  65. - css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
  66. - jmobile (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?dol_use_jmobile=4&dol_optimize_smallscreen=1'; ?>">dol_use_jmobile=4&amp;dol_optimize_smallscreen=1</a> and switch to small screen < 1000 to enable view with jmobile)<br>
  67. - 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>
  68. - no javascript / usage for bind people (add parameter <a href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
  69. - tablednd<br>
  70. </h2>
  71. <?php ?>
  72. <br><hr><br>Example 0a : Table with div+div+div containg a select that should be overflowed and truncated => Use this to align text or form<br>
  73. <div class="tagtable centpercent">
  74. <div class="tagtr">
  75. <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  76. <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>
  77. </div>
  78. <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  79. <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>
  80. </div>
  81. </div>
  82. </div>
  83. <br><hr><br>Example 0b: Table with div+form+div containg a select that should be overflowed and truncated => Use this to align text or form<br>
  84. <div class="tagtable centpercent">
  85. <form action="xxx" method="POST" class="tagtr">
  86. <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  87. <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>
  88. </div>
  89. <div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  90. <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>
  91. </div>
  92. </form>
  93. </div>
  94. <br><hr><br>Example 0c: Table with table+tr+td containg a select that should be overflowed and truncated => Use this to align text or form<br>
  95. <table class="centpercent">
  96. <tr>
  97. <td class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  98. <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>
  99. </td>
  100. <td class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;"> <!-- If you remove max-width, the jmobile overflow does not work -->
  101. <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>
  102. </td>
  103. </tr>
  104. </table>
  105. <?php ?>
  106. <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>
  107. <script type="text/javascript" language="javascript">
  108. /*jQuery(document).ready(function() {
  109. $(document).ready(function() {
  110. var table = $('#tablelines3').DataTable( {
  111. scrollY: "300px",
  112. scrollX: true,
  113. scrollCollapse: true,
  114. paging: false,
  115. fixedColumns: {
  116. leftColumns: 1,
  117. rightColumns: 1
  118. }
  119. } );
  120. } );
  121. });*/
  122. </script>
  123. <?php
  124. include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  125. $productspecimen = new Product($db);
  126. $productspecimen->initAsSpecimen();
  127. $sortfield = 'aaa';
  128. $sortorder = 'ASC';
  129. $tasksarray = array(1, 2, 3); // To force having several lines
  130. $tagidfortablednd = 'tablelines3';
  131. if (!empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  132. $nav = '';
  133. $nav .= '<form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
  134. if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav .= '<input type="hidden" name="actioncode" value="'.$actioncode.'">';
  135. if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav .= '<input type="hidden" name="status" value="'.$status.'">';
  136. if ($filter) $nav .= '<input type="hidden" name="filter" value="'.$filter.'">';
  137. if ($filtert) $nav .= '<input type="hidden" name="filtert" value="'.$filtert.'">';
  138. if ($socid) $nav .= '<input type="hidden" name="socid" value="'.$socid.'">';
  139. if ($showbirthday) $nav .= '<input type="hidden" name="showbirthday" value="1">';
  140. if ($pid) $nav .= '<input type="hidden" name="projectid" value="'.$pid.'">';
  141. if ($type) $nav .= '<input type="hidden" name="type" value="'.$type.'">';
  142. if ($usergroup) $nav .= '<input type="hidden" name="usergroup" value="'.$usergroup.'">';
  143. $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
  144. $nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
  145. $nav .= '</form>';
  146. $limit = 10;
  147. print_barre_liste('Title of my list', 12, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 500, '', 0, $nav, '', $limit);
  148. $moreforfilter .= '<div class="divsearchfield">';
  149. $moreforfilter .= $langs->trans('This is a select list for a filter A').': ';
  150. $cate_arbo = array('field1'=>'value1a into the select list A', 'field2'=>'value2a');
  151. $moreforfilter .= $form->selectarray('search_aaa', $cate_arbo, '', 1); // List without js combo
  152. $moreforfilter .= '</div>';
  153. $moreforfilter .= '<div class="divsearchfield">';
  154. $moreforfilter .= $langs->trans('This is a select list for a filter B').': ';
  155. $cate_arbo = array('field1'=>'value1b into the select list B', 'field2'=>'value2b');
  156. $moreforfilter .= $form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
  157. $moreforfilter .= '</div>';
  158. $moreforfilter .= '<div class="divsearchfield">';
  159. $moreforfilter .= $langs->trans('This is a select list for a filter C').': ';
  160. $cate_arbo = array('field1'=>'value1c into the select list C', 'field2'=>'value2c');
  161. $moreforfilter .= $form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
  162. $moreforfilter .= '</div>';
  163. $moreforfilter .= '<div class="divsearchfield">';
  164. $moreforfilter .= $langs->trans('This is a select list for a filter D').': ';
  165. $cate_arbo = array('field1'=>'value1d into the select list D', 'field2'=>'value2d');
  166. $moreforfilter .= $form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
  167. $moreforfilter .= '</div>';
  168. if (!empty($moreforfilter))
  169. {
  170. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  171. print $moreforfilter;
  172. $parameters = array();
  173. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  174. print $hookmanager->resPrint;
  175. print '</div>';
  176. }
  177. ?>
  178. <table class="stripe row-border order-column centpercent tagtable liste<?php echo $moreforfilter ? " listwithfilterbefore" : ""; ?>" id="tablelines3">
  179. <thead>
  180. <tr class="liste_titre">
  181. <?php print getTitleFieldOfList($langs->trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder); ?>
  182. <?php print getTitleFieldOfList($langs->trans('title2'), 0, $_SERVER["PHP_SELF"], 'bbb', '', '', 'align="right"', $sortfield, $sortorder); ?>
  183. <?php print getTitleFieldOfList($langs->trans('title3'), 0, $_SERVER["PHP_SELF"], 'ccc', '', '', 'align="center"', $sortfield, $sortorder); ?>
  184. </tr>
  185. </thead>
  186. <tbody>
  187. <tr class="pair"><td><?php echo $productspecimen->getNomUrl(1); ?></td><td class="right">b1</td><td class="tdlineupdown left">c1</td></tr>
  188. <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="right">b2</td><td class="tdlineupdown left">c2</td></tr>
  189. <tr class="pair"><td>a3</td><td class="right">b3</td><td class="tdlineupdown left">c3</td></tr>
  190. </tbody>
  191. </table>
  192. <br>
  193. <!--
  194. <br><hr><br>Example 1b : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>
  195. <script type="text/javascript">
  196. $(document).ready(function(){
  197. $('#idtableexample2').dataTable( {
  198. <?php
  199. if ($optioncss == 'print') {
  200. print '\'dom\': \'lfrtip\',';
  201. } else {
  202. print '\'dom\': \'Blfrtip\',';
  203. }
  204. ?>
  205. "colReorder": true,
  206. 'buttons': [
  207. 'colvis','copy', 'csv', 'excel', 'pdf', 'print'
  208. ],
  209. "sPaginationType": "full_numbers",
  210. "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "<?php echo $langs->trans('All'); ?>"]],
  211. "oLanguage": {
  212. "sLengthMenu": "<?php echo $langs->trans('Show'); ?> _MENU_ <?php echo $langs->trans('Entries'); ?>",
  213. "sSearch": "<?php echo $langs->trans('Search'); ?>:",
  214. "sZeroRecords": "<?php echo $langs->trans('NoRecordsToDisplay'); ?>",
  215. "sInfoEmpty": "<?php echo $langs->trans('NoEntriesToShow'); ?>",
  216. "sInfoFiltered": "(<?php echo $langs->trans('FilteredFrom'); ?> _MAX_ <?php echo $langs->trans('TotalEntries'); ?>)",
  217. "sInfo": "<?php echo $langs->trans('Showing'); ?> _START_ <?php echo $langs->trans('To'); ?> _END_ <?php echo $langs->trans('WTOf'); ?> _TOTAL_ <?php echo $langs->trans('Entries'); ?>",
  218. "oPaginate": {
  219. "sFirst": "<?php echo $langs->transnoentities('First'); ?>",
  220. "sLast": "<?php echo $langs->transnoentities('Last'); ?>",
  221. "sPrevious": "<?php echo $langs->transnoentities('Previous'); ?>",
  222. "sNext": "<?php echo $langs->transnoentities('Next'); ?>"
  223. }
  224. },
  225. "aaSorting": [[0,'desc']],
  226. /* To use in ajax mode
  227. "bProcessing": true,
  228. "stateSave": true,
  229. "bServerSide": true,
  230. "sAjaxSource": "../ajax.php",
  231. "aoColumnDefs": [
  232. { "bSortable": false, "aTargets": [ 2,3,4 ] }
  233. ],
  234. */
  235. })
  236. });
  237. </script>
  238. -->
  239. <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>
  240. <?php
  241. $tasksarray = array(1, 2, 3); // To force having several lines
  242. $tagidfortablednd = 'tablelines';
  243. if (!empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  244. ?>
  245. <div class="tagtable centpercent liste_titre_bydiv" id="tablelines">
  246. <div class="tagtr liste_titre">
  247. <div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div>
  248. <div class="tagtd">title B</div>
  249. <div class="tagtd">title C</div>
  250. <div class="tagtd">title D</div>
  251. </div>
  252. <div class="pair tagtr">
  253. <div class="tagtd">line4<input type="hidden" name="cartitem" value="3"></div>
  254. <div class="tagtd">dfsdf</div>
  255. <div class="tagtd"><input name="count" value="4"></div>
  256. <div class="tagtd tdlineupdown">bbbb</div>
  257. </div>
  258. <div class="impair tagtr">
  259. <div class="tagtd">line5<input type="hidden" name="cartitemb" value="3"></div>
  260. <div class="tagtd">dfsdf</div>
  261. <div class="tagtd"><input name="countb" value="4"></div>
  262. <div class="tagtd tdlineupdown">bbbb</div>
  263. </div>
  264. <div class="pair tagtr">
  265. <div class="tagtd">line6<input type="hidden" name="cartitem" value="3"></div>
  266. <div class="tagtd">jghjgh</div>
  267. <div class="tagtd">5</div>
  268. <div class="tagtd tdlineupdown">lll</div>
  269. </div>
  270. <!-- Using form into div make Firefox crazy (page loading does not end) -->
  271. <!-- <form class="liste_titre" method="POST" action="1.php">
  272. <div>line1<input type="hidden" name="cartitem" value="1"></div>
  273. <div><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></div>
  274. <div><input name="count" value="4"></div>
  275. <div><input type="submit" name="count2" class="button noshadow" value="aaa"></div>
  276. </form>
  277. <form class="impair" method="POST" action="2.php">
  278. <div>line2<input type="hidden" name="cartitem" value="2"></div>
  279. <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>
  280. <div><input name="countb" value="4"></div>
  281. <div class="tdlineupdown"><input type="submit" value="xxx" class="button"></div>
  282. </form>-->
  283. </div>
  284. <?php
  285. if (!empty($usedolheader))
  286. {
  287. llxFooter();
  288. } else { ?>
  289. </body>
  290. <?php } ?>
  291. </html>