dolibarr  16.0.5
test_forms.php
1 <?php
2 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
3 //define("NOLOGIN",1); // This means this output page does not require to be logged.
4 /*if (!defined('NOSESSION')) {
5  define('NOSESSION', '1');
6 }*/
7 
8 require '../../main.inc.php';
9 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
10 
11 // Security
12 if ($dolibarr_main_prod) {
13  accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1');
14 }
15 
16 
17 /*
18  * View
19  */
20 
21 llxHeader();
22 
23 ?>
24 
25 <h2>
26 This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with<br>
27 - css (add parameter &amp;theme=newtheme to test another theme or edit css of current theme)<br>
28 - 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>
29 - 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>
30 - use with a text browser (add parameter <a class="wordbreak" href="<?php echo $_SERVER["PHP_SELF"].'?textbrowser=1'; ?>">textbrowser=1</a> to force detection of a text browser)<br>
31 </h2>
32 <br>
33 
34 <!-- Output to test html.form.class.php -->
35 <?php
36 $form = new Form($db);
37 
38 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
39 
40 // Test1: form->selectDate using tzuser date
41 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.";
42 $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;
43 $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60;
44 print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")<br>\n";
45 print $form->selectDate(dol_now(), 'test1a', 1, 1, 0);
46 
47 print '<br><br>'."\n";
48 
49 print "Test 1b: We must have here current date with hours to 00:00.<br>";
50 print $form->selectDate('', 'test1b', 1, 1, 0);
51 
52 print '<br><br>'."\n";
53 
54 // Test2: form->selectDate using tzuser date
55 print "Test 2: We must have here 1970-01-01 00:00:00 selected (fields can be empty)<br>\n";
56 print $form->selectDate(dol_get_first_day(1970, 1, false), 'test2', 1, 1, 1);
57 
58 print '<br><br>'."\n";
59 
60 // Test3: form->selectDate for 1970-01-01 00:00:00
61 print "Test 3: We must have here 1970-01-01 00:00:00 selected (fields are mandatory)<br>\n";
62 print $form->selectDate(dol_get_first_day(1970, 1, false), 'test3', 1, 1, 0);
63 
64 print '<br><br>'."\n";
65 
66 // Test4a: a select
67 print "Test 4a: a select<br>\n";
68 $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.');
69 $selected = 3;
70 print $form->selectarray('testselecta', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
71 print '<br><br>';
72 print "Test 4b: a select<br>\n";
73 $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
74 $selected = 3;
75 print $form->selectarray('testselectb', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
76 print '<br><br>'."\n";
77 print "Test 4c: Select array with addjscombo not forced<br>\n";
78 $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
79 print $form->selectarray('selectarray', $array, $selected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 0);
80 
81 print '<br><br>'."\n";
82 
83 print "Test 4d: a select with ajax refresh and with onchange call of url<br>\n";
84 $selected = -1;
85 print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth100', 1);
86 
87 print '<br><br>'."\n";
88 
89 // Test5a: form->select_thirdparty
90 print "Test 5a: Select thirdparty<br>\n";
91 print $form->select_company(0, 'thirdpartytest', '', '', 0, 0, null, 0, 'minwidth100');
92 
93 print '<br><br>'."\n";
94 
95 // Test5b: form->select_product
96 print "Test 5b: Select product (using ajax)<br>\n";
97 $form->select_produits(0, 'producttest', '', 20, 0, 1, 2, '', 0, null, 0, '1', 0, 'minwidth100');
98 
99 print '<br><br>'."\n";
100 
101 // Test5c: a multiselect
102 print "Test 5c: a multiselect<br>\n";
103 $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
104 $arrayselected = array(1, 3);
105 print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, 'minwidth100');
106 
107 print '</div>';
108 
109 // End of page
110 llxFooter();
111 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
usage
usage($path, $script_file)
script cron usage
Definition: cron_run_jobs.php:310
dol_get_first_day
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:551
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59