From bf7a6380c90dcb8e80e61552fe82c16da763ea47 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 1 Sep 2016 01:00:28 +0200
Subject: [PATCH] Fix sort on wrong field

---
 htdocs/core/boxes/box_contracts.php | 8 +++++---
 htdocs/langs/en_US/boxes.lang       | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php
index 40cc8885f90..fe864e1df16 100644
--- a/htdocs/core/boxes/box_contracts.php
+++ b/htdocs/core/boxes/box_contracts.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2010 Regis Houssin  <regis.houssin@capnetworks.com>
- * Copyright (C) 2015      Frederic France      <frederic.france@free.fr>
+/* Copyright (C) 2010 Regis Houssin        <regis.houssin@capnetworks.com>
+ * Copyright (C) 2015 Frederic France      <frederic.france@free.fr>
+ * Copyright (C) 2016 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -71,7 +72,8 @@ class box_contracts extends ModeleBoxes
     		$sql.= " AND c.entity = ".$conf->entity;
     		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
     		if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
-    		$sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
+    		if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC ";
+    		else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
     		$sql.= $db->plimit($max, 0);
 
     		$resql = $db->query($sql);
diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang
index 0cd7cac6a6b..98970318e85 100644
--- a/htdocs/langs/en_US/boxes.lang
+++ b/htdocs/langs/en_US/boxes.lang
@@ -38,7 +38,7 @@ BoxMyLastBookmarks=My latest %s bookmarks
 BoxOldestExpiredServices=Oldest active expired services
 BoxLastExpiredServices=Latest %s oldest contacts with active expired services
 BoxTitleLastActionsToDo=Latest %s actions to do
-BoxTitleLastContracts=Latest %s contracts
+BoxTitleLastContracts=Latest %s modified contracts
 BoxTitleLastModifiedDonations=Latest %s modified donations
 BoxTitleLastModifiedExpenses=Latest %s modified expense reports
 BoxGlobalActivity=Global activity (invoices, proposals, orders)
-- 
GitLab