27 include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
28 include_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
29 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 public $table_element;
64 $this->socid = ($socid > 0 ? $socid : 0);
65 $this->userid = $userid;
66 $this->cachefilesuffix = $mode;
69 $this->from = MAIN_DB_PREFIX.$object->table_element.
" as c";
71 $this->field =
'weight';
72 $this->where .=
" c.fk_statut > 0";
75 $this->where .=
" AND c.entity = ".$conf->entity;
76 if (!$user->rights->societe->client->voir && !$this->socid) $this->where .=
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
79 $this->where .=
" AND c.fk_soc = ".$this->socid;
81 if ($this->userid > 0) $this->where .=
' AND c.fk_user_author = '.$this->userid;
95 $sql =
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
96 $sql .=
" FROM ".$this->from;
97 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
99 $sql .=
" AND ".$this->where;
100 $sql .=
" GROUP BY dm";
101 $sql .= $this->
db->order(
'dm',
'DESC');
117 $sql =
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.
")";
118 $sql .=
" FROM ".$this->from;
119 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
120 $sql .=
" WHERE ".$this->where;
121 $sql .=
" GROUP BY dm";
122 $sql .= $this->
db->order(
'dm',
'DESC');
136 $sql =
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.
") as total, AVG(".$this->field.
") as avg";
137 $sql .=
" FROM ".$this->from;
138 if (!$user->rights->societe->client->voir && !$this->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
139 $sql .=
" WHERE ".$this->where;
140 $sql .=
" GROUP BY year";
141 $sql .= $this->
db->order(
'year',
'DESC');
Parent class of statistics class.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
getNbByYear()
Return shipments number per year.
_getNbByMonth($year, $sql, $format=0)
Renvoie le nombre de documents par mois pour une annee donnee Return number of documents per month fo...
$conf db
API class for accounts.
getNbByMonth($year, $format=0)
Return shipment number by month for a year.
Class to manage shipments.
_getAllByYear($sql)
Return nb of elements, total amount and avg amount each year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
__construct($db, $socid, $mode, $userid=0)
Constructor.
_getNbByYear($sql)
Return nb of elements by year.
Class to manage shipment statistics.
getAllByYear()
Return nb, total and average.