Fix: Duplicate entry, wrong sort

This commit is contained in:
Laurent Destailleur 2010-08-26 11:48:30 +00:00
parent 0d2b38f994
commit 38cbd12d92

View File

@ -223,7 +223,7 @@ $sql = "SELECT e.rowid, e.ref";
$sql.= ", s.nom, s.rowid as socid";
$sql.= ", c.ref as commande_ref, c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.sourcetype in ('commande')";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid)
@ -235,7 +235,7 @@ if (!$user->rights->societe->client->voir && !$socid)
$sql.= $clause." e.fk_statut = 1";
$sql.= " AND e.entity = ".$conf->entity;
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " ORDER BY e.date_expedition DESC";
$sql.= " ORDER BY e.date_delivery DESC";
$sql.= $db->plimit(5, 0);
$resql = $db->query($sql);