From b4733e043cfde64234a382a88e0037b472fc77d9 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Fri, 20 Jan 2017 12:17:10 +0100
Subject: [PATCH] Fix tooltip when customer is closed

---
 htdocs/comm/card.php              | 14 +++++++++-----
 htdocs/langs/en_US/companies.lang |  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index a639fea53ea..d37cb327ec5 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -1007,7 +1007,15 @@ if ($id > 0)
     
     		if (! empty($conf->facture->enabled))
     		{
-    			if ($user->rights->facture->creer && $object->status==1)
+    			if (empty($user->rights->facture->creer))
+    			{
+    			    print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
+    			}
+    			else if ($object->status != 1)
+    			{
+    			    print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
+    			}
+    			else
     			{
     				$langs->load("bills");
     				$langs->load("orders");
@@ -1022,10 +1030,6 @@ if ($id > 0)
     				else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
     
     			}
-    			else
-    			{
-    				print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
-    			}
     		}
     	}
     
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 553e4d884e8..49c409d81e8 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -388,6 +388,7 @@ LastModifiedThirdParties=Latest %s modified third parties
 UniqueThirdParties=Total of unique third parties
 InActivity=Open
 ActivityCeased=Closed
+ThirdPartyIsClosed=Third party is closed
 ProductsIntoElements=List of products/services into %s
 CurrentOutstandingBill=Current outstanding bill
 OutstandingBill=Max. for outstanding bill
-- 
GitLab