From d12f974efd1a9a0b3683eb410511c7799b134498 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 11 Dec 2009 18:30:14 +0000 Subject: [PATCH] Works on multi-company --- htdocs/expedition/index.php | 10 ++++---- htdocs/expedition/liste.php | 2 +- .../stats/expeditionstats.class.php | 24 ++++++++----------- htdocs/expedition/stats/index.php | 10 ++++---- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 548df32107d..3fb81d5e44b 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -70,8 +70,7 @@ if (!$user->rights->societe->client->voir && !$socid) $clause = " AND "; } $sql.= $clause." e.fk_statut = 0"; -$sql.= " AND (e.entity = ".$conf->entity; -$sql.= " AND s.entity = ".$conf->entity.")"; +$sql.= " AND e.entity = ".$conf->entity; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $resql=$db->query($sql); @@ -107,7 +106,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND s.entity = ".$conf->entity; +$sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_statut = 1"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -154,7 +153,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND s.entity = ".$conf->entity; +$sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_statut = 2"; if ($socid) $sql.= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -190,6 +189,7 @@ if ( $resql ) * 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"; @@ -204,7 +204,7 @@ if (!$user->rights->societe->client->voir && !$socid) $clause = " AND "; } $sql.= $clause." e.fk_statut = 1"; -$sql.= " AND s.entity = ".$conf->entity; +$sql.= " AND e.entity = ".$conf->entity; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $sql.= " ORDER BY e.date_expedition DESC"; $sql.= $db->plimit(5, 0); diff --git a/htdocs/expedition/liste.php b/htdocs/expedition/liste.php index b12d70d83b8..54a29a21dc6 100644 --- a/htdocs/expedition/liste.php +++ b/htdocs/expedition/liste.php @@ -67,7 +67,7 @@ else $sql.= " AND el.sourcetype = 'propal'"; } $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -$sql.= " WHERE s.entity = ".$conf->entity; +$sql.= " WHERE 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"; diff --git a/htdocs/expedition/stats/expeditionstats.class.php b/htdocs/expedition/stats/expeditionstats.class.php index 8e3de6754be..8de665a14ee 100644 --- a/htdocs/expedition/stats/expeditionstats.class.php +++ b/htdocs/expedition/stats/expeditionstats.class.php @@ -28,7 +28,7 @@ class ExpeditionStats $this->db = $DB; } /** - * Renvoie le nombre de expedition par ann�e + * Renvoie le nombre de expedition par annee * */ function getNbExpeditionByYear() @@ -36,12 +36,10 @@ class ExpeditionStats global $conf; $result = array(); - $sql = "SELECT count(*), date_format(e.date_expedition,'%Y') as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s "; - $sql.= " WHERE e.fk_statut > 0"; - $sql.= " AND e.fk_soc = s.rowid"; - $sql.= " s.entity = ".$conf->entity; + $sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; + $sql.= " WHERE fk_statut > 0"; + $sql.= " AND entity = ".$conf->entity; $sql.= " GROUP BY dm DESC"; if ($this->db->query($sql)) @@ -60,7 +58,7 @@ class ExpeditionStats return $result; } /** - * Renvoie le nombre de expedition par mois pour une ann�e donn�e + * Renvoie le nombre de expedition par mois pour une annee donnee * */ function getNbExpeditionByMonth($year) @@ -68,13 +66,11 @@ class ExpeditionStats global $conf; $result = array(); - $sql = "SELECT count(*), date_format(e.date_expedition,'%m') as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s "; - $sql.= " WHERE date_format(e.date_expedition,'%Y') = ".$year; + $sql = "SELECT count(*), date_format(date_expedition,'%m') as dm"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; + $sql.= " WHERE date_format(date_expedition,'%Y') = ".$year; $sql.= " AND fk_statut > 0"; - $sql.= " AND e.fk_soc = s.rowid"; - $sql.= " s.entity = ".$conf->entity; + $sql.= " AND entity = ".$conf->entity; $sql.= " GROUP BY dm DESC"; if ($this->db->query($sql)) diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index 6c9f0b36f6d..c47129f3fbe 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -39,12 +39,10 @@ print ''; print ''; print ''; -$sql = "SELECT count(*), date_format(e.date_expedition,'%Y') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s "; -$sql.= " WHERE e.fk_statut > 0"; -$sql.= " AND e.fk_soc = s.rowid"; -$sql.= " s.entity = ".$conf->entity; +$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm"; +$sql.= " FROM ".MAIN_DB_PREFIX."expedition"; +$sql.= " WHERE fk_statut > 0"; +$sql.= " AND entity = ".$conf->entity; $sql.= " GROUP BY dm DESC "; if ($db->query($sql))
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").'