23require_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
24require_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 = ".((int) $conf->entity);
66 if ($this->socid > 0) {
67 $this->where .=
" AND fk_soc = ".((int) $this->socid);
69 if (is_array($this->userid) && count($this->userid) > 0) {
70 $this->where .=
' AND fk_user_create IN ('.$this->db->sanitize(implode(
',', $this->userid)).
')';
71 } elseif ($this->userid > 0) {
72 $this->where .=
" AND fk_user_create = ".((int) $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;
100 $sql =
"SELECT MONTH(datec) as dm, count(*)";
101 $sql .=
" FROM ".$this->from;
102 $sql .=
" WHERE YEAR(datec) = ".((int) $year);
103 $sql .=
" AND ".$this->where;
104 $sql .=
" GROUP BY dm";
105 $sql .= $this->db->order(
'dm',
'DESC');
121 $sql =
"SELECT date_format(datec,'%m') as dm, sum(".$this->field.
")";
122 $sql .=
" FROM ".$this->from;
123 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
124 $sql .=
" AND ".$this->where;
125 $sql .=
" GROUP BY dm";
126 $sql .= $this->db->order(
'dm',
'DESC');
141 $sql =
"SELECT date_format(datec,'%m') as dm, avg(".$this->field.
")";
142 $sql .=
" FROM ".$this->from;
143 $sql .=
" WHERE date_format(datec,'%Y') = '".$this->db->escape($year).
"'";
144 $sql .=
" AND ".$this->where;
145 $sql .=
" GROUP BY dm";
146 $sql .= $this->db->order(
'dm',
'DESC');
158 $sql =
"SELECT date_format(datec,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
159 $sql .=
" FROM ".$this->from;
160 $sql .=
" WHERE ".$this->where;
161 $sql .=
" GROUP BY year";
162 $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 th eamount 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.