23 require_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
24 require_once
'ticket.class.php';
35 public $table_element;
57 $this->socid = $socid;
58 $this->userid = $userid;
61 $this->from = MAIN_DB_PREFIX.$object->table_element;
62 $this->field =
'timing';
64 $this->where =
" fk_statut > 0";
65 $this->where .=
" AND entity = ".$conf->entity;
66 if ($this->socid > 0) {
67 $this->where .=
" AND fk_soc = ".$this->socid;
69 if (is_array($this->userid) && count($this->userid) > 0) {
70 $this->where .=
' AND fk_user_create IN ('.join(
',', $this->userid).
')';
71 } elseif ($this->userid > 0) {
72 $this->where .=
' AND fk_user_create = '.$this->userid;
83 $sql =
"SELECT YEAR(datec) as dm, count(*)";
84 $sql .=
" FROM ".$this->from;
85 $sql .=
" GROUP BY dm DESC";
86 $sql .=
" WHERE ".$this->where;
99 $sql =
"SELECT MONTH(datec) as dm, count(*)";
100 $sql .=
" FROM ".$this->from;
101 $sql .=
" WHERE YEAR(datec) = ".$year;
102 $sql .=
" AND ".$this->where;
103 $sql .=
" GROUP BY dm";
104 $sql .= $this->
db->order(
'dm',
'DESC');
119 $sql =
"SELECT date_format(datec,'%m') as dm, sum(".$this->field.
")";
120 $sql .=
" FROM ".$this->from;
121 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
122 $sql .=
" AND ".$this->where;
123 $sql .=
" GROUP BY dm";
124 $sql .= $this->
db->order(
'dm',
'DESC');
139 $sql =
"SELECT date_format(datec,'%m') as dm, avg(".$this->field.
")";
140 $sql .=
" FROM ".$this->from;
141 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
142 $sql .=
" AND ".$this->where;
143 $sql .=
" GROUP BY dm";
144 $sql .= $this->
db->order(
'dm',
'DESC');
156 $sql =
"SELECT date_format(datec,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
157 $sql .=
" FROM ".$this->from;
158 $sql .=
" WHERE ".$this->where;
159 $sql .=
" GROUP BY year";
160 $sql .= $this->
db->order(
'year',
'DESC');
Classe permettant la gestion des stats des deplacements et notes de frais.
Parent class of statistics class.
getNbByYear()
Renvoie le nombre de tickets par annee.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
$conf db
API class for accounts.
getNbByMonth($year)
Renvoie le nombre de facture par mois pour une annee donnee.
getAllByYear()
Return nb, total and average.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
getAverageByMonth($year)
Return average amount.
__construct($db, $socid=0, $userid=0)
Constructor.
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
_getNbByYear($sql)
Return nb of elements by year.
getAmountByMonth($year)
Renvoie le montant de facture par mois pour une annee donnee.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...