27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37 public $table_element;
61 $this->socid = ($socid > 0 ? $socid : 0);
62 $this->userid = $userid;
63 $this->cachefilesuffix = $mode;
66 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
68 $this->field =
'weight';
69 $this->where .=
" c.fk_statut > 0";
72 $this->where .=
" AND c.entity IN (".getEntity(
'reception').
")";
73 if (empty($user->rights->societe->client->voir) && !$this->socid) {
74 $this->where .=
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
77 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
79 if ($this->userid > 0) {
80 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
95 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
96 $sql .=
" FROM ".$this->from;
97 if (empty($user->rights->societe->client->voir) && !$this->socid) {
98 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
101 $sql .=
" AND ".$this->where;
102 $sql .=
" GROUP BY dm";
103 $sql .= $this->db->order(
'dm',
'DESC');
119 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.
")";
120 $sql .=
" FROM ".$this->from;
121 if (empty($user->rights->societe->client->voir) && !$this->socid) {
122 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
124 $sql .=
" WHERE ".$this->where;
125 $sql .=
" GROUP BY dm";
126 $sql .= $this->db->order(
'dm',
'DESC');
142 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.
")";
143 $sql .=
" FROM ".$this->from;
144 if (empty($user->rights->societe->client->voir) && !$this->socid) {
145 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
148 $sql .=
" AND ".$this->where;
149 $sql .=
" GROUP BY dm";
150 $sql .= $this->db->order(
'dm',
'DESC');
166 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.
")";
167 $sql .=
" FROM ".$this->from;
168 if (empty($user->rights->societe->client->voir) && !$this->socid) {
169 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
172 $sql .=
" AND ".$this->where;
173 $sql .=
" GROUP BY dm";
174 $sql .= $this->db->order(
'dm',
'DESC');
188 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.
") as total, AVG(".$this->field.
") as avg";
189 $sql .=
" FROM ".$this->from;
190 if (empty($user->rights->societe->client->voir) && !$this->socid) {
191 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
193 $sql .=
" WHERE ".$this->where;
194 $sql .=
" GROUP BY year";
195 $sql .= $this->db->order(
'year',
'DESC');
Class to manage receptions.
Class to manage reception statistics.
getNbByMonth($year, $format=0)
Return reception number by month for a year.
getNbByYear()
Return receptions number per year.
getAmountByMonth($year, $format=0)
Return the orders amount by month for a year.
getAverageByMonth($year)
Return the orders amount average by month for a year.
getAllByYear()
Return nb, total and average.
__construct($db, $socid, $mode, $userid=0)
Constructor.
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.