test_forms.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. define('REQUIRE_JQUERY_MULTISELECT', 'select2');
  5. require '../../main.inc.php';
  6. include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  7. if ($dolibarr_main_prod) {
  8. accessforbidden();
  9. }
  10. llxHeader();
  11. ?>
  12. <h2>
  13. This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with<br>
  14. - css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
  15. - jmobile (add parameter <a class="wordbreak" 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>
  16. - no javascript / usage for bind people (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
  17. </h2>
  18. <br>
  19. <!-- Output to test html.form.class.php -->
  20. <?php
  21. $form = new Form($db);
  22. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  23. // Test1: form->selectDate using tzuser date
  24. print "Test 1a: We must have here current date and hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known.";
  25. $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;
  26. $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60;
  27. print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")<br>\n";
  28. print $form->selectDate(dol_now(), 'test1a', 1, 1, 0);
  29. print '<br><br>'."\n";
  30. print "Test 1b: We must have here current date with hours to 00:00.<br>";
  31. print $form->selectDate('', 'test1b', 1, 1, 0);
  32. print '<br><br>'."\n";
  33. // Test2: form->selectDate using tzuser date
  34. print "Test 2: We must have here 1970-01-01 00:00:00 selected (fields can be empty)<br>\n";
  35. print $form->selectDate(dol_get_first_day(1970, 1, false), 'test2', 1, 1, 1);
  36. print '<br><br>'."\n";
  37. // Test3: form->selectDate for 1970-01-01 00:00:00
  38. print "Test 3: We must have here 1970-01-01 00:00:00 selected (fields are mandatory)<br>\n";
  39. print $form->selectDate(dol_get_first_day(1970, 1, false), 'test3', 1, 1, 0);
  40. print '<br><br>'."\n";
  41. // Test4a: a select
  42. print "Test 4a: a select<br>\n";
  43. $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3 ith a very long text. aze eazeae e ae aeae a e a ea ea ea e a e aea e ae aeaeaeaze.');
  44. $selected = 3;
  45. print $form->selectarray('testselecta', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
  46. print '<br><br>';
  47. print "Test 4b: a select<br>\n";
  48. $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
  49. $selected = 3;
  50. print $form->selectarray('testselectb', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
  51. print '<br><br>'."\n";
  52. print "Test 4c: Select array with addjscombo not forced<br>\n";
  53. $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
  54. print $form->selectarray('selectarray', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 0);
  55. print '<br><br>'."\n";
  56. print "Test 4d: a select with ajax refresh and with onchange call of url<br>\n";
  57. $selected = -1;
  58. print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth100', 1);
  59. print '<br><br>'."\n";
  60. // Test5a: form->select_thirdparty
  61. print "Test 5a: Select thirdparty<br>\n";
  62. print $form->select_company(0, 'thirdpartytest', '', '', 0, 0, null, 0, 'minwidth100');
  63. print '<br><br>'."\n";
  64. // Test5b: form->select_product
  65. print "Test 5b: Select product (using ajax)<br>\n";
  66. $form->select_produits(0, 'producttest', '', 20, 0, 1, 2, '', 0, null, 0, '1', 0, 'minwidth100');
  67. print '<br><br>'."\n";
  68. // Test5c: a multiselect
  69. print "Test 5c: a multiselect<br>\n";
  70. $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
  71. $arrayselected = array(1, 3);
  72. print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, 'minwidth100');
  73. print '</div>';
  74. // End of page
  75. llxFooter();
  76. $db->close();