27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
38 public $table_element;
63 $this->socid = $socid;
64 $this->userid = $userid;
67 $this->from = MAIN_DB_PREFIX.$object->table_element;
68 $this->field =
'amount';
70 $this->where =
" entity = ".$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 IN ('.$this->db->sanitize(implode(
',', $this->userid)).
')';
76 } elseif ($this->userid > 0) {
77 $this->where .=
" AND fk_user = ".((int) $this->userid);
89 $sql =
"SELECT YEAR(dateep) as dm, count(*)";
90 $sql .=
" FROM ".$this->from;
91 $sql .=
" WHERE ".$this->where;
92 $sql .=
" GROUP BY dm DESC";
107 $sql =
"SELECT MONTH(dateep) as dm, count(*)";
108 $sql .=
" FROM ".$this->from;
109 $sql .=
" WHERE YEAR(dateep) = ".((int) $year);
110 $sql .=
" AND ".$this->where;
111 $sql .=
" GROUP BY dm";
112 $sql .= $this->db->order(
'dm',
'DESC');
129 $sql =
"SELECT date_format(dateep,'%m') as dm, sum(".$this->field.
")";
130 $sql .=
" FROM ".$this->from;
131 $sql .=
" WHERE date_format(dateep,'%Y') = '".$this->db->escape($year).
"'";
132 $sql .=
" AND ".$this->where;
133 $sql .=
" GROUP BY dm";
134 $sql .= $this->db->order(
'dm',
'DESC');
149 $sql =
"SELECT date_format(dateep,'%m') as dm, avg(".$this->field.
")";
150 $sql .=
" FROM ".$this->from;
151 $sql .=
" WHERE date_format(dateep,'%Y') = '".$this->db->escape($year).
"'";
152 $sql .=
" AND ".$this->where;
153 $sql .=
" GROUP BY dm";
154 $sql .= $this->db->order(
'dm',
'DESC');
166 $sql =
"SELECT date_format(dateep,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
167 $sql .=
" FROM ".$this->from;
168 $sql .=
" WHERE ".$this->where;
169 $sql .=
" GROUP BY year";
170 $sql .= $this->db->order(
'year',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage salary statistics.
getNbByMonth($year, $format=0)
Return the number of salary by month, for a given year.
__construct($db, $socid=0, $userid=0)
Constructor.
getAverageByMonth($year)
Return average amount.
getAmountByMonth($year, $format=0)
Return amount of salaries by month for a given year.
getNbByYear()
Return the number of salary by year.
getAllByYear()
Return nb, total and average.
Class to manage salary payments.
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...