25include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
36 public $table_element;
58 $this->socid = $socid;
59 $this->userid = $userid;
61 $object =
new Salary($this->db);
62 $this->from = MAIN_DB_PREFIX.$object->table_element;
63 $this->field =
'amount';
65 $this->where =
" entity = ".$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 IN ('.$this->db->sanitize(join(
',', $this->userid)).
')';
71 } elseif ($this->userid > 0) {
72 $this->where .=
" AND fk_user = ".((int) $this->userid);
84 $sql =
"SELECT YEAR(dateep) as dm, count(*)";
85 $sql .=
" FROM ".$this->from;
86 $sql .=
" WHERE ".$this->where;
87 $sql .=
" GROUP BY dm DESC";
102 $sql =
"SELECT MONTH(dateep) as dm, count(*)";
103 $sql .=
" FROM ".$this->from;
104 $sql .=
" WHERE YEAR(dateep) = ".((int) $year);
105 $sql .=
" AND ".$this->where;
106 $sql .=
" GROUP BY dm";
107 $sql .= $this->db->order(
'dm',
'DESC');
124 $sql =
"SELECT date_format(dateep,'%m') as dm, sum(".$this->field.
")";
125 $sql .=
" FROM ".$this->from;
126 $sql .=
" WHERE date_format(dateep,'%Y') = '".$this->db->escape($year).
"'";
127 $sql .=
" AND ".$this->where;
128 $sql .=
" GROUP BY dm";
129 $sql .= $this->db->order(
'dm',
'DESC');
144 $sql =
"SELECT date_format(dateep,'%m') as dm, avg(".$this->field.
")";
145 $sql .=
" FROM ".$this->from;
146 $sql .=
" WHERE date_format(dateep,'%Y') = '".$this->db->escape($year).
"'";
147 $sql .=
" AND ".$this->where;
148 $sql .=
" GROUP BY dm";
149 $sql .= $this->db->order(
'dm',
'DESC');
161 $sql =
"SELECT date_format(dateep,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
162 $sql .=
" FROM ".$this->from;
163 $sql .=
" WHERE ".$this->where;
164 $sql .=
" GROUP BY year";
165 $sql .= $this->db->order(
'year',
'DESC');
Classe permettant la gestion des stats des salaires.
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)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...
_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...