Fix: sql request error

This commit is contained in:
Regis Houssin 2012-07-02 10:14:01 +02:00
parent e300bb0611
commit 96bd81d387

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -222,23 +222,17 @@ else dol_print_error($db);
/* /*
* Last shipments * Last shipments
*/ */
$clause = " WHERE ";
$sql = "SELECT e.rowid, e.ref"; $sql = "SELECT e.rowid, e.ref";
$sql.= ", s.nom, s.rowid as socid"; $sql.= ", s.nom, s.rowid as socid";
$sql.= ", c.ref as commande_ref, c.rowid as commande_id"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $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."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."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"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid) 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;
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
$sql.= $clause." sc.fk_user = " .$user->id; $sql.= " AND e.fk_statut = 1";
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 1";
$sql.= " AND e.entity = ".$conf->entity;
if ($socid) $sql.= " AND c.fk_soc = ".$socid; if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " ORDER BY e.date_delivery DESC"; $sql.= " ORDER BY e.date_delivery DESC";
$sql.= $db->plimit(5, 0); $sql.= $db->plimit(5, 0);
@ -258,7 +252,7 @@ if ($resql)
{ {
$var=!$var; $var=!$var;
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td width=\"20%\"><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowSending"),"sending").' '; print '<tr '.$bc[$var].'><td width="20%"><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowSending"),"sending").' ';
print $obj->ref.'</a></td>'; print $obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td>'; print '<td>';
@ -280,8 +274,7 @@ else dol_print_error($db);
print '</td></tr></table>'; print '</td></tr></table>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>