26 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
27 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
28 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 public $table_element;
63 $this->socid = ($socid > 0 ? $socid : 0);
64 $this->userid = $userid;
65 $this->cachefilesuffix = $mode;
67 if ($mode ==
'customer')
70 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
71 $this->from_line = MAIN_DB_PREFIX.$object->table_element_line.
" as tl";
73 $this->field_line =
'0';
76 if (!$user->rights->societe->client->voir && !$this->socid) $this->where .=
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
77 $this->where .= ($this->where ?
' AND ' :
'').
"c.entity IN (".
getEntity(
'fichinter').
')';
81 $this->where .=
" AND c.fk_soc = ".$this->socid;
83 if ($this->userid > 0) $this->where .=
' AND c.fk_user_author = '.$this->userid;
97 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
98 $sql .=
" FROM ".$this->from;
99 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
101 $sql .=
" AND ".$this->where;
102 $sql .=
" GROUP BY dm";
103 $sql .= $this->
db->order(
'dm',
'DESC');
119 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
120 $sql .=
" FROM ".$this->from;
121 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
122 $sql .=
" WHERE ".$this->where;
123 $sql .=
" GROUP BY dm";
124 $sql .= $this->
db->order(
'dm',
'DESC');
140 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
141 $sql .=
" FROM ".$this->from;
142 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
144 $sql .=
" AND ".$this->where;
145 $sql .=
" GROUP BY dm";
146 $sql .= $this->
db->order(
'dm',
'DESC');
162 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
163 $sql .=
" FROM ".$this->from;
164 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
166 $sql .=
" AND ".$this->where;
167 $sql .=
" GROUP BY dm";
168 $sql .= $this->
db->order(
'dm',
'DESC');
182 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
183 $sql .=
" FROM ".$this->from;
184 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
185 $sql .=
" WHERE ".$this->where;
186 $sql .=
" GROUP BY year";
187 $sql .= $this->
db->order(
'year',
'DESC');
203 $sql =
"SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg";
204 $sql .=
" FROM ".$this->from.
", ".$this->from_line.
", ".MAIN_DB_PREFIX.
"product as product";
206 $sql .=
" WHERE ".$this->where;
207 $sql .=
" AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid";
209 $sql .=
" GROUP BY product.ref";
210 $sql .= $this->
db->order(
'nb',
'DESC');
__construct($db, $socid, $mode, $userid=0)
Constructor.
getAllByYear()
Return nb, total and average.
Parent class of statistics class.
Class to manage interventions.
getAverageByMonth($year)
Return the intervention amount average by month for a year.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
getAmountByMonth($year, $format=0)
Return the intervention amount by month for a year.
$conf db
API class for accounts.
_getAllByProduct($sql, $limit=10)
Return number or total of product refs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
getNbByYear()
Return interventions number per year.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
getNbByMonth($year, $format=0)
Return intervention number by month for a year.
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
getAllByProduct($year, $limit=0)
Return nb, amount of predefined product for year.
_getNbByYear($sql)
Return nb of elements by year.
Class to manage intervention statistics.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...