From 45bcd1c3bfc1dff0bbdc0633b0ec704925211354 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2020 01:50:53 +0100 Subject: [PATCH] Code simpler --- htdocs/core/tpl/contacts.tpl.php | 78 ++------------------------------ 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index b7b1ed32a51..8a4647264c6 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -236,27 +236,8 @@ $sortorder = GETPOST("sortorder", 'alpha'); if (!$sortfield) $sortfield = "nature"; if (!$sortorder) $sortorder = "asc"; -/** - * Re-sort list - */ - -// TODO: switch to $db->sort($sortfield, $sortorder); -if($sortorder == "asc") -{ - if($sortfield == "nature") usort($list, "nature_asc"); - if($sortfield == "thirdparty") usort($list, "thirdparty_asc"); - if($sortfield == "contact") usort($list, "contact_asc"); - if($sortfield == "type") usort($list, "type_asc"); - if($sortfield == "status") usort($list, "status_asc"); -} -else -{ - if($sortfield == "nature") usort($list, "nature_desc"); - if($sortfield == "thirdparty") usort($list, "thirdparty_desc"); - if($sortfield == "contact") usort($list, "contact_desc"); - if($sortfield == "type") usort($list, "type_desc"); - if($sortfield == "status") usort($list, "status_desc"); -} +// Re-sort list +$list = dol_sort_array($list, $sortfield, $sortorder, 1, 0, 1); $arrayfields = array( 'rowid' => array('label'=>$langs->trans("Id"), 'checked'=>1), @@ -291,7 +272,7 @@ print_liste_field_titre($arrayfields['nature']['label'], $_SERVER["PHP_SELF"], " print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"], "thirdparty", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch '); print ""; @@ -303,7 +284,7 @@ foreach($list as $entry) print ''.$entry->thirdparty.''; print ''.$entry->contact.''; print ''.$entry->type.''; - print ''.$entry->status.''; + print ''.$entry->status.''; if ($permission) { @@ -335,54 +316,3 @@ if (is_object($hookmanager)) { } print "\n"; - -// TODO: Remove this functions after switch to $db->sort($sortfield, $sortorder); -function nature_asc($left, $right) -{ - return $left->nature > $right->nature; -} - -function thirdparty_asc($left, $right) -{ - return $left->thirdparty > $right->thirdparty; -} - -function contact_asc($left, $right) -{ - return $left->contact > $right->contact; -} - -function type_asc($left, $right) -{ - return $left->type > $right->type; -} - -function status_asc($left, $right) -{ - return $left->status > $right->status; -} - -function nature_desc($left, $right) -{ - return $left->nature < $right->nature; -} - -function thirdparty_desc($left, $right) -{ - return $left->thirdparty < $right->thirdparty; -} - -function contact_desc($left, $right) -{ - return $left->contact < $right->contact; -} - -function type_desc($left, $right) -{ - return $left->type < $right->type; -} - -function status_desc($left, $right) -{ - return $left->status < $right->status; -}