2014-03-29 04:26:44 +01:00
< ? php
2024-11-15 14:09:04 +01:00
/* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2024-11-23 10:38:30 +01:00
2020-04-10 10:59:32 +02:00
define ( " NOCSRFCHECK " , 1 ); // We accept to go on this page from external web site.
2024-11-14 01:00:14 +01:00
//define("NOLOGIN",1); // This means this output page does not require to be logged.
2022-04-02 19:50:26 +02:00
/* if ( ! defined ( 'NOSESSION' )) {
2021-02-26 18:58:34 +01:00
define ( 'NOSESSION' , '1' );
2022-04-02 19:50:26 +02:00
} */
2014-03-29 04:26:44 +01:00
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2024-11-23 10:38:30 +01:00
require '../../../../main.inc.php' ;
2024-11-14 01:00:14 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2014-03-29 04:26:44 +01:00
2024-11-23 10:38:30 +01:00
/**
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*
* @ var int $dolibarr_main_prod
*/
2021-11-24 20:53:17 +01:00
// Security
2015-05-07 10:32:20 +02:00
if ( $dolibarr_main_prod ) {
2021-12-06 12:12:04 +01:00
accessforbidden ( 'Access forbidden when $dolibarr_main_prod is set to 1' );
2014-03-29 04:26:44 +01:00
}
2014-11-15 00:57:31 +01:00
2021-11-24 20:53:17 +01:00
/*
* View
*/
2014-11-15 00:57:31 +01:00
llxHeader ();
2014-03-29 04:26:44 +01:00
?>
2014-11-23 13:19:28 +01:00
This page is a sample of page using Dolibarr HTML widget methods . It is designed to make test with < br >
2015-12-15 09:32:09 +01:00
- css ( add parameter & amp ; theme = newtheme to test another theme or edit css of current theme ) < br >
2019-08-29 01:32:10 +02:00
- 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 >
2024-11-15 14:09:04 +01:00
- 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 >
2020-06-12 01:19:50 +02:00
- 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 >
2024-01-27 23:38:18 +01:00
< br >< br >
2014-03-29 04:26:44 +01:00
<!-- Output to test html . form . class . php -->
2014-11-15 00:57:31 +01:00
< ? php
2020-04-10 10:59:32 +02:00
$form = new Form ( $db );
2014-03-29 04:26:44 +01:00
2024-01-12 17:55:52 +01:00
print '<div class="div-table-responsive">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2019-08-29 01:32:10 +02:00
2018-09-09 08:02:26 +02:00
// Test1: form->selectDate using tzuser date
2018-05-12 13:40:53 +02:00
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. " ;
2020-04-10 10:59:32 +02:00
$offsettz = ( empty ( $_SESSION [ 'dol_tz' ]) ? 0 : $_SESSION [ 'dol_tz' ]) * 60 * 60 ;
$offsetdst = ( empty ( $_SESSION [ 'dol_dst' ]) ? 0 : $_SESSION [ 'dol_dst' ]) * 60 * 60 ;
2023-07-31 01:37:04 +02:00
print " (dol_tz= " . $offsettz . " dol_dst= " . $offsetdst . " )<br> \n " ;
2018-09-09 08:02:26 +02:00
print $form -> selectDate ( dol_now (), 'test1a' , 1 , 1 , 0 );
2018-05-12 13:40:53 +02:00
print '<br><br>' . " \n " ;
print " Test 1b: We must have here current date with hours to 00:00.<br> " ;
2018-09-09 08:02:26 +02:00
print $form -> selectDate ( '' , 'test1b' , 1 , 1 , 0 );
2014-03-29 04:26:44 +01:00
print '<br><br>' . " \n " ;
2018-09-09 08:02:26 +02:00
// Test2: form->selectDate using tzuser date
2024-01-27 23:38:18 +01:00
print " Test 2: We must have here 1970-01-01 selected (fields can be empty)<br> \n " ;
2019-01-27 11:55:16 +01:00
print $form -> selectDate ( dol_get_first_day ( 1970 , 1 , false ), 'test2' , 1 , 1 , 1 );
2014-03-29 04:26:44 +01:00
print '<br><br>' . " \n " ;
2018-09-09 08:02:26 +02:00
// Test3: form->selectDate for 1970-01-01 00:00:00
2014-03-29 04:26:44 +01:00
print " Test 3: We must have here 1970-01-01 00:00:00 selected (fields are mandatory)<br> \n " ;
2019-01-27 11:55:16 +01:00
print $form -> selectDate ( dol_get_first_day ( 1970 , 1 , false ), 'test3' , 1 , 1 , 0 );
2014-03-29 04:26:44 +01:00
2014-12-07 23:51:36 +01:00
print '<br><br>' . " \n " ;
2015-09-12 11:33:22 +02:00
// Test4a: a select
2015-05-10 21:21:29 +02:00
print " Test 4a: a select<br> \n " ;
2024-01-12 17:55:52 +01:00
$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.' );
2020-04-10 10:59:32 +02:00
$selected = 3 ;
2019-08-29 01:32:10 +02:00
print $form -> selectarray ( 'testselecta' , $array , $selected , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100' , 1 );
2015-05-10 21:21:29 +02:00
print '<br><br>' ;
print " Test 4b: a select<br> \n " ;
2020-04-10 10:59:32 +02:00
$array = array ( 1 => 'Value 1' , 2 => 'Value 2' , 3 => 'Value 3' );
$selected = 3 ;
2019-08-29 01:32:10 +02:00
print $form -> selectarray ( 'testselectb' , $array , $selected , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100' , 1 );
2015-05-10 21:21:29 +02:00
print '<br><br>' . " \n " ;
2019-08-29 01:32:10 +02:00
print " Test 4c: Select array with addjscombo not forced<br> \n " ;
2020-04-10 10:59:32 +02:00
$array = array ( 1 => 'Value 1' , 2 => 'Value 2' , 3 => 'Value 3' );
2019-08-29 01:32:10 +02:00
print $form -> selectarray ( 'selectarray' , $array , $selected , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100' , 0 );
2014-12-07 23:51:36 +01:00
print '<br><br>' . " \n " ;
2015-10-26 11:23:31 +01:00
print " Test 4d: a select with ajax refresh and with onchange call of url<br> \n " ;
2020-04-10 10:59:32 +02:00
$selected = - 1 ;
2019-08-29 01:32:10 +02:00
print $form -> selectArrayAjax ( 'testselectc' , DOL_URL_ROOT . '/core/ajax/selectsearchbox.php' , $selected , '' , '' , 0 , 1 , 'minwidth100' , 1 );
2015-09-12 11:33:22 +02:00
print '<br><br>' . " \n " ;
// Test5a: form->select_thirdparty
print " Test 5a: Select thirdparty<br> \n " ;
2019-08-29 01:32:10 +02:00
print $form -> select_company ( 0 , 'thirdpartytest' , '' , '' , 0 , 0 , null , 0 , 'minwidth100' );
2015-05-10 21:21:29 +02:00
print '<br><br>' . " \n " ;
2015-09-12 11:33:22 +02:00
// Test5b: form->select_product
print " Test 5b: Select product (using ajax)<br> \n " ;
2019-08-29 01:32:10 +02:00
$form -> select_produits ( 0 , 'producttest' , '' , 20 , 0 , 1 , 2 , '' , 0 , null , 0 , '1' , 0 , 'minwidth100' );
2015-05-10 21:21:29 +02:00
print '<br><br>' . " \n " ;
2015-09-12 11:33:22 +02:00
// Test5c: a multiselect
print " Test 5c: a multiselect<br> \n " ;
2020-04-10 10:59:32 +02:00
$array = array ( 1 => 'Value 1' , 2 => 'Value 2' , 3 => 'Value 3' );
$arrayselected = array ( 1 , 3 );
2019-08-29 01:32:10 +02:00
print $form -> multiselectarray ( 'testmulti' , $array , $arrayselected , '' , 0 , 'minwidth100' );
2023-02-23 11:20:19 +01:00
print '<br><br>' . " \n " ;
// Test6a: Upload of big files
print " Test 6a: Upload of big files<br> \n " ;
2023-02-24 11:05:54 +01:00
print " The file will be uploaded in the directory: documents/test/temp/<br> \n " ;
2023-02-23 11:20:19 +01:00
if ( is_file ( DOL_DOCUMENT_ROOT . '/includes/flowjs/flow.js' )) {
print '<button id="buttonbigupload" type="button">Browse...</button>' ;
print ' <span id="filespan">No file selected.</span>' ;
print '<br><div class="progress-bar filepgbar taligncenter" role="progressbar" style="width:1%;display:none"><span class="small valigntop">0%</span></div>' ;
print '<br><button type="button" style="display:none;" data-fileidentifier="" class="btn green-haze btn-circle cancelfileinput" id="filecancel">Cancel</button>' ;
print '<script src="' . DOL_URL_ROOT . '/includes/flowjs/flow.js"></script>' ;
print ' < script >
jQuery ( document ) . ready ( function () {
var flow = new Flow ({
2024-01-27 23:38:18 +01:00
target : " '.DOL_URL_ROOT.'/core/ajax/flowjs-server.php " ,
2023-02-24 11:05:54 +01:00
query : { module : " test " , token : " '.newToken().' " },
2023-02-23 11:20:19 +01:00
testChunks : false
});
' ;
2023-12-04 13:49:31 +01:00
print ' if ( flow . support ){
2023-02-23 11:20:19 +01:00
flow . assignBrowse ( document . getElementById ( " buttonbigupload " ));
flow . on ( " fileAdded " , function ( file , event ){
console . log ( " Trigger event file added " , file , event );
$ ( " #filespan " ) . text ( file . name );
$ ( " #filecancel " ) . data ( " fileidentifier " , file . uniqueIdentifier )
$ ( " #filecancel " ) . show ()
$ ( " .filepgbar " ) . show ();
$ ( " .filepgbar " ) . attr ( " id " , file . uniqueIdentifier + " pgbar " )
});
flow . on ( " filesSubmitted " , function ( array , message ){
console . log ( " Trigger event file submitted " );
flow . upload ()
});
flow . on ( " progress " , function (){
console . log ( " progress " , flow . files );
flow . files . forEach ( function ( element ){
console . log ( element . progress ());
width = Math . round ( element . progress () * 100 )
width = width . toString ()
$ ( " # " + element . uniqueIdentifier + " pgbar " ) . width ( width + " % " )
$ ( " # " + element . uniqueIdentifier + " pgbar " ) . children ( " span " ) . text ( width + " % " )
});
});
flow . on ( " fileSuccess " , function ( file , message ){
console . log ( " The file has been uploaded successfully " , file , message );
});
$ ( " .cancelfileinput " ) . on ( " click " , function (){
filename = $ ( this ) . data ( " fileidentifier " );
file = flow . getFromUniqueIdentifier ( filename );
file . cancel ();
$ ( " # " + file . uniqueIdentifier + " pgbar " ) . hide ();
console . log ( " We remove file " + filename );
$ ( " #filespan " ) . text ( " No file selected. " );
$ ( this ) . hide ();
})
2023-02-24 12:20:39 +01:00
flow . on ( " fileError " , function ( file , message ){
console . log ( " Error on file upload " , file , message );
$ ( " # " + file . uniqueIdentifier + " pgbar " ) . width ( 20 + " % " );
$ ( " # " + file . uniqueIdentifier + " pgbar " ) . children ( " span " ) . text ( " ERROR UPLOAD " );
});
2023-02-23 11:20:19 +01:00
}
})
' ;
print '</script>' ;
} else {
2023-02-24 11:05:54 +01:00
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 " ;
2023-02-23 11:20:19 +01:00
}
2019-08-29 01:32:10 +02:00
print '</div>' ;
2014-11-15 00:57:31 +01:00
2018-08-17 17:55:00 +02:00
// End of page
2014-11-15 00:57:31 +01:00
llxFooter ();
$db -> close ();