From d1a45ad24d0c9d5fe3eee7a010a778abfefe1db9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Oct 2005 13:52:16 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Tri=20des=20derni=E8res=20facture=20=E9t?= =?UTF-8?q?ait=20=E0=20l'envers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/fiche.php | 203 +++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 97 deletions(-) diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index 361863e36cb..01c3219356c 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -19,14 +19,13 @@ * * $Id$ * $Source$ - * */ /** - \file htdocs/fourn/fiche.php - \ingroup fournisseur, facture - \brief Page de fiche fournisseur - \version $Revision$ + \file htdocs/fourn/fiche.php + \ingroup fournisseur, facture + \brief Page de fiche fournisseur + \version $Revision$ */ require("./pre.inc.php"); @@ -193,106 +192,113 @@ if ( $societe->fetch($socid) ) print '
'; } - /* - * - * Liste des commandes associées - * - */ - $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; - $sql .= " WHERE p.fk_soc =".$societe->id; - $sql .= " ORDER BY p.rowid DESC LIMIT 4"; - if ( $db->query($sql) ) + /* + * Liste des commandes associées + */ + $max=4; + + $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " WHERE p.fk_soc =".$societe->id; + $sql.= " ORDER BY p.rowid"; + $sql.= " ".$db->plimit($max); + $resql=$db->query($sql); + if ($resql) { - $i = 0 ; - $num = $db->num_rows(); - if ($num > 0) - { - print ''; - print ''; - print ""; - } - while ($i < $num && $i < 5) - { - $obj = $db->fetch_object(); - $var=!$var; - - print ""; - print ''; - print ""; - $i++; - } - $db->free(); - if ($num > 0) { - print "
id\">".$langs->trans("LastOrders",$num)."
'; - print ' '; - print ''; - print $obj->ref.'"; - if ($obj->dc) - { - print dolibarr_print_date($obj->dc); - } - else - { - print "-"; - } - print "

"; - } + $i = 0 ; + $num = $db->num_rows($resql); + if ($num > 0) + { + print ''; + print ''; + print ''; + } + while ($i < $num && $i <= $max) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + print ''; + print ''; + print ''; + print ''; + $i++; + } + $db->free($resql); + if ($num > 0) + { + print "
'; + print ''; + print '
'.$langs->trans("LastOrders",min($num,$max)).''.$langs->trans("AllOrders").' ('.$num.')
'; + print '
'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; + if ($obj->dc) + { + print dolibarr_print_date($obj->dc); + } + else + { + print "-"; + } + print '

"; + } } - else + else { - dolibarr_print_error($db); + dolibarr_print_error($db); } - /* - * Liste des factures associées - */ - $langs->load("bills"); - - $max=5; - - $sql = "SELECT p.rowid,p.libelle,p.facnumber,p.fk_statut,".$db->pdate("p.datef")." as df, total_ttc as amount, paye"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as p WHERE p.fk_soc = $societe->id"; - $sql .= " ORDER BY p.datef"; - $resql=$db->query($sql); - if ($resql) + /* + * Liste des factures associées + */ + $langs->load("bills"); + + $max=5; + + $sql = "SELECT p.rowid,p.libelle,p.facnumber,p.fk_statut,".$db->pdate("p.datef")." as df, total_ttc as amount, paye"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as p WHERE p.fk_soc = $societe->id"; + $sql.= " ORDER BY p.datef DESC"; + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); + + $resql=$db->query($sql); + if ($resql) { - $i = 0 ; - $num = $db->num_rows($resql); - if ($num > 0) - { - print ''; - print ''; - print ""; - } - - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - print ""; - print ''; - print ""; - print ''; - $fac = new FactureFournisseur($db); - print ''; - print ""; - $i++; - } - $db->free($resql); - if ($num > 0) { - print "
"; - print "
".$langs->trans("LastSuppliersBills",min($num,$max))."id\">".$langs->trans("AllBills")." (".$num.")
"; - print "
'; - print ''; - print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.' '.dolibarr_trunc($obj->libelle,14).'".dolibarr_print_date($obj->df)."'.$obj->amount.''.$fac->LibStatut($obj->paye,$obj->fk_statut).'

"; - } + $i = 0 ; + $num = $db->num_rows($resql); + if ($num > 0) + { + print ''; + print ''; + print ""; + } + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + print ''; + print ""; + print ''; + $fac = new FactureFournisseur($db); + print ''; + print ""; + $i++; + } + $db->free($resql); + if ($num > 0) + { + print "
"; + print "
".$langs->trans("LastSuppliersBills",min($num,$max))."id\">".$langs->trans("AllBills")." (".$num.")
"; + print "
'; + print ''; + print img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber.' '.dolibarr_trunc($obj->libelle,14).'".dolibarr_print_date($obj->df)."'.$obj->amount.''.$fac->LibStatut($obj->paye,$obj->fk_statut).'

"; + } } - else + else { - dolibarr_print_error($db); + dolibarr_print_error($db); } /* @@ -339,7 +345,10 @@ if ( $societe->fetch($socid) ) print "".$langs->trans("AddContact").""; $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $societe->id ORDER by p.datec"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql.= " WHERE p.fk_soc = ".$societe->id; + $sql.= " ORDER by p.datec"; + $result = $db->query($sql); $i = 0 ;