Fix: Tri des dernières facture était à l'envers

This commit is contained in:
Laurent Destailleur 2005-10-15 13:52:16 +00:00
parent c3c86a6b9e
commit d1a45ad24d

View File

@ -19,7 +19,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -194,35 +193,37 @@ if ( $societe->fetch($socid) )
} }
/* /*
*
* Liste des commandes associées * Liste des commandes associées
*
*/ */
$max=4;
$sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; $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.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
$sql.= " WHERE p.fk_soc =".$societe->id; $sql.= " WHERE p.fk_soc =".$societe->id;
$sql .= " ORDER BY p.rowid DESC LIMIT 4"; $sql.= " ORDER BY p.rowid";
if ( $db->query($sql) ) $sql.= " ".$db->plimit($max);
$resql=$db->query($sql);
if ($resql)
{ {
$i = 0 ; $i = 0 ;
$num = $db->num_rows(); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0)
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print "<td colspan=\"2\"><a href=\"commande/liste.php?socid=$societe->id\">".$langs->trans("LastOrders",$num)."</td></tr>"; print '<td colspan="3">';
print '<table class="noborder" width="100%"><tr><td>'.$langs->trans("LastOrders",min($num,$max)).'</td>';
print '<td align="right"><a href="commande/liste.php?socid='.$societe->id.'">'.$langs->trans("AllOrders").' ('.$num.')</td></tr></table>';
print '</td></tr>';
} }
while ($i < $num && $i < 5) while ($i < $num && $i <= $max)
{ {
$obj = $db->fetch_object(); $obj = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'; print '<td><a href="commande/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.'</a></td>';
print '<img src="commande/statut'.$obj->fk_statut.'.png">&nbsp;'; print '<td align="center" width="80">';
print '<a href="commande/fiche.php?id='.$obj->rowid.'">';
print $obj->ref.'</a></td>';
print "<td align=\"right\" width=\"100\">";
if ($obj->dc) if ($obj->dc)
{ {
print dolibarr_print_date($obj->dc); print dolibarr_print_date($obj->dc);
@ -231,11 +232,14 @@ if ( $societe->fetch($socid) )
{ {
print "-"; print "-";
} }
print "</td></tr>"; print '</td>';
print '<td width="20"><img src="commande/statut'.$obj->fk_statut.'.png"></td>';
print '</tr>';
$i++; $i++;
} }
$db->free(); $db->free($resql);
if ($num > 0) { if ($num > 0)
{
print "</table><br>"; print "</table><br>";
} }
} }
@ -254,7 +258,9 @@ if ( $societe->fetch($socid) )
$sql = "SELECT p.rowid,p.libelle,p.facnumber,p.fk_statut,".$db->pdate("p.datef")." as df, total_ttc as amount, paye"; $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.= " FROM ".MAIN_DB_PREFIX."facture_fourn as p WHERE p.fk_soc = $societe->id";
$sql .= " ORDER BY p.datef"; $sql.= " ORDER BY p.datef DESC";
$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -268,7 +274,6 @@ if ( $societe->fetch($socid) )
print "<table class=\"noborder\" width=\"100%\"><tr><td>".$langs->trans("LastSuppliersBills",min($num,$max))."</td><td align=\"right\"><a href=\"facture/index.php?socid=$societe->id\">".$langs->trans("AllBills")." (".$num.")</td></tr></table>"; print "<table class=\"noborder\" width=\"100%\"><tr><td>".$langs->trans("LastSuppliersBills",min($num,$max))."</td><td align=\"right\"><a href=\"facture/index.php?socid=$societe->id\">".$langs->trans("AllBills")." (".$num.")</td></tr></table>";
print "</td></tr>"; print "</td></tr>";
} }
while ($i < $num && $i < $max) while ($i < $num && $i < $max)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -286,7 +291,8 @@ if ( $societe->fetch($socid) )
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
if ($num > 0) { if ($num > 0)
{
print "</table><br>"; print "</table><br>";
} }
} }
@ -339,7 +345,10 @@ if ( $societe->fetch($socid) )
print "<td align=\"center\"><a href=\"".DOL_URL_ROOT.'/contact/fiche.php?socid='.$socid."&amp;action=create\">".$langs->trans("AddContact")."</a></td></tr>"; print "<td align=\"center\"><a href=\"".DOL_URL_ROOT.'/contact/fiche.php?socid='.$socid."&amp;action=create\">".$langs->trans("AddContact")."</a></td></tr>";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; $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); $result = $db->query($sql);
$i = 0 ; $i = 0 ;