26include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
28include_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') {
69 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
70 $this->from_line = MAIN_DB_PREFIX.$object->table_element_line.
" as tl";
72 $this->field_line =
'0';
75 if (!$user->hasRight(
'societe',
'client',
'voir')) {
76 $this->where .= (!empty($this->where) ?
' AND ' :
'').
" c.fk_soc = sc.fk_soc AND sc.fk_user = ".((
int) $user->id);
78 $this->where .= ($this->where ?
' AND ' :
'').
"c.entity IN (".
getEntity(
'intervention').
')';
81 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
83 if ($this->userid > 0) {
84 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
99 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
100 $sql .=
" FROM ".$this->from;
101 if (!$user->hasRight(
'societe',
'client',
'voir')) {
102 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
105 $sql .=
" AND ".$this->where;
106 $sql .=
" GROUP BY dm";
107 $sql .= $this->db->order(
'dm',
'DESC');
123 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
124 $sql .=
" FROM ".$this->from;
125 if (!$user->hasRight(
'societe',
'client',
'voir')) {
126 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
128 $sql .=
" WHERE ".$this->where;
129 $sql .=
" GROUP BY dm";
130 $sql .= $this->db->order(
'dm',
'DESC');
146 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
147 $sql .=
" FROM ".$this->from;
148 if (!$user->hasRight(
'societe',
'client',
'voir')) {
149 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
152 $sql .=
" AND ".$this->where;
153 $sql .=
" GROUP BY dm";
154 $sql .= $this->db->order(
'dm',
'DESC');
170 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
171 $sql .=
" FROM ".$this->from;
172 if (!$user->hasRight(
'societe',
'client',
'voir')) {
173 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
176 $sql .=
" AND ".$this->where;
177 $sql .=
" GROUP BY dm";
178 $sql .= $this->db->order(
'dm',
'DESC');
192 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
193 $sql .=
" FROM ".$this->from;
194 if (!$user->hasRight(
'societe',
'client',
'voir')) {
195 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
197 $sql .=
" WHERE ".$this->where;
198 $sql .=
" GROUP BY year";
199 $sql .= $this->db->order(
'year',
'DESC');
215 $sql =
"SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg";
216 $sql .=
" FROM ".$this->from.
", ".$this->from_line.
", ".MAIN_DB_PREFIX.
"product as product";
218 $sql .=
" WHERE ".$this->where;
219 $sql .=
" AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid";
221 $sql .=
" GROUP BY product.ref";
222 $sql .= $this->db->order(
'nb',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage interventions.
Class to manage intervention statistics.
__construct($db, $socid, $mode, $userid=0)
Constructor.
getNbByYear()
Return interventions number per year.
getAmountByMonth($year, $format=0)
Return the intervention amount by month for a year.
getAverageByMonth($year)
Return the intervention amount average by month for a year.
getAllByYear()
Return nb, total and average.
getNbByMonth($year, $format=0)
Return intervention number by month for a year.
getAllByProduct($year, $limit=0)
Return nb, amount of predefined product for year.
Parent class of statistics class.
_getAverageByMonth($year, $sql, $format=0)
Return the amount average par month for a given year.
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
_getNbByYear($sql)
Return nb of elements by year.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
_getAllByProduct($sql, $limit=10)
Return number or total of product refs.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.