27include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 public $table_element;
87 $this->socid = ($socid > 0 ? $socid : 0);
88 $this->userid = $userid;
89 $this->cachefilesuffix = $mode;
92 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
94 $this->field =
'weight';
95 $this->where .=
" c.fk_statut > 0";
98 $this->where .=
" AND c.entity = ".$conf->entity;
99 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
100 $this->where .=
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
103 $this->where .=
" AND c.fk_soc = ".((int) $this->socid);
105 if ($this->userid > 0) {
106 $this->where .=
' AND c.fk_user_author = '.((int) $this->userid);
121 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
122 $sql .=
" FROM ".$this->from;
123 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
124 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
127 $sql .=
" AND ".$this->where;
128 $sql .=
" GROUP BY dm";
129 $sql .= $this->db->order(
'dm',
'DESC');
145 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.
")";
146 $sql .=
" FROM ".$this->from;
147 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
148 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
150 $sql .=
" WHERE ".$this->where;
151 $sql .=
" GROUP BY dm";
152 $sql .= $this->db->order(
'dm',
'DESC');
168 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.
")";
169 $sql .=
" FROM ".$this->from;
170 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
171 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
174 $sql .=
" WHERE ".$this->where;
175 $sql .=
" GROUP BY dm";
176 $sql .= $this->db->order(
'dm',
'DESC');
192 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.
")";
193 $sql .=
" FROM ".$this->from;
194 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
195 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
198 $sql .=
" WHERE ".$this->where;
199 $sql .=
" GROUP BY dm";
200 $sql .= $this->db->order(
'dm',
'DESC');
214 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.
") as total, AVG(".$this->field.
") as avg";
215 $sql .=
" FROM ".$this->from;
216 if (!$user->hasRight(
'societe',
'client',
'voir') && !$this->socid) {
217 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
219 $sql .=
" WHERE ".$this->where;
220 $sql .=
" GROUP BY year";
221 $sql .= $this->db->order(
'year',
'DESC');
Class to manage shipments.
Class to manage shipment statistics.
getNbByMonth($year, $format=0)
Return shipment number by month for a year.
__construct($db, $socid, $mode, $userid=0)
Constructor.
getAverageByMonth($year)
Return the orders amount average by month for a year.
getAmountByMonth($year, $format=0)
Return the orders amount by month for a year.
getNbByYear()
Return shipments number per year.
getAllByYear()
Return nb, total and average.
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.