From 4ddffc6506aaede1f5ceceba88f9a5a2893aeb09 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 12 Jan 2012 20:37:31 +0100
Subject: [PATCH] Qual: Uniformize code

---
 htdocs/fourn/facture/impayees.php | 26 +++++++++++---------------
 htdocs/fourn/facture/index.php    |  2 +-
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php
index 098d29e4311..fabded05370 100644
--- a/htdocs/fourn/facture/impayees.php
+++ b/htdocs/fourn/facture/impayees.php
@@ -28,8 +28,7 @@ require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php');
 require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
 require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php");
 
-if (!$user->rights->facture->lire)
-accessforbidden();
+if (!$user->rights->facture->lire) accessforbidden();
 
 $langs->load("companies");
 $langs->load("bills");
@@ -76,7 +75,7 @@ if (! $sortorder) $sortorder="ASC";
 
 if ($user->rights->fournisseur->facture->lire)
 {
-	$sql = "SELECT s.nom, s.rowid as socid,";
+	$sql = "SELECT s.rowid as socid, s.nom";
 	$sql.= " f.rowid as ref, f.facnumber, f.total_ht, f.total_ttc,";
 	$sql.= " f.datef as df, f.date_lim_reglement as datelimite, ";
 	$sql.= " f.paye as paye, f.rowid as facid, f.fk_statut";
@@ -127,20 +126,19 @@ if ($user->rights->fournisseur->facture->lire)
 
 	if (dol_strlen($_POST["sf_ref"]) > 0)
 	{
-		$sql .= " AND f.facnumber like '%".$_POST["sf_ref"] . "%'";
+		$sql .= " AND f.facnumber like '%".$_POST["sf_ref"]."%'";
 	}
-	$sql.= " GROUP BY f.facnumber,s.nom, s.rowid, f.rowid, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut";
+	$sql.= " GROUP BY f.facnumber, f.rowid, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, s.rowid, s.nom";
 
 	$sql.= " ORDER BY ";
 	$listfield=explode(',',$sortfield);
 	foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.",";
 	$sql.= " f.facnumber DESC";
 
-	$result = $db->query($sql);
-
-	if ($result)
+	$resql = $db->query($sql);
+	if ($resql)
 	{
-		$num = $db->num_rows($result);
+		$num = $db->num_rows($resql);
 
 		if ($socid)
 		{
@@ -196,11 +194,11 @@ if ($user->rights->fournisseur->facture->lire)
 
 			while ($i < $num)
 			{
-				$objp = $db->fetch_object($result);
+				$objp = $db->fetch_object($resql);
 
 				$var=!$var;
 
-				print "<tr $bc[$var]>";
+				print "<tr ".$bc[$var].">";
 				$classname = "impayee";
 
 				print '<td nowrap>';
@@ -249,7 +247,7 @@ if ($user->rights->fournisseur->facture->lire)
 		}
 
 		print "</table>";
-		$db->free();
+		$db->free($resql);
 	}
 	else
 	{
@@ -259,9 +257,7 @@ if ($user->rights->fournisseur->facture->lire)
 }
 
 
-
+llxFooter();
 
 $db->close();
-
-llxFooter();
 ?>
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index ed084001ef6..372534d9bc0 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -267,7 +267,7 @@ if ($resql)
 
 		// Affiche statut de la facture
 		print '<td align="right" nowrap="nowrap">';
-		// TODO  le montant deja paye obj->am n'est pas definie
+		// TODO  le montant deja paye objp->am n'est pas definie
 		print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am);
 		print '</td>';
 
-- 
GitLab