25require_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
26require_once
'ticket.class.php';
37 public $table_element;
62 $this->socid = $socid;
63 $this->userid = $userid;
66 $this->from = MAIN_DB_PREFIX.$object->table_element;
67 $this->field =
'timing';
69 $this->where =
" fk_statut > 0";
70 $this->where .=
" AND entity = ".((int) $conf->entity);
71 if ($this->socid > 0) {
72 $this->where .=
" AND fk_soc = ".((int) $this->socid);
74 if (is_array($this->userid) && count($this->userid) > 0) {
75 $this->where .=
' AND fk_user_create IN ('.$this->db->sanitize(implode(
',', $this->userid)).
')';
76 } elseif ($this->userid > 0) {
77 $this->where .=
" AND fk_user_create = ".((int) $this->userid);
88 $sql =
"SELECT YEAR(datec) as dm, count(*)";
89 $sql .=
" FROM ".$this->from;
90 $sql .=
" GROUP BY dm DESC";
91 $sql .=
" WHERE ".$this->where;
105 $sql =
"SELECT MONTH(datec) as dm, count(*)";
106 $sql .=
" FROM ".$this->from;
107 $sql .=
" WHERE YEAR(datec) = ".((int) $year);
108 $sql .=
" AND ".$this->where;
109 $sql .=
" GROUP BY dm";
110 $sql .= $this->db->order(
'dm',
'DESC');
126 $sql =
"SELECT date_format(datec,'%m') as dm, sum(".$this->field.
")";
127 $sql .=
" FROM ".$this->from;
128 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
129 $sql .=
" AND ".$this->where;
130 $sql .=
" GROUP BY dm";
131 $sql .= $this->db->order(
'dm',
'DESC');
146 $sql =
"SELECT date_format(datec,'%m') as dm, avg(".$this->field.
")";
147 $sql .=
" FROM ".$this->from;
148 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
149 $sql .=
" AND ".$this->where;
150 $sql .=
" GROUP BY dm";
151 $sql .= $this->db->order(
'dm',
'DESC');
163 $sql =
"SELECT date_format(datec,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
164 $sql .=
" FROM ".$this->from;
165 $sql .=
" WHERE ".$this->where;
166 $sql .=
" GROUP BY year";
167 $sql .= $this->db->order(
'year',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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...
Class to manage the ticket stats.
getAllByYear()
Return nb, total and average.
getNbByMonth($year, $format=0)
Return the number of tickets per month for a given year.
getNbByYear()
Renvoie le nombre de tickets par annee.
getAverageByMonth($year)
Return average amount.
getAmountByMonth($year, $format=0)
Return the number of tickets for a month and a given year.
__construct($db, $socid=0, $userid=0)
Constructor.
Class to generate the form for creating a new ticket.