Works on multi-company
This commit is contained in:
parent
a5b1f447e6
commit
d12f974efd
@ -70,8 +70,7 @@ if (!$user->rights->societe->client->voir && !$socid)
|
|||||||
$clause = " AND ";
|
$clause = " AND ";
|
||||||
}
|
}
|
||||||
$sql.= $clause." e.fk_statut = 0";
|
$sql.= $clause." e.fk_statut = 0";
|
||||||
$sql.= " AND (e.entity = ".$conf->entity;
|
$sql.= " AND e.entity = ".$conf->entity;
|
||||||
$sql.= " AND s.entity = ".$conf->entity.")";
|
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
@ -107,7 +106,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$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";
|
$sql.= " AND c.fk_statut = 1";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
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;
|
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";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$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";
|
$sql.= " AND c.fk_statut = 2";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
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;
|
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
|
* Last shipments
|
||||||
*/
|
*/
|
||||||
$clause = " WHERE ";
|
$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";
|
||||||
@ -204,7 +204,7 @@ if (!$user->rights->societe->client->voir && !$socid)
|
|||||||
$clause = " AND ";
|
$clause = " AND ";
|
||||||
}
|
}
|
||||||
$sql.= $clause." e.fk_statut = 1";
|
$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;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
$sql.= " ORDER BY e.date_expedition DESC";
|
$sql.= " ORDER BY e.date_expedition DESC";
|
||||||
$sql.= $db->plimit(5, 0);
|
$sql.= $db->plimit(5, 0);
|
||||||
|
|||||||
@ -67,7 +67,7 @@ else
|
|||||||
$sql.= " AND el.sourcetype = 'propal'";
|
$sql.= " AND el.sourcetype = 'propal'";
|
||||||
}
|
}
|
||||||
$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";
|
||||||
$sql.= " WHERE s.entity = ".$conf->entity;
|
$sql.= " WHERE e.entity = ".$conf->entity;
|
||||||
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.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class ExpeditionStats
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Renvoie le nombre de expedition par ann<EFBFBD>e
|
* Renvoie le nombre de expedition par annee
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getNbExpeditionByYear()
|
function getNbExpeditionByYear()
|
||||||
@ -36,12 +36,10 @@ class ExpeditionStats
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$sql = "SELECT count(*), date_format(e.date_expedition,'%Y') as dm";
|
$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s ";
|
$sql.= " WHERE fk_statut > 0";
|
||||||
$sql.= " WHERE e.fk_statut > 0";
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$sql.= " AND e.fk_soc = s.rowid";
|
|
||||||
$sql.= " s.entity = ".$conf->entity;
|
|
||||||
$sql.= " GROUP BY dm DESC";
|
$sql.= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
@ -60,7 +58,7 @@ class ExpeditionStats
|
|||||||
return $result;
|
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)
|
function getNbExpeditionByMonth($year)
|
||||||
@ -68,13 +66,11 @@ class ExpeditionStats
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$sql = "SELECT count(*), date_format(e.date_expedition,'%m') as dm";
|
$sql = "SELECT count(*), date_format(date_expedition,'%m') as dm";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s ";
|
$sql.= " WHERE date_format(date_expedition,'%Y') = ".$year;
|
||||||
$sql.= " WHERE date_format(e.date_expedition,'%Y') = ".$year;
|
|
||||||
$sql.= " AND fk_statut > 0";
|
$sql.= " AND fk_statut > 0";
|
||||||
$sql.= " AND e.fk_soc = s.rowid";
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$sql.= " s.entity = ".$conf->entity;
|
|
||||||
$sql.= " GROUP BY dm DESC";
|
$sql.= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
|
|||||||
@ -39,12 +39,10 @@ print '<table class="border" width="100%">';
|
|||||||
print '<tr><td align="center">'.$langs->trans("Year").'</td>';
|
print '<tr><td align="center">'.$langs->trans("Year").'</td>';
|
||||||
print '<td width="40%" align="center">'.$langs->trans("NbOfSendings").'</td></tr>';
|
print '<td width="40%" align="center">'.$langs->trans("NbOfSendings").'</td></tr>';
|
||||||
|
|
||||||
$sql = "SELECT count(*), date_format(e.date_expedition,'%Y') as dm";
|
$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s ";
|
$sql.= " WHERE fk_statut > 0";
|
||||||
$sql.= " WHERE e.fk_statut > 0";
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$sql.= " AND e.fk_soc = s.rowid";
|
|
||||||
$sql.= " s.entity = ".$conf->entity;
|
|
||||||
$sql.= " GROUP BY dm DESC ";
|
$sql.= " GROUP BY dm DESC ";
|
||||||
|
|
||||||
if ($db->query($sql))
|
if ($db->query($sql))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user