Utilisation d'une classe mère
This commit is contained in:
parent
d320606a82
commit
05a9866407
@ -20,7 +20,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PropaleStats
|
include_once DOL_DOCUMENT_ROOT . "/stats.class.php";
|
||||||
|
|
||||||
|
class PropaleStats extends Stats
|
||||||
{
|
{
|
||||||
var $db ;
|
var $db ;
|
||||||
|
|
||||||
@ -29,84 +31,29 @@ class PropaleStats
|
|||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function getNbByMonthWithPrevYear($year)
|
|
||||||
{
|
|
||||||
$data1 = $this->getNbByMonth($year - 1);
|
|
||||||
$data2 = $this->getNbByMonth($year);
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
for ($i = 0 ; $i < 12 ; $i++)
|
|
||||||
{
|
|
||||||
$data[$i] = array($data1[$i][0],
|
|
||||||
$data1[$i][1],
|
|
||||||
$data2[$i][1]);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Renvoie le nombre de proposition par mois pour une année donnée
|
* Renvoie le nombre de proposition par mois pour une année donnée
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function getNbByMonth($year)
|
Function getNbByMonth($year)
|
||||||
{
|
{
|
||||||
$result = array();
|
|
||||||
$sql = "SELECT date_format(datep,'%m') as dm, count(*) FROM llx_propal";
|
$sql = "SELECT date_format(datep,'%m') as dm, count(*) FROM llx_propal";
|
||||||
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
||||||
$sql .= " GROUP BY dm DESC";
|
$sql .= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($i);
|
|
||||||
$j = $row[0] * 1;
|
|
||||||
$result[$j] = $row[1];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$this->db->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
return $this->_getNbByMonth($year, $sql);
|
||||||
{
|
|
||||||
$res[$i] = $result[$i] + 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
|
||||||
{
|
|
||||||
$data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoie le nombre de propale par année
|
* Renvoie le nombre de propale par année
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function getNbByYear()
|
Function getNbByYear()
|
||||||
{
|
{
|
||||||
$result = array();
|
|
||||||
$sql = "SELECT date_format(datep,'%Y') as dm, count(*) FROM llx_propal GROUP BY dm DESC WHERE fk_statut > 0";
|
$sql = "SELECT date_format(datep,'%Y') as dm, count(*) FROM llx_propal GROUP BY dm DESC WHERE fk_statut > 0";
|
||||||
if ($this->db->query($sql))
|
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($i);
|
|
||||||
$result[$i] = $row;
|
|
||||||
|
|
||||||
$i++;
|
return $this->_getNbByYear($sql);
|
||||||
}
|
|
||||||
$this->db->free();
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Renvoie le nombre de propale par mois pour une année donnée
|
* Renvoie le nombre de propale par mois pour une année donnée
|
||||||
@ -114,31 +61,11 @@ class PropaleStats
|
|||||||
*/
|
*/
|
||||||
Function getAmountByMonth($year)
|
Function getAmountByMonth($year)
|
||||||
{
|
{
|
||||||
$result = array();
|
|
||||||
$sql = "SELECT date_format(datep,'%m') as dm, sum(price) FROM llx_propal";
|
$sql = "SELECT date_format(datep,'%m') as dm, sum(price) FROM llx_propal";
|
||||||
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
||||||
$sql .= " GROUP BY dm DESC";
|
$sql .= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
return $this->_getAmountByMonth($year, $sql);
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($i);
|
|
||||||
$j = $row[0] * 1;
|
|
||||||
$result[$j] = $row[1];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$this->db->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
|
||||||
{
|
|
||||||
$res[$i] = $result[$i] + 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -146,31 +73,11 @@ class PropaleStats
|
|||||||
*/
|
*/
|
||||||
Function getAverageByMonth($year)
|
Function getAverageByMonth($year)
|
||||||
{
|
{
|
||||||
$result = array();
|
|
||||||
$sql = "SELECT date_format(datep,'%m') as dm, avg(price) FROM llx_propal";
|
$sql = "SELECT date_format(datep,'%m') as dm, avg(price) FROM llx_propal";
|
||||||
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
$sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
|
||||||
$sql .= " GROUP BY dm DESC";
|
$sql .= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
return $this->_getAverageByMonth($year, $sql);
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($i);
|
|
||||||
$j = $row[0] * 1;
|
|
||||||
$result[$j] = $row[1];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$this->db->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
|
||||||
{
|
|
||||||
$res[$i] = $result[$i] + 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user