2
0
forked from Wavyzz/dolibarr

More complete test pages

This commit is contained in:
Laurent Destailleur
2015-05-18 08:59:25 +02:00
parent e4aaff1de9
commit f0a1b7984f
2 changed files with 188 additions and 117 deletions

View File

@@ -1,18 +1,18 @@
<?php
define("NOLOGIN",1); // This means this output page does not require to be logged.
//define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require '../../main.inc.php';
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1')
{
print "Page available only frome remote address 127.0.0.1";
exit;
if ($dolibarr_main_prod) {
accessforbidden();
}
$usedolheader=1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header
$form=new Form($db);
$usedolheader=0; // 1 = Test inside a dolibarr page, 0 = Use hard coded header
// HEADER
@@ -21,39 +21,41 @@ $usedolheader=0; // 1 = Test inside a dolibarr page, 0 = Use hard coded header
if (empty($usedolheader))
{
header("Content-type: text/html; charset=UTF8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<meta name="author" content="Dolibarr Development Team">
<link rel="shortcut icon" type="image/x-icon" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/img/favicon.ico"/>
<title>Test page</title>
<!-- Includes for JQuery (Ajax library) -->
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/smoothness/jquery-ui-latest.custom.css" />
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/css/jquery.dataTables.css" />
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.css" />
<?php } ?>
<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':''; ?>" />
<!-- Includes JS for JQuery -->
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-latest.min.js"></script>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/js/jquery.dataTables.js"></script>
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.js"></script>--
<?php } ?>
</head>
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<meta name="author" content="Dolibarr Development Team">
<link rel="shortcut icon" type="image/x-icon" href="<?php echo DOL_URL_ROOT ?>/theme/eldy/img/favicon.ico"/>
<title>Test page</title>
<!-- Includes for JQuery (Ajax library) -->
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/css/smoothness/jquery-ui-latest.custom.css" />
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/css/jquery.dataTables.css" />
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.css" />
<?php } ?>
<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':''; ?>" />
<!-- Includes JS for JQuery -->
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-latest.min.js"></script>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js"></script>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/datatables/js/jquery.dataTables.js"></script>
<?php if ($_GET["dol_use_jmobile"] == 1) { ?>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/plugins/mobile/jquery.mobile-latest.min.js"></script>
<?php } ?>
</head>
<body style="padding: 10px;">
<body style="padding: 10px;">
<div data-role="page">
<div data-role="page">
<?php
<?php
}
else
{
llxHeader();
$arraycss=array('/includes/jquery/plugins/datatables/css/jquery.dataTables.css');
$arrayjs=array('/includes/jquery/plugins/datatables/js/jquery.dataTables.js');
llxHeader('','','','',0,0,$arrayjs,$arraycss);
}
@@ -63,8 +65,9 @@ else
<h1>
This page is a sample of page using tables. It is designed to make test with<br>
- css (edit page to change to test another css)<br>
- jmobile (add parameter dol_use_jmobile=1 to enable view with jmobile)<br>
- css (add parameter &theme=newtheme to test another theme or edit css of current theme)<br>
- jmobile (add parameter dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)<br>
- no javascript / usage for bind people (add parameter nojs=1 to force disable javascript)<br>
- dataTables<br>
- tablednd<br>
</h1>
@@ -111,51 +114,53 @@ This page is a sample of page using tables. It is designed to make test with<br>
<br><hr><br>Example 1 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this for tables that are edited forms<br><br>
<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>
<?php
$tasksarray=array(1,2,3); // To force having several lines
$tagidfortablednd='tablelines';
if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$productspecimen=new Product($db);
$productspecimen->initAsSpecimen();
$sortfield='aaa';
$sortorder='ASC';
$tasksarray=array(1,2,3); // To force having several lines
$tagidfortablednd='tablelines3';
if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
$nav='';
$nav.='<form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.='<input type="hidden" name="status" value="'.$status.'">';
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
if ($type) $nav.='<input type="hidden" name="type" value="'.$type.'">';
if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">';
$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$nav.='</form>';
print_barre_liste('Title of my list', 3, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 5000, '', 0, $nav);
?>
<div class="tagtable centpercent" id="tablelines">
<div class="tagtr liste_titre">
<div class="tagtd">line3<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">dfsdf</div>
<div class="tagtd">ffdsfsd</div>
<div class="tagtd tdlineupdown">aaaa</div>
</div>
<div class="impair tagtr">
<div class="tagtd">line4<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">dfsdf</div>
<div class="tagtd"><input name="count" value="4"></div>
<div class="tagtd tdlineupdown">bbbb</div>
</div>
<div class="pair tagtr">
<div class="tagtd">line5<input type="hidden" name="cartitemb" value="3"></div>
<div class="tagtd">dfsdf</div>
<div class="tagtd"><input name="countb" value="4"></div>
<div class="tagtd tdlineupdown">bbbb</div>
</div>
<!-- Using form into div make Firefox crazy (page loading does not end) -->
<!-- <form class="liste_titre" method="POST" action="1.php">
<div>line1<input type="hidden" name="cartitem" value="1"></div>
<div><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></div>
<div><input name="count" value="4"></div>
<div><input type="submit" name="count2" class="button noshadow" value="aaa"></div>
</form>
<form class="impair" method="POST" action="2.php">
<div>line2<input type="hidden" name="cartitem" value="2"></div>
<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>
<div><input name="countb" value="4"></div>
<div class="tdlineupdown"><input type="submit" value="xxx" class="button"></div>
</form>-->
</div>
<table class="liste noborder tagtable centpercent" id="tablelines3">
<tr class="liste_titre">
<?php print getTitleFieldOfList($langs->trans('title1'),0,$_SERVER["PHP_SELF"],'aaa','','','align="left"',$sortfield,$sortorder); ?>
<?php print getTitleFieldOfList($langs->trans('title2'),0,$_SERVER["PHP_SELF"],'bbb','','','align="right"',$sortfield,$sortorder); ?>
<?php print getTitleFieldOfList($langs->trans('title3'),0,$_SERVER["PHP_SELF"],'ccc','','','align="center"',$sortfield,$sortorder); ?>
</tr>
<tr class="pair"><td><?php echo $productspecimen->getNomUrl(1); ?></td><td align="right">b1</td><td class="tdlineupdown" align="left">c1</td></tr>
<tr class="impair"><td>a2</td><td align="right">b2</td><td class="tdlineupdown" align="left">c2</td></tr>
</table>
<br>
<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/td + dataTable => Use this for long result tables<br>
<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>
@@ -238,91 +243,129 @@ $('xxxth').replaceWith(
<table id="idtableexample2" class="centpercent">
<thead>
<tr>
<th>snake</th>
<th><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></th>
<?php print getTitleFieldOfList($langs->trans('zzz'),1,$_SERVER["PHP_SELF"],'','','','align="center" class="tagtd"',$sortfield,$sortorder); ?>
<tr class="liste_titre">
<th>Column A</th>
<th><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a title of Column B</label></th>
<?php
print getTitleFieldOfList($langs->trans('Column C'),1,$_SERVER["PHP_SELF"],'','','','align="center" class="tagtd"',$sortfield,$sortorder);
?>
</tr>
</thead>
<tbody>
<tr>
<td>line1</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line2</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line3</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line4</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line5</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line6</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line7</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line8</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line9</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line10</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line11</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
<tr>
<td>line12</td>
<td>dfsdf</td>
<td> xxx </td>
<td align="center"> xxx </td>
</tr>
</tbody>
</table>
<br>
<br><hr><br>Example 3 : Standard table => Use this if you need the drag and drop for lines<br>
<br><hr><br>Example 3 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.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>
<?php
$tasksarray=array(1,2,3); // To force having several lines
$tagidfortablednd='tablelines3';
$tagidfortablednd='tablelines';
if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
?>
<table class="tagtable centpercent centpercent" id="tablelines3">
<tr class="liste_titre"><td>title1</td><td>title2</td></tr>
<tr class="pair"><td class="pair">a1</td><td class="tdlineupdown pair">b1</td></tr>
<tr class="impair"><td class="impair">a2</td><td class="tdlineupdown impair">b2</td></tr>
</table>
<br>
<div class="tagtable centpercent" id="tablelines">
<div class="tagtr liste_titre">
<div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">title B</div>
<div class="tagtd">title C</div>
<div class="tagtd">title D</div>
</div>
<div class="pair tagtr">
<div class="tagtd">line4<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">dfsdf</div>
<div class="tagtd"><input name="count" value="4"></div>
<div class="tagtd tdlineupdown">bbbb</div>
</div>
<div class="impair tagtr">
<div class="tagtd">line5<input type="hidden" name="cartitemb" value="3"></div>
<div class="tagtd">dfsdf</div>
<div class="tagtd"><input name="countb" value="4"></div>
<div class="tagtd tdlineupdown">bbbb</div>
</div>
<div class="pair tagtr">
<div class="tagtd">line6<input type="hidden" name="cartitem" value="3"></div>
<div class="tagtd">jghjgh</div>
<div class="tagtd">5</div>
<div class="tagtd tdlineupdown">lll</div>
</div>
<!-- Using form into div make Firefox crazy (page loading does not end) -->
<!-- <form class="liste_titre" method="POST" action="1.php">
<div>line1<input type="hidden" name="cartitem" value="1"></div>
<div><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></div>
<div><input name="count" value="4"></div>
<div><input type="submit" name="count2" class="button noshadow" value="aaa"></div>
</form>
<form class="impair" method="POST" action="2.php">
<div>line2<input type="hidden" name="cartitem" value="2"></div>
<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>
<div><input name="countb" value="4"></div>
<div class="tdlineupdown"><input type="submit" value="xxx" class="button"></div>
</form>-->
</div>
<?php
@@ -334,4 +377,4 @@ if (! empty($usedolheader))
</body>
<?php } ?>
</html>
</html>

View File

@@ -6,23 +6,21 @@ define('REQUIRE_JQUERY_MULTISELECT','select2');
require '../../main.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1')
{
print "Page available only frome remote address 127.0.0.1";
exit;
if ($dolibarr_main_prod) {
accessforbidden();
}
llxHeader();
?>
<h1>
This page is a sample of page using Dolibarr HTML widget methods. It is designed to make test with<br>
- css (edit page to change to test another css)<br>
- jmobile (add parameter dol_use_jmobile=1 to enable view with jmobile)<br>
<br>
- css (add parameter &theme=newtheme to test another theme or edit css of current theme)<br>
- jmobile (add parameter dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)<br>
- no javascript / usage for bind people (add parameter nojs=1 to force disable javascript)<br>
</h1>
<br>
<!-- Output to test html.form.class.php -->
<?php
@@ -47,22 +45,52 @@ print '<br><br>'."\n";
print "Test 3: We must have here 1970-01-01 00:00:00 selected (fields are mandatory)<br>\n";
$form->select_date(dol_get_first_day(1970,1,false), 'test3', 1, 1, 0);
/*print '<br><br>'."\n";
print "Test 4c: a select with ajax refresh<br>\n";
//$array=array(0=>'',1=>'Search into xxx',2=>'Search into yyy',3=>'Search into zzz');
$array=array();
$selected=-1;
print $form->selectArrayAjax(DOL_URL_ROOT.'/core/ajax/selecsearchbox.php', 'testselectc', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
*/
print '<br><br>'."\n";
// Test4: a multiselect
print "Test 4: a multiselect<br>\n";
// Test4: a select
print "Test 4a: a select<br>\n";
$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.');
$selected=3;
print $form->selectarray('testselecta', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
print '<br><br>';
print "Test 4b: a select<br>\n";
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
$selected=3;
print $form->selectarray('testselectb', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
print '<br><br>'."\n";
print "Test 4c: Select array with no js forced<br>\n";
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
print $form->selectarray('selectarray',$array);
print '<br><br>'."\n";
// Test4d: form->select_thirdparty
print "Test 4d: Select thirdparty<br>\n";
print $form->select_thirdparty(0,'thirdpartytest');
print '<br><br>'."\n";
// Test4e: form->select_product
print "Test 4e: Select product (using ajax)<br>\n";
$form->select_produits(0,'producttest');
print '<br><br>'."\n";
// Test5: a multiselect
print "Test 5: a multiselect<br>\n";
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
$arrayselected=array(1,3);
print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, '', 0, 250);
print '<br><br>'."\n";
// Test5: a select
print "Test 5: a select<br>\n";
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
$selected=3;
print $form->selectarray('testselect', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"');
llxFooter();
$db->close();