28include_once DOL_DOCUMENT_ROOT.
'/core/class/stats.class.php';
 
   29include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
 
   30include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   40  public $table_element;
 
   81  public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $status = 4)
 
   87    $this->field = 
'amount';
 
   88    $this->socid = ($socid > 0 ? $socid : 0);
 
   89    $this->userid = $userid;
 
   90    $this->cachefilesuffix = $mode;
 
   93    if ($status == 0 || $status == 1 || $status == 2) {
 
   94      $this->where = 
' d.fk_statut IN ('.$this->db->sanitize($status).
')';
 
   95    } elseif ($status == 3) {
 
   96      $this->where = 
' d.fk_statut IN (-1)';
 
   97    } elseif ($status == 4) {
 
   98      $this->where = 
' d.fk_statut >= 0';
 
  102    $this->from = MAIN_DB_PREFIX.$object->table_element.
" as d";
 
  104    if ($socid !== 
"-1" && $socid > 0) {
 
  105      $this->where .= 
" AND d.fk_soc = ".((int) $socid);
 
  108    $this->where .= 
" AND d.entity = ".$conf->entity;
 
  109    if ($this->userid > 0) {
 
  110      $this->where .= 
' AND d.fk_user_author = '.((int) $this->userid);
 
  114      $this->join .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON s.rowid = d.fk_soc';
 
  115      $this->where .= 
' AND s.fk_typent = '.((int) $typentid);
 
 
  128    $sql = 
"SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb";
 
  129    $sql .= 
" FROM ".$this->from;
 
  132    $sql .= 
" AND ".$this->where;
 
  133    $sql .= 
" GROUP BY dm";
 
  134    $sql .= $this->db->order(
'dm', 
'DESC');
 
 
  147    $sql = 
"SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.
")";
 
  148    $sql .= 
" FROM ".$this->from;
 
  150    $sql .= 
" WHERE ".$this->where;
 
  151    $sql .= 
" GROUP BY dm";
 
  152    $sql .= $this->db->order(
'dm', 
'DESC');
 
 
  166    $sql = 
"SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.
")";
 
  167    $sql .= 
" FROM ".$this->from;
 
  169    $sql .= 
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
 
  170    $sql .= 
" AND ".$this->where;
 
  171    $sql .= 
" GROUP BY dm";
 
  172    $sql .= $this->db->order(
'dm', 
'DESC');
 
 
  185    $sql = 
"SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.
")";
 
  186    $sql .= 
" FROM ".$this->from;
 
  188    $sql .= 
" WHERE ".dolSqlDateFilter(
'd.datedon', 0, 0, (
int) $year, 1);
 
  189    $sql .= 
" AND ".$this->where;
 
  190    $sql .= 
" GROUP BY dm";
 
  191    $sql .= $this->db->order(
'dm', 
'DESC');
 
 
  203    $sql = 
"SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.
") as total, AVG(".$this->field.
") as avg";
 
  204    $sql .= 
" FROM ".$this->from;
 
  206    $sql .= 
" WHERE ".$this->where;
 
  207    $sql .= 
" GROUP BY year";
 
  208    $sql .= $this->db->order(
'year', 
'DESC');
 
 
 
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
 
Class to manage donations.
 
Class to manage donations statistics.
 
getAmountByMonth($year, $format=0)
Return the number of subscriptions by month for a given year.
 
getNbByMonth($year, $format=0)
Return shipment number by month for a year.
 
__construct($db, $socid, $mode, $userid=0, $typentid=0, $status=4)
Constructor.
 
getAllByYear()
Return nb, total and average.
 
getNbByYear()
Return shipments number per year.
 
getAverageByMonth($year)
Return average amount each month.
 
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.
 
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...