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 (empty($user->rights->societe->client->voir) && !$this->socid) {
 
   77       $this->where .= 
" AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
   80       $this->where .= 
" AND c.fk_soc = ".((int) $this->socid);
 
   82     if ($this->userid > 0) {
 
   83       $this->where .= 
' AND c.fk_user_author = '.((int) $this->userid);
 
   98     $sql = 
"SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
 
   99     $sql .= 
" FROM ".$this->from;
 
  100     if (empty($user->rights->societe->client->voir) && !$this->socid) {
 
  101       $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  104     $sql .= 
" AND ".$this->where;
 
  105     $sql .= 
" GROUP BY dm";
 
  106     $sql .= $this->
db->order(
'dm', 
'DESC');
 
  122     $sql = 
"SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.
")";
 
  123     $sql .= 
" FROM ".$this->from;
 
  124     if (empty($user->rights->societe->client->voir) && !$this->socid) {
 
  125       $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  127     $sql .= 
" WHERE ".$this->where;
 
  128     $sql .= 
" GROUP BY dm";
 
  129     $sql .= $this->
db->order(
'dm', 
'DESC');
 
  145     $sql = 
"SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.
")";
 
  146     $sql .= 
" FROM ".$this->from;
 
  147     if (empty($user->rights->societe->client->voir) && !$this->socid) {
 
  148       $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  151     $sql .= 
" WHERE ".$this->where;
 
  152     $sql .= 
" GROUP BY dm";
 
  153     $sql .= $this->
db->order(
'dm', 
'DESC');
 
  169     $sql = 
"SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.
")";
 
  170     $sql .= 
" FROM ".$this->from;
 
  171     if (empty($user->rights->societe->client->voir) && !$this->socid) {
 
  172       $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  175     $sql .= 
" WHERE ".$this->where;
 
  176     $sql .= 
" GROUP BY dm";
 
  177     $sql .= $this->
db->order(
'dm', 
'DESC');
 
  191     $sql = 
"SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.
") as total, AVG(".$this->field.
") as avg";
 
  192     $sql .= 
" FROM ".$this->from;
 
  193     if (empty($user->rights->societe->client->voir) && !$this->socid) {
 
  194       $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  196     $sql .= 
" WHERE ".$this->where;
 
  197     $sql .= 
" GROUP BY year";
 
  198     $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.
 
$conf db
API class for accounts.