From a27ed541284b4849c002e4085b37a0750665f9dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 16:40:48 +0100 Subject: [PATCH] Fix sort order of email templates --- htdocs/core/class/html.formmail.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6e25c1ca730..04f4aa020a3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -999,7 +999,8 @@ class FormMail extends Form if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; - $sql.= $db->order("position,lang,label","ASC"); + if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + else $sql.= $db->order("position,lang,label","ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined if ($id == -1) $sql.= $db->plimit(1); //print $sql;