25include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
36 public $table_element;
58 $this->socid = $socid;
59 $this->userid = $userid;
62 $this->from = MAIN_DB_PREFIX.$object->table_element;
65 $this->where =
" fk_statut > 0";
66 $this->where .=
" AND entity = ".$conf->entity;
67 if ($this->socid > 0) {
68 $this->where .=
" AND fk_soc = ".((int) $this->socid);
70 if (is_array($this->userid) && count($this->userid) > 0) {
71 $this->where .=
' AND fk_user IN ('.$this->db->sanitize(join(
',', $this->userid)).
')';
72 } elseif ($this->userid > 0) {
73 $this->where .=
' AND fk_user = '.((int) $this->userid);
85 $sql =
"SELECT YEAR(dated) as dm, count(*)";
86 $sql .=
" FROM ".$this->from;
87 $sql .=
" GROUP BY dm DESC";
88 $sql .=
" WHERE ".$this->where;
103 $sql =
"SELECT MONTH(dated) as dm, count(*)";
104 $sql .=
" FROM ".$this->from;
105 $sql .=
" WHERE YEAR(dated) = ".((int) $year);
106 $sql .=
" AND ".$this->where;
107 $sql .=
" GROUP BY dm";
108 $sql .= $this->db->order(
'dm',
'DESC');
125 $sql =
"SELECT date_format(dated,'%m') as dm, sum(".$this->field.
")";
126 $sql .=
" FROM ".$this->from;
127 $sql .=
" WHERE date_format(dated,'%Y') = '".$this->db->escape($year).
"'";
128 $sql .=
" AND ".$this->where;
129 $sql .=
" GROUP BY dm";
130 $sql .= $this->db->order(
'dm',
'DESC');
145 $sql =
"SELECT date_format(dated,'%m') as dm, avg(".$this->field.
")";
146 $sql .=
" FROM ".$this->from;
147 $sql .=
" WHERE date_format(dated,'%Y') = '".$this->db->escape($year).
"'";
148 $sql .=
" AND ".$this->where;
149 $sql .=
" GROUP BY dm";
150 $sql .= $this->db->order(
'dm',
'DESC');
162 $sql =
"SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
163 $sql .=
" FROM ".$this->from;
164 $sql .=
" WHERE ".$this->where;
165 $sql .=
" GROUP BY year";
166 $sql .= $this->db->order(
'year',
'DESC');
Class to manage trips and working credit notes.
Classe permettant la gestion des stats des deplacements et notes de frais.
getNbByYear()
Renvoie le nombre de facture par annee.
__construct($db, $socid=0, $userid=0)
Constructor.
getAmountByMonth($year, $format=0)
Renvoie le montant de facture par mois pour une annee donnee.
getNbByMonth($year, $format=0)
Renvoie le nombre de facture par mois pour une annee donnee.
getAverageByMonth($year)
Return average amount.
getAllByYear()
Return nb, total and average.
Parent class of statistics class.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...
_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.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...