From 407b9bb7953eb9b42b2accc511dead520dd765d8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 30 Aug 2011 17:56:45 +0000 Subject: [PATCH] Possibility to use thead tag --- htdocs/lib/functions.lib.php | 117 +++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 45 deletions(-) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 54ff2adf317..76deaccd75e 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2534,7 +2534,6 @@ function dol_print_error_email() print '
'.$langs->trans("ErrorContactEMail",$conf->global->MAIN_INFO_SOCIETE_MAIL,'ERRORNEWPAYMENT'.dol_print_date(mktime(),'%Y%m%d')).'
'; } - /** * Show title line of an array * @param name Label of field @@ -2547,58 +2546,86 @@ function dol_print_error_email() * @param sortorder Current sort order */ function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="") +{ + print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder); +} + +/** + * Get title line of an array + * @param name Label of field + * @param thead For thead format + * @param file Url used when we click on sort picto + * @param field Field to use for new sorting + * @param begin ("" by defaut) + * @param moreparam Add more parameters on sort url links ("" by default) + * @param td Options of attribute td ("" by defaut) + * @param sortfield Current field used to sort + * @param sortorder Current sort order + */ +function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="") { global $conf; //print "$name, $file, $field, $begin, $options, $td, $sortfield, $sortorder
\n"; - - // Le champ de tri est mis en evidence. - // Exemple si (sortfield,field)=("nom","xxx.nom") ou (sortfield,field)=("nom","nom") - if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) + + $out=''; + + if ($thead) { - print ''; + $out.= ''.$name.''; } else { - print ''; + // Le champ de tri est mis en evidence. + // Exemple si (sortfield,field)=("nom","xxx.nom") ou (sortfield,field)=("nom","nom") + if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) + { + $out.= ''; + } + else + { + $out.= ''; + } + $out.= $name; + + // If this is a sort field + if ($field) + { + $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); + $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); + $options=preg_replace('/&+/i','&',$options); + if (! preg_match('/^&/',$options)) $options='&'.$options; + + //print " "; + $out.= ''; + if (! $sortorder) + { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",0).''; + } + else + { + if ($field != $sortfield) + { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",0).''; + } + else { + $sortorder=strtoupper($sortorder); + if ($sortorder == 'DESC' ) { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",1).''; + } + if ($sortorder == 'ASC' ) { + $out.= ''.img_down("A-Z",1).''; + $out.= ''.img_up("Z-A",0).''; + } + } + } + } + $out.= ""; } - print $name; - - // If this is a sort field - if ($field) - { - $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); - $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); - $options=preg_replace('/&+/i','&',$options); - if (! preg_match('/^&/',$options)) $options='&'.$options; - - //print " "; - print ''; - if (! $sortorder) - { - print ''.img_down("A-Z",0).''; - print ''.img_up("Z-A",0).''; - } - else - { - if ($field != $sortfield) - { - print ''.img_down("A-Z",0).''; - print ''.img_up("Z-A",0).''; - } - else { - $sortorder=strtoupper($sortorder); - if ($sortorder == 'DESC' ) { - print ''.img_down("A-Z",0).''; - print ''.img_up("Z-A",1).''; - } - if ($sortorder == 'ASC' ) { - print ''.img_down("A-Z",1).''; - print ''.img_up("Z-A",0).''; - } - } - } - } - print ""; + + return $out; } /**