Works on multi-company

This commit is contained in:
Regis Houssin 2009-12-11 18:30:14 +00:00
parent a5b1f447e6
commit d12f974efd
4 changed files with 20 additions and 26 deletions

View File

@ -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);

View File

@ -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";

View File

@ -28,7 +28,7 @@ class ExpeditionStats
$this->db = $DB;
}
/**
* Renvoie le nombre de expedition par ann<EFBFBD>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<EFBFBD>e donn<EFBFBD>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))

View File

@ -39,12 +39,10 @@ print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("Year").'</td>';
print '<td width="40%" align="center">'.$langs->trans("NbOfSendings").'</td></tr>';
$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))