27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 public $table_element;
74 public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $status = 4)
80 $this->field =
'amount';
81 $this->socid = ($socid > 0 ? $socid : 0);
82 $this->userid = $userid;
83 $this->cachefilesuffix = $mode;
86 if ($status == 0 || $status == 1 || $status == 2) {
87 $this->where =
' d.fk_statut IN ('.$this->db->sanitize($status).
')';
88 } elseif ($status == 3) {
89 $this->where =
' d.fk_statut IN (-1)';
90 } elseif ($status == 4) {
91 $this->where =
' d.fk_statut >= 0';
95 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as d";
97 if ($socid !==
"-1" && $socid > 0) {
98 $this->where .=
" AND d.fk_soc = ".((int) $socid);
101 $this->where .=
" AND d.entity = ".$conf->entity;
102 if ($this->userid > 0) {
103 $this->where .=
' AND d.fk_user_author = '.((int) $this->userid);
107 $this->join .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON s.rowid = d.fk_soc';
108 $this->where .=
' AND s.fk_typent = '.((int) $typentid);
121 $sql =
"SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb";
122 $sql .=
" FROM ".$this->from;
125 $sql .=
" AND ".$this->where;
126 $sql .=
" GROUP BY dm";
127 $sql .= $this->db->order(
'dm',
'DESC');
140 $sql =
"SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.
")";
141 $sql .=
" FROM ".$this->from;
143 $sql .=
" WHERE ".$this->where;
144 $sql .=
" GROUP BY dm";
145 $sql .= $this->db->order(
'dm',
'DESC');
159 $sql =
"SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.
")";
160 $sql .=
" FROM ".$this->from;
162 $sql .=
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
163 $sql .=
" AND ".$this->where;
164 $sql .=
" GROUP BY dm";
165 $sql .= $this->db->order(
'dm',
'DESC');
178 $sql =
"SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.
")";
179 $sql .=
" FROM ".$this->from;
181 $sql .=
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
182 $sql .=
" AND ".$this->where;
183 $sql .=
" GROUP BY dm";
184 $sql .= $this->db->order(
'dm',
'DESC');
196 $sql =
"SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.
") as total, AVG(".$this->field.
") as avg";
197 $sql .=
" FROM ".$this->from;
199 $sql .=
" WHERE ".$this->where;
200 $sql .=
" GROUP BY year";
201 $sql .= $this->db->order(
'year',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage donations.
Class to manage donations statistics.
getAmountByMonth($year, $format=0)
Return the number of subscriptions by month for a given year.
getNbByMonth($year, $format=0)
Return shipment number by month for a year.
__construct($db, $socid, $mode, $userid=0, $typentid=0, $status=4)
Constructor.
getAllByYear()
Return nb, total and average.
getNbByYear()
Return shipments number per year.
getAverageByMonth($year)
Return average amount each month.
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...
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.