18define(
"NOCSRFCHECK", 1);
25require
'../../../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38if ($dolibarr_main_prod) {
39 accessforbidden(
'Access forbidden when $dolibarr_main_prod is set to 1');
51This page is a sample of page
using Dolibarr HTML widget methods. It is designed to make test with<br>
52- css (add parameter &theme=newtheme to test another theme or edit css of current theme)<br>
53- jmobile (add parameter <a
class=
"wordbreak" href=
"<?php echo $_SERVER["PHP_SELF
"].'?dol_use_jmobile=1&dol_optimize_smallscreen=1'; ?>">dol_use_jmobile=1&dol_optimize_smallscreen=1</a> and
switch to small screen < 570 to enable with emulated jmobile)<br>
54- no javascript /
usage for blind people (add parameter <a
class=
"wordbreak" href=
"<?php echo $_SERVER["PHP_SELF
"].'?nojs=1'; ?>">nojs=1</a> to force disable javascript)<br>
55- 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>
58<!-- Output to test html.form.class.php -->
62print
'<div class="div-table-responsive">';
65print
"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.";
66$offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
67$offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
68print
" (dol_tz=".$offsettz.
" dol_dst=".$offsetdst.
")<br>\n";
69print $form->selectDate(
dol_now(),
'test1a', 1, 1, 0);
73print
"Test 1b: We must have here current date with hours to 00:00.<br>";
74print $form->selectDate(
'',
'test1b', 1, 1, 0);
79print
"Test 2: We must have here 1970-01-01 selected (fields can be empty)<br>\n";
85print
"Test 3: We must have here 1970-01-01 00:00:00 selected (fields are mandatory)<br>\n";
91print
"Test 4a: a select<br>\n";
92$array = array(1=>
'Value 1', 2=>
'Value 2', 3=>
'Value 3 with a very long text. aze eazeae e ae aeae a e a ea ea ea e a e aea e ae aeaeaeaze.');
94print $form->selectarray(
'testselecta', $array, $selected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
96print
"Test 4b: a select<br>\n";
97$array = array(1=>
'Value 1', 2=>
'Value 2', 3=>
'Value 3');
99print $form->selectarray(
'testselectb', $array, $selected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
100print
'<br><br>'.
"\n";
101print
"Test 4c: Select array with addjscombo not forced<br>\n";
102$array = array(1=>
'Value 1', 2=>
'Value 2', 3=>
'Value 3');
103print $form->selectarray(
'selectarray', $array, $selected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 0);
105print
'<br><br>'.
"\n";
107print
"Test 4d: a select with ajax refresh and with onchange call of url<br>\n";
109print $form->selectArrayAjax(
'testselectc', DOL_URL_ROOT.
'/core/ajax/selectsearchbox.php', $selected,
'',
'', 0, 1,
'minwidth100', 1);
111print
'<br><br>'.
"\n";
114print
"Test 5a: Select thirdparty<br>\n";
115print $form->select_company(0,
'thirdpartytest',
'',
'', 0, 0,
null, 0,
'minwidth100');
117print
'<br><br>'.
"\n";
120print
"Test 5b: Select product (using ajax)<br>\n";
121$form->select_produits(0,
'producttest',
'', 20, 0, 1, 2,
'', 0,
null, 0,
'1', 0,
'minwidth100');
123print
'<br><br>'.
"\n";
126print
"Test 5c: a multiselect<br>\n";
127$array = array(1=>
'Value 1', 2=>
'Value 2', 3=>
'Value 3');
128$arrayselected = array(1, 3);
129print $form->multiselectarray(
'testmulti', $array, $arrayselected,
'', 0,
'minwidth100');
131print
'<br><br>'.
"\n";
134print
"Test 6a: Upload of big files<br>\n";
135print
"The file will be uploaded in the directory: documents/test/temp/<br>\n";
137if (is_file(DOL_DOCUMENT_ROOT.
'/includes/flowjs/flow.js')) {
138 print
'<button id="buttonbigupload" type="button">Browse...</button>';
139 print
' <span id="filespan">No file selected.</span>';
140 print
'<br><div class="progress-bar filepgbar taligncenter" role="progressbar" style="width:1%;display:none"><span class="small valigntop">0%</span></div>';
141 print
'<br><button type="button" style="display:none;" data-fileidentifier="" class="btn green-haze btn-circle cancelfileinput" id="filecancel">Cancel</button>';
142 print
'<script src="'.DOL_URL_ROOT.
'/includes/flowjs/flow.js"></script>';
144 jQuery(document).ready(function() {
145 var flow = new Flow({
146 target:"'.DOL_URL_ROOT.
'/core/ajax/flowjs-server.php",
147 query:{module:"test", token:"'.
newToken().
'"},
151 print
'if(flow.support){
152 flow.assignBrowse(document.getElementById("buttonbigupload"));
153 flow.on("fileAdded", function(file, event){
154 console.log("Trigger event file added", file, event);
155 $("#filespan").text(file.name);
156 $("#filecancel").data("fileidentifier", file.uniqueIdentifier)
157 $("#filecancel").show()
158 $(".filepgbar").show();
159 $(".filepgbar").attr("id",file.uniqueIdentifier+"pgbar")
161 flow.on("filesSubmitted", function(array,message){
162 console.log("Trigger event file submitted");
165 flow.on("progress", function(){
166 console.log("progress",flow.files);
167 flow.files.forEach(function(element){
168 console.log(element.progress());
169 width = Math.round(element.progress()*100)
170 width = width.toString()
171 $("#"+element.uniqueIdentifier+"pgbar").width(width+"%")
172 $("#"+element.uniqueIdentifier+"pgbar").children("span").text(width+"%")
175 flow.on("fileSuccess", function(file,message){
176 console.log("The file has been uploaded successfully",file,message);
178 $(".cancelfileinput").on("click", function(){
179 filename = $(this).data("fileidentifier");
180 file = flow.getFromUniqueIdentifier(filename);
182 $("#"+file.uniqueIdentifier+"pgbar").hide();
183 console.log("We remove file "+filename);
184 $("#filespan").text("No file selected.");
187 flow.on("fileError", function(file, message){
188 console.log("Error on file upload",file, message);
189 $("#"+file.uniqueIdentifier+"pgbar").width(20+"%");
190 $("#"+file.uniqueIdentifier+"pgbar").children("span").text("ERROR UPLOAD");
197 print
"If this message displays, please add flow.js and flow.min.js files which can be found here: https://github.com/flowjs/flow.js and place the js lib in htdocs/includes/flowjs/<br>\n";
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_now($mode='auto')
Return date for now.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
usage($program, $header)
Print the usage when executing scripts from install/.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.