From a669b61b69760e6a60b6e82d550a717f1c19f455 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 5 Jul 2016 18:33:13 +0200
Subject: [PATCH] Code comment

---
 htdocs/compta/facture/list.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 989aa6a6692..0e9c6874103 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -699,7 +699,13 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company);
 if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
 if ($search_montant_vat != '') $sql.= natural_search('f.total_vat', $search_montant_vat, 1);
 if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
-if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status);
+if ($search_status != '' && $search_status >= 0)
+{
+    if ($search_status == '0') $sql.=" AND f.fk_statut = 0";  // draft
+    if ($search_status == '1') $sql.=" AND f.fk_statut = 1";  // unpayed
+    if ($search_status == '2') $sql.=" AND f.fk_statut = 2";  // payed     Not that some correupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
+    if ($search_status == '3') $sql.=" AND f.fk_statut = 3";  // abandonned
+}
 if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode."";
 if ($month > 0)
 {
-- 
GitLab