Fix missing abstract methods

This commit is contained in:
Laurent Destailleur 2022-11-17 10:21:26 +01:00
parent 110f95e442
commit 309a7ccf34

View File

@ -131,6 +131,54 @@ class ExpeditionStats extends Stats
return $this->_getNbByYear($sql);
}
/**
* Return the orders amount by month for a year
*
* @param int $year Year to scan
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
* @return array Array with amount by month
*/
public function getAmountByMonth($year, $format = 0)
{
global $user;
$sql = "SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
$res = $this->_getAmountByMonth($year, $sql, $format);
return $res;
}
/**
* Return the orders amount average by month for a year
*
* @param int $year year for stats
* @return array array with number by month
*/
public function getAverageByMonth($year)
{
global $user;
$sql = "SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
/**
* Return nb, total and average
*