Propale stats: reworking of the fix to comply with travis rule for SQL string building
This commit is contained in:
parent
c3e42f1961
commit
b29ebef05f
@ -247,19 +247,18 @@ class PropaleStats extends Stats
|
||||
{
|
||||
global $user;
|
||||
|
||||
$sql = 'SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.' . $this->field_line . ') as total, AVG(tl.' . $this->field_line . ') as avg';
|
||||
$sql .= ' FROM ' . $this->from;
|
||||
$sql .= ' INNER JOIN ' . $this->from_line . ' ON p.rowid = tl.fk_propal';
|
||||
$sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'product as product ON tl.fk_product = product.rowid';
|
||||
if (empty($user->rights->societe->client->voir) && ! $user->socid) {
|
||||
$sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ' . ((int) $user->id);
|
||||
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
|
||||
$sql .= " FROM ".$this->from;
|
||||
$sql .= " INNER JOIN ".$this->from_line." ON p.rowid = tl.fk_propal";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
$sql .= $this->join;
|
||||
$sql .= ' WHERE ' . $this->where;
|
||||
$sql .= ' AND ' . $this->field_date . " BETWEEN '" . $this->db->idate(dol_get_first_day($year, 1, false)) . "' AND '" . $this->db->idate(dol_get_last_day($year, 12, false)) . "'";
|
||||
$sql .= ' GROUP BY product.ref';
|
||||
$sql .= " WHERE ".$this->where;
|
||||
$sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
|
||||
$sql .= " GROUP BY product.ref";
|
||||
$sql .= $this->db->order('nb', 'DESC');
|
||||
|
||||
//$sql.= $this->db->plimit(20);
|
||||
|
||||
return $this->_getAllByProduct($sql, $limit);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user