26include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
37 public $table_element;
74 $this->socid = $socid;
75 $this->userid = $userid;
78 $this->from = MAIN_DB_PREFIX.$object->table_element;
81 $this->where =
" fk_statut > 0";
82 $this->where .=
" AND entity = ".$conf->entity;
83 if ($this->socid > 0) {
84 $this->where .=
" AND fk_soc = ".((int) $this->socid);
86 if (is_array($this->userid) && count($this->userid) > 0) {
87 $this->where .=
' AND fk_user IN ('.$this->db->sanitize(implode(
',', $this->userid)).
')';
88 } elseif ($this->userid > 0) {
89 $this->where .=
' AND fk_user = '.((int) $this->userid);
101 $sql =
"SELECT YEAR(dated) as dm, count(*)";
102 $sql .=
" FROM ".$this->from;
103 $sql .=
" GROUP BY dm DESC";
104 $sql .=
" WHERE ".$this->where;
119 $sql =
"SELECT MONTH(dated) as dm, count(*)";
120 $sql .=
" FROM ".$this->from;
121 $sql .=
" WHERE YEAR(dated) = ".((int) $year);
122 $sql .=
" AND ".$this->where;
123 $sql .=
" GROUP BY dm";
124 $sql .= $this->db->order(
'dm',
'DESC');
141 $sql =
"SELECT date_format(dated,'%m') as dm, sum(".$this->field.
")";
142 $sql .=
" FROM ".$this->from;
143 $sql .=
" WHERE date_format(dated,'%Y') = '".$this->db->escape($year).
"'";
144 $sql .=
" AND ".$this->where;
145 $sql .=
" GROUP BY dm";
146 $sql .= $this->db->order(
'dm',
'DESC');
161 $sql =
"SELECT date_format(dated,'%m') as dm, avg(".$this->field.
")";
162 $sql .=
" FROM ".$this->from;
163 $sql .=
" WHERE date_format(dated,'%Y') = '".$this->db->escape($year).
"'";
164 $sql .=
" AND ".$this->where;
165 $sql .=
" GROUP BY dm";
166 $sql .= $this->db->order(
'dm',
'DESC');
178 $sql =
"SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
179 $sql .=
" FROM ".$this->from;
180 $sql .=
" WHERE ".$this->where;
181 $sql .=
" GROUP BY year";
182 $sql .= $this->db->order(
'year',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage trips and working credit notes.
Class to manage the statistics of travel and expense notes.
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)
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.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...