From 9f52b9e800fde722b57677c11c78774583261647 Mon Sep 17 00:00:00 2001
From: phf <phf@atm-consulting.fr>
Date: Fri, 29 May 2015 17:27:05 +0200
Subject: [PATCH] FIX : #2901

---
 htdocs/compta/dons/card.php            | 10 +++++++++-
 htdocs/compta/dons/class/don.class.php |  5 +++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php
index 7bf909378b4..41b129a4cc6 100644
--- a/htdocs/compta/dons/card.php
+++ b/htdocs/compta/dons/card.php
@@ -554,7 +554,15 @@ if (! empty($id) && $action != 'edit')
 
 	if ($user->rights->don->supprimer)
 	{
-		print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$don->id.'&action=delete">'.$langs->trans("Delete")."</a></div>";
+		if ($don->statut == -1 || $don->statut == 0)
+		{
+			print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$don->id.'&action=delete">'.$langs->trans("Delete")."</a></div>";
+		}
+		else
+		{
+			print '<div class="inline-block divButAction"><a class="butActionDelete butActionRefused" href="#">'.$langs->trans("Delete")."</a></div>";
+		}
+		
 	}
 	else
 	{
diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php
index a8f7c11d92b..06d383e1c50 100644
--- a/htdocs/compta/dons/class/don.class.php
+++ b/htdocs/compta/dons/class/don.class.php
@@ -449,10 +449,11 @@ class Don extends CommonObject
      */
     function delete($rowid)
     {
-
+		global $user;
+		
         $this->db->begin();
 
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0 OR fk_statut = -1";
 
         $resql=$this->db->query($sql);
         if ($resql)
-- 
GitLab