26 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
27 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
38 public $table_element;
61 $this->socid = $socid;
62 $this->userid = $userid;
66 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as p";
67 $this->from .=
", ".MAIN_DB_PREFIX.
"adherent as m";
69 $this->field =
'subscription';
71 $this->where .=
" m.statut != -1";
72 $this->where .=
" AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity(
'adherent').
")";
74 if ($this->memberid) {
75 $this->where .=
" AND m.rowid = ".((int) $this->memberid);
90 $sql =
"SELECT date_format(p.dateadh,'%m') as dm, count(*)";
91 $sql .=
" FROM ".$this->from;
93 $sql .=
" WHERE ".dolSqlDateFilter(
'p.dateadh', 0, 0, (
int) $year, 1);
94 $sql .=
" AND ".$this->where;
95 $sql .=
" GROUP BY dm";
96 $sql .= $this->
db->order(
'dm',
'DESC');
108 $sql =
"SELECT date_format(p.dateadh,'%Y') as dm, count(*)";
109 $sql .=
" FROM ".$this->from;
111 $sql .=
" WHERE ".$this->where;
112 $sql .=
" GROUP BY dm";
113 $sql .= $this->
db->order(
'dm',
'DESC');
127 $sql =
"SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.
")";
128 $sql .=
" FROM ".$this->from;
130 $sql .=
" WHERE ".dolSqlDateFilter(
'p.dateadh', 0, 0, (
int) $year, 1);
131 $sql .=
" AND ".$this->where;
132 $sql .=
" GROUP BY dm";
133 $sql .= $this->
db->order(
'dm',
'DESC');
146 $sql =
"SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.
")";
147 $sql .=
" FROM ".$this->from;
149 $sql .=
" WHERE ".dolSqlDateFilter(
'p.dateadh', 0, 0, (
int) $year, 1);
150 $sql .=
" AND ".$this->where;
151 $sql .=
" GROUP BY dm";
152 $sql .= $this->
db->order(
'dm',
'DESC');
165 $sql =
"SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.
") as total, avg(".$this->field.
") as avg";
166 $sql .=
" FROM ".$this->from;
168 $sql .=
" WHERE ".$this->where;
169 $sql .=
" GROUP BY year";
170 $sql .= $this->
db->order(
'year',
'DESC');
Class to manage statistics of members.
getNbByMonth($year, $format=0)
Return the number of proposition by month for a given year.
getAllByYear()
Return nb, total and average.
__construct($db, $socid=0, $userid=0)
Constructor.
getNbByYear()
Return the number of subscriptions by year.
getAverageByMonth($year)
Return average amount each month.
getAmountByMonth($year, $format=0)
Return the number of subscriptions by month for a given year.
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...
Class to manage subscriptions of foundation members.
$conf db
API class for accounts.