24 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
25 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.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 =
'amount';
64 $this->where .=
" entity = ".$conf->entity;
66 $this->where .=
" AND fk_soc = ".$this->socid;
68 if (is_array($this->userid) && count($this->userid) > 0) $this->where .=
' AND fk_user IN ('.join(
',', $this->userid).
')';
69 elseif ($this->userid > 0) $this->where .=
' AND fk_user = '.$this->userid;
80 $sql =
"SELECT YEAR(datep) as dm, count(*)";
81 $sql .=
" FROM ".$this->from;
82 $sql .=
" GROUP BY dm DESC";
83 $sql .=
" WHERE ".$this->where;
98 $sql =
"SELECT MONTH(datep) as dm, count(*)";
99 $sql .=
" FROM ".$this->from;
100 $sql .=
" WHERE YEAR(datep) = ".$year;
101 $sql .=
" AND ".$this->where;
102 $sql .=
" GROUP BY dm";
103 $sql .= $this->
db->order(
'dm',
'DESC');
120 $sql =
"SELECT date_format(datep,'%m') as dm, sum(".$this->field.
")";
121 $sql .=
" FROM ".$this->from;
122 $sql .=
" WHERE date_format(datep,'%Y') = '".$this->db->escape($year).
"'";
123 $sql .=
" AND ".$this->where;
124 $sql .=
" GROUP BY dm";
125 $sql .= $this->
db->order(
'dm',
'DESC');
141 $sql =
"SELECT date_format(datep,'%m') as dm, avg(".$this->field.
")";
142 $sql .=
" FROM ".$this->from;
143 $sql .=
" WHERE date_format(datep,'%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(datep,'%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');
Parent class of statistics class.
Class to manage salary payments.
getAmountByMonth($year, $format=0)
Return amount of salaries by month for a given year.
Classe permettant la gestion des stats des salaires.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
$conf db
API class for accounts.
__construct($db, $socid=0, $userid=0)
Constructor.
getAllByYear()
Return nb, total and average.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
getAverageByMonth($year)
Return average amount.
_getAmountByMonth($year, $sql, $format=0)
Return the amount per month for a given year.
getNbByMonth($year, $format=0)
Return the number of salary by month, for a given year.
_getNbByYear($sql)
Return nb of elements by year.
getNbByYear()
Return the number of salary by year.
_getAverageByMonth($year, $sql, $format=0)
Renvoie le montant moyen par mois pour une annee donnee Return the amount average par month for a giv...