From ca6ce2ba8b0aa8fcb4568ce74646b13cc3d30393 Mon Sep 17 00:00:00 2001
From: arnaud <arnaud.saint-patrice@atm-consulting.fr>
Date: Fri, 30 Jun 2017 10:38:54 +0200
Subject: [PATCH] FIX status were wrong on product referent list

---
 htdocs/compta/facture/list.php   |  8 ++++----
 htdocs/product/stats/facture.php | 13 +++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 1d0a5ad7e9f..4ce8e0ed724 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1431,10 +1431,10 @@ if ($resql)
             // Status
             if (! empty($arrayfields['f.fk_statut']['checked']))
             {
-                print '<td align="right" class="nowrap">';
-                print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type);
-                print "</td>";
-                if (! $i) $totalarray['nbfield']++;
+            	print '<td align="right" class="nowrap">';
+            	print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type);
+            	print "</td>";
+            	if (! $i) $totalarray['nbfield']++;
             }
             
     		// Action column
diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php
index e9eb3d41859..e8fd04ac818 100644
--- a/htdocs/product/stats/facture.php
+++ b/htdocs/product/stats/facture.php
@@ -141,7 +141,7 @@ if ($id > 0 || ! empty($ref))
         elseif ($user->rights->facture->lire) 
         {
             $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
-            $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,";
+            $sql.= " f.facnumber, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
             $sql.= " d.rowid, d.total_ht as total_ht, d.qty";           // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
             if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
             $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
@@ -232,23 +232,24 @@ if ($id > 0 || ! empty($ref))
                     $var=True;
                     while ($i < min($num,$conf->liste_limit))
 					{
-                        $objp = $db->fetch_object($result);
+						$objp = $db->fetch_object($result);
+						$invoicestatic->id=$objp->facid;
+						$invoicestatic->ref=$objp->facnumber;
+						$societestatic->fetch($objp->socid);
+						$paiement = $invoicestatic->getSommePaiement();
                         $var=!$var;
 
                         print '<tr '.$bc[$var].'>';
                         print '<td>';
-                        $invoicestatic->id=$objp->facid;
-                        $invoicestatic->ref=$objp->facnumber;
                         print $invoicestatic->getNomUrl(1);
                         print "</td>\n";
-                        $societestatic->fetch($objp->socid);
                         print '<td>'.$societestatic->getNomUrl(1).'</td>';
                         print "<td>".$objp->code_client."</td>\n";
                         print '<td align="center">';
                         print dol_print_date($db->jdate($objp->datef),'day')."</td>";
                         print '<td align="center">'.$objp->qty."</td>\n";
                         print '<td align="right">'.price($objp->total_ht)."</td>\n";
-                        print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
+                        print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'</td>';
                         print "</tr>\n";
                         $i++;
 
-- 
GitLab