diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index bb635323c85..619e48405f7 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,23 +222,17 @@ else dol_print_error($db); /* * Last shipments */ -$clause = " WHERE "; - $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 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."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 AND el.targettype IN ('shipping')"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -if (!$user->rights->societe->client->voir && !$socid) -{ - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql.= $clause." sc.fk_user = " .$user->id; - $clause = " AND "; -} -$sql.= $clause." e.fk_statut = 1"; -$sql.= " AND e.entity = ".$conf->entity; +if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; +$sql.= " WHERE e.entity = ".$conf->entity; +if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id; +$sql.= " AND e.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $sql.= " ORDER BY e.date_delivery DESC"; $sql.= $db->plimit(5, 0); @@ -258,7 +252,7 @@ if ($resql) { $var=!$var; $obj = $db->fetch_object($resql); - print "rowid\">".img_object($langs->trans("ShowSending"),"sending").' '; + print ''.img_object($langs->trans("ShowSending"),"sending").' '; print $obj->ref.''; print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; print ''; @@ -280,8 +274,7 @@ else dol_print_error($db); print ''; -$db->close(); llxFooter(); - +$db->close(); ?>