Skip to content
Snippets Groups Projects
Commit 1907e5da authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #3619 from atm-arnaud/3.6_fix_facturestat

FIX facturestat bad sql when customer view is limited
parents 34adc60d 0b7305d2
No related branches found
No related tags found
No related merge requests found
......@@ -168,7 +168,7 @@ class FactureStats extends Stats
$sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm";
......@@ -188,7 +188,7 @@ class FactureStats extends Stats
$sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year";
$sql.= $this->db->order('year','DESC');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment