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';
40 public $table_element;
75 $this->field =
'amount';
76 $this->socid = ($socid > 0 ? $socid : 0);
77 $this->userid = $userid;
78 $this->cachefilesuffix = $mode;
80 $object =
new Don($this->db);
81 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as d";
84 $this->where .=
" d.fk_statut > 0";
87 $this->where .=
" AND d.entity = ".$conf->entity;
88 if ($this->userid > 0) {
89 $this->where .=
' WHERE c.fk_user_author = '.((int) $this->userid);
102 $sql =
"SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb";
103 $sql .=
" FROM ".$this->from;
105 $sql .=
" AND ".$this->where;
106 $sql .=
" GROUP BY dm";
107 $sql .= $this->db->order(
'dm',
'DESC');
121 $sql =
"SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.
")";
122 $sql .=
" FROM ".$this->from;
123 $sql .=
" WHERE ".$this->where;
124 $sql .=
" GROUP BY dm";
125 $sql .= $this->db->order(
'dm',
'DESC');
139 $sql =
"SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.
")";
140 $sql .=
" FROM ".$this->from;
142 $sql .=
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
143 $sql .=
" AND ".$this->where;
144 $sql .=
" GROUP BY dm";
145 $sql .= $this->db->order(
'dm',
'DESC');
158 $sql =
"SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.
")";
159 $sql .=
" FROM ".$this->from;
161 $sql .=
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
162 $sql .=
" AND ".$this->where;
163 $sql .=
" GROUP BY dm";
164 $sql .= $this->db->order(
'dm',
'DESC');
176 $sql =
"SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.
") as total, AVG(".$this->field.
") as avg";
177 $sql .=
" FROM ".$this->from;
178 $sql .=
" WHERE ".$this->where;
179 $sql .=
" GROUP BY year";
180 $sql .= $this->db->order(
'year',
'DESC');
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)
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)
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...
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.