27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 public $table_element;
79 $this->socid = ($socid > 0 ? $socid : 0);
80 $this->userid = $userid;
81 $this->cachefilesuffix = $mode;
83 if ($mode ==
'customer') {
85 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
86 $this->from_line = MAIN_DB_PREFIX.$object->table_element_line.
" as tl";
88 $this->field_line =
'0';
91 if (!$user->hasRight(
'societe',
'client',
'voir')) {
92 $this->where .= (!empty($this->where) ?
' AND ' :
'').
" c.fk_soc = sc.fk_soc AND sc.fk_user = ".((
int) $user->id);
94 $this->where .= ($this->where ?
' AND ' :
'').
"c.entity IN (".
getEntity(
'intervention').
')';
97 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
99 if ($this->userid > 0) {
100 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
115 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
116 $sql .=
" FROM ".$this->from;
117 if (!$user->hasRight(
'societe',
'client',
'voir')) {
118 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
121 $sql .=
" AND ".$this->where;
122 $sql .=
" GROUP BY dm";
123 $sql .= $this->db->order(
'dm',
'DESC');
139 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
140 $sql .=
" FROM ".$this->from;
141 if (!$user->hasRight(
'societe',
'client',
'voir')) {
142 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
144 $sql .=
" WHERE ".$this->where;
145 $sql .=
" GROUP BY dm";
146 $sql .= $this->db->order(
'dm',
'DESC');
162 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
163 $sql .=
" FROM ".$this->from;
164 if (!$user->hasRight(
'societe',
'client',
'voir')) {
165 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
168 $sql .=
" AND ".$this->where;
169 $sql .=
" GROUP BY dm";
170 $sql .= $this->db->order(
'dm',
'DESC');
186 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, 0";
187 $sql .=
" FROM ".$this->from;
188 if (!$user->hasRight(
'societe',
'client',
'voir')) {
189 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
192 $sql .=
" AND ".$this->where;
193 $sql .=
" GROUP BY dm";
194 $sql .= $this->db->order(
'dm',
'DESC');
208 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
209 $sql .=
" FROM ".$this->from;
210 if (!$user->hasRight(
'societe',
'client',
'voir')) {
211 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
213 $sql .=
" WHERE ".$this->where;
214 $sql .=
" GROUP BY year";
215 $sql .= $this->db->order(
'year',
'DESC');
231 $sql =
"SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg";
232 $sql .=
" FROM ".$this->from.
", ".$this->from_line.
", ".MAIN_DB_PREFIX.
"product as product";
234 $sql .=
" WHERE ".$this->where;
235 $sql .=
" AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid";
237 $sql .=
" GROUP BY product.ref";
238 $sql .= $this->db->order(
'nb',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage intervention statistics.
__construct($db, $socid, $mode, $userid=0)
Constructor.
getNbByYear()
Return interventions number per year.
getAmountByMonth($year, $format=0)
Return the intervention amount by month for a year.
getAverageByMonth($year)
Return the intervention amount average by month for a year.
getAllByYear()
Return nb, total and average.
getNbByMonth($year, $format=0)
Return intervention number by month for a year.
getAllByProduct($year, $limit=0)
Return nb, amount of predefined product for year.
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.
_getAllByProduct($sql, $limit=10)
Return number or total of product refs.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...