28include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
30include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41 public $table_element;
71 $this->socid = ($socid > 0 ? $socid : 0);
72 $this->userid = $userid;
73 $this->cachefilesuffix = $mode;
76 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
78 $this->field =
'weight';
79 $this->where .=
" c.fk_statut > 0";
82 $this->where .=
" AND c.entity IN (".getEntity(
'reception').
")";
83 if (!$user->hasRight(
'societe',
'client',
'voir')) {
84 $this->where .=
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
87 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
89 if ($this->userid > 0) {
90 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
105 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
106 $sql .=
" FROM ".$this->from;
107 if (!$user->hasRight(
'societe',
'client',
'voir')) {
108 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
111 $sql .=
" AND ".$this->where;
112 $sql .=
" GROUP BY dm";
113 $sql .= $this->db->order(
'dm',
'DESC');
129 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.
")";
130 $sql .=
" FROM ".$this->from;
131 if (!$user->hasRight(
'societe',
'client',
'voir')) {
132 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
134 $sql .=
" WHERE ".$this->where;
135 $sql .=
" GROUP BY dm";
136 $sql .= $this->db->order(
'dm',
'DESC');
152 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.
")";
153 $sql .=
" FROM ".$this->from;
154 if (!$user->hasRight(
'societe',
'client',
'voir')) {
155 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
158 $sql .=
" AND ".$this->where;
159 $sql .=
" GROUP BY dm";
160 $sql .= $this->db->order(
'dm',
'DESC');
176 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.
")";
177 $sql .=
" FROM ".$this->from;
178 if (!$user->hasRight(
'societe',
'client',
'voir')) {
179 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
182 $sql .=
" AND ".$this->where;
183 $sql .=
" GROUP BY dm";
184 $sql .= $this->db->order(
'dm',
'DESC');
198 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.
") as total, AVG(".$this->field.
") as avg";
199 $sql .=
" FROM ".$this->from;
200 if (!$user->hasRight(
'societe',
'client',
'voir')) {
201 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
203 $sql .=
" WHERE ".$this->where;
204 $sql .=
" GROUP BY year";
205 $sql .= $this->db->order(
'year',
'DESC');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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)
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.