27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 public $table_element;
64 $this->socid = ($socid > 0 ? $socid : 0);
65 $this->userid = $userid;
66 $this->cachefilesuffix = $mode;
68 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->hasRight(
'societe',
'client',
'voir')) {
77 $this->where .= (!empty($this->where) ?
' AND ' :
'').
" c.fk_soc = sc.fk_soc AND sc.fk_user = ".((
int) $user->id);
79 $this->where .= ($this->where ?
' AND ' :
'').
"c.entity IN (".
getEntity(
'intervention').
')';
82 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
84 if ($this->userid > 0) {
85 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
100 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
101 $sql .=
" FROM ".$this->from;
102 if (!$user->hasRight(
'societe',
'client',
'voir')) {
103 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
106 $sql .=
" AND ".$this->where;
107 $sql .=
" GROUP BY dm";
108 $sql .= $this->db->order(
'dm',
'DESC');
124 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
125 $sql .=
" FROM ".$this->from;
126 if (!$user->hasRight(
'societe',
'client',
'voir')) {
127 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
129 $sql .=
" WHERE ".$this->where;
130 $sql .=
" GROUP BY dm";
131 $sql .= $this->db->order(
'dm',
'DESC');
147 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
148 $sql .=
" FROM ".$this->from;
149 if (!$user->hasRight(
'societe',
'client',
'voir')) {
150 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
153 $sql .=
" AND ".$this->where;
154 $sql .=
" GROUP BY dm";
155 $sql .= $this->db->order(
'dm',
'DESC');
171 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
172 $sql .=
" FROM ".$this->from;
173 if (!$user->hasRight(
'societe',
'client',
'voir')) {
174 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
177 $sql .=
" AND ".$this->where;
178 $sql .=
" GROUP BY dm";
179 $sql .= $this->db->order(
'dm',
'DESC');
193 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
194 $sql .=
" FROM ".$this->from;
195 if (!$user->hasRight(
'societe',
'client',
'voir')) {
196 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
198 $sql .=
" WHERE ".$this->where;
199 $sql .=
" GROUP BY year";
200 $sql .= $this->db->order(
'year',
'DESC');
216 $sql =
"SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg";
217 $sql .=
" FROM ".$this->from.
", ".$this->from_line.
", ".MAIN_DB_PREFIX.
"product as product";
219 $sql .=
" WHERE ".$this->where;
220 $sql .=
" AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid";
222 $sql .=
" GROUP BY product.ref";
223 $sql .= $this->db->order(
'nb',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.