Go to the documentation of this file.
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;
60 $object =
new Ticket($this->db);
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(join(
',', $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');
getNbByYear()
Renvoie le nombre de tickets par annee.
Parent class of statistics class.
_getNbByYear($sql)
Return nb of elements by year.
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
getAllByYear()
Return nb, total and average.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
__construct($db, $socid=0, $userid=0)
Constructor.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
getNbByMonth($year, $format=0)
Return the number of tickets per month for a given year.
getAmountByMonth($year, $format=0)
Return th eamount of tickets for a month and a given year.
getAverageByMonth($year)
Return average amount.
_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 generate the form for creating a new ticket.
Classe permettant la gestion des stats des deplacements et notes de frais.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...