From 1a1959b52c4f05ae46692fa19d8aa1241249bf4a Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sun, 22 Mar 2015 21:18:25 +0100
Subject: [PATCH] Fix: Solve conflict with imgup and imgdown class use for sort
 fields and to drag and drop lines.

---
 htdocs/core/lib/functions.lib.php       |  12 ++-
 htdocs/core/tpl/ajaxrow.tpl.php         |   8 +-
 htdocs/core/tpl/objectline_view.tpl.php |   4 +-
 htdocs/public/test/test_arrays.php      | 116 +++++++++++++-----------
 htdocs/theme/eldy/style.css.php         |  16 +++-
 htdocs/theme/md_dev/style.css.php       |  14 +++
 6 files changed, 102 insertions(+), 68 deletions(-)

diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index d2ce8023a65..cb3752f817c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2280,15 +2280,16 @@ function img_previous($titlealt = 'default')
  *
  *	@param	string	$titlealt   Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
  *	@param  int		$selected   Selected
+ *  @param	string	$moreclass	Add more CSS classes
  *	@return string      		Return img tag
  */
-function img_down($titlealt = 'default', $selected = 0)
+function img_down($titlealt = 'default', $selected = 0, $moreclass='')
 {
 	global $conf, $langs;
 
 	if ($titlealt == 'default') $titlealt = $langs->trans('Down');
 
-	return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown"');
+	return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass?" ".$moreclass:"").'"');
 }
 
 /**
@@ -2296,15 +2297,16 @@ function img_down($titlealt = 'default', $selected = 0)
  *
  *	@param	string	$titlealt   Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
  *	@param  int		$selected	Selected
+ *  @param	string	$moreclass	Add more CSS classes
  *	@return string      		Return img tag
  */
-function img_up($titlealt = 'default', $selected = 0)
+function img_up($titlealt = 'default', $selected = 0, $moreclass='')
 {
 	global $conf, $langs;
 
 	if ($titlealt == 'default') $titlealt = $langs->trans('Up');
 
-	return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup"');
+	return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass?" ".$moreclass:"").'"');
 }
 
 /**
@@ -2622,7 +2624,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
  *	Get title line of an array
  *
  *	@param	string	$name        Label of field
- *	@param	int		$thead		 0=To use with standard table forat, 1=To use inside <thead><tr>, 2=To use with <div>
+ *	@param	int		$thead		 0=To use with standard table format, 1=To use inside <thead><tr>, 2=To use with <div>
  *	@param	string	$file        Url used when we click on sort picto
  *	@param	string	$field       Field to use for new sorting. Empty if this field is not sortable.
  *	@param	string	$begin       ("" by defaut)
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 27b14d859f3..4b8d82bce40 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -33,8 +33,8 @@ $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
 if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>
 <script type="text/javascript">
 $(document).ready(function(){
-	$(".imgup").hide();
-	$(".imgdown").hide();
+	$(".imgupforline").hide();
+	$(".imgdownforline").hide();
     $(".lineupdown").removeAttr('href');
     $(".tdlineupdown").css("background-image",'url(<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png'; ?>)');
     $(".tdlineupdown").css("background-repeat","no-repeat");
@@ -78,8 +78,8 @@ $(document).ready(function(){
 <?php } else { ?>
 <script>
 $(document).ready(function(){
-	$(".imgup").hide();
-	$(".imgdown").hide();
+	$(".imgupforline").hide();
+	$(".imgdownforline").hide();
     $(".lineupdown").removeAttr('href');
 });
 </script>
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index 1fd86ed871d..8da915ddd9a 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -203,12 +203,12 @@ if (empty($usemargins)) $usemargins=0;
 	<td align="center" class="tdlineupdown"><?php $coldisplay++; ?>
 		<?php if ($i > 0) { ?>
 		<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
-		<?php echo img_up(); ?>
+		<?php echo img_up('default',0,'imgupforline'); ?>
 		</a>
 		<?php } ?>
 		<?php if ($i < $num-1) { ?>
 		<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
-		<?php echo img_down(); ?>
+		<?php echo img_down('default',0,'imgdownforline'); ?>
 		</a>
 		<?php } ?>
 	</td>
diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php
index cae90530d36..ea0791dc984 100644
--- a/htdocs/public/test/test_arrays.php
+++ b/htdocs/public/test/test_arrays.php
@@ -1,5 +1,5 @@
 <?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.
 
 
@@ -12,7 +12,7 @@ if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1')
 }
 
 
-$usedolheader=0;	// 1 = Test inside a dolibarr page, 0 = Use hard coded header
+$usedolheader=1;	// 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>
-
-<body style="padding: 10px;">
-
-<div data-role="page">
-
-<?php
+	?>
+	<!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;">
+
+	<div data-role="page">
+
+	<?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);
 }
 
 
@@ -64,7 +66,7 @@ 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>
+- jmobile (add parameter dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)<br>
 - dataTables<br>
 - tablednd<br>
 </h1>
@@ -111,7 +113,7 @@ 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 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this for tables that are edited forms (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
@@ -238,7 +240,7 @@ $('xxxth').replaceWith(
 
 <table id="idtableexample2" class="centpercent">
 	<thead>
-    <tr>
+    <tr class="liste_titre">
         <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); ?>
@@ -248,62 +250,62 @@ $('xxxth').replaceWith(
     <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>
@@ -313,14 +315,20 @@ $('xxxth').replaceWith(
 <br><hr><br>Example 3 : Standard table => Use this if you need the drag and drop for lines<br>
 
 <?php
-	$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';
+$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';
 ?>
-<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 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 class="pair">a1</td><td class="pair" align="right">b1</td><td class="tdlineupdown pair" align="left">c1</td></tr>
+<tr class="impair"><td class="impair">a2</td><td class="impair" align="right">b2</td><td class="tdlineupdown impair" align="left">c2</td></tr>
 </table>
 <br>
 
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 42bf78a0745..4744f7b630c 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -443,11 +443,13 @@ textarea.centpercent {
 .movable {
 	cursor: move;
 }
-
 .borderrightlight
 {
 	border-right: 1px solid #DDD;
 }
+#formuserfile_link {
+	margin-left: 1px;
+}
 
 /* ============================================================================== */
 /* Styles to hide objects                                                         */
@@ -1906,7 +1908,12 @@ table.liste td {
 	color: #202020;
 }
 
-
+div.liste_titre .tagtd {
+	vertical-align: middle;
+}
+div.liste_titre {
+	min-height: 26px !important;	/* We cant use height because it's a div and it should be higher if content is more. but min-height doe not work either for div */
+}
 tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr
 {
 	height: 26px !important;
@@ -2921,7 +2928,10 @@ div.dolEventError h1, div.dolEventError h2 {
 {
 	text-decoration: underline !important;
 }
-
+.paginate_button
+{
+	font-weight: normal !important;
+}
 /* For jquery plugin combobox */
 /* Disable this. It breaks wrapping of boxes
 .ui-corner-all { white-space: nowrap; } */
diff --git a/htdocs/theme/md_dev/style.css.php b/htdocs/theme/md_dev/style.css.php
index 4d3e0937e4d..7d171d25c3a 100644
--- a/htdocs/theme/md_dev/style.css.php
+++ b/htdocs/theme/md_dev/style.css.php
@@ -455,6 +455,10 @@ textarea.centpercent {
 {
 	border-right: 1px solid #DDD;
 }
+#formuserfile_link {
+	margin-left: 1px;
+}
+
 
 /* ============================================================================== */
 /* Styles to hide objects                                                         */
@@ -1990,6 +1994,12 @@ table.liste td {
 }
 
 
+div.liste_titre .tagtd {
+	vertical-align: middle;
+}
+div.liste_titre {
+	min-height: 26px !important;
+}
 tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr
 {
 	height: 26px !important;
@@ -3019,6 +3029,10 @@ div.dolEventError h1, div.dolEventError h2 {
 {
 	text-decoration: underline !important;
 }
+.paginate_button
+{
+	font-weight: normal !important;
+}
 
 /* For jquery plugin combobox */
 /* Disable this. It breaks wrapping of boxes
-- 
GitLab