Nouvelle mthode de graph pour prendre en compte les lignes rejetes
This commit is contained in:
parent
378d8774a4
commit
8cddfac668
@ -20,9 +20,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/baracc.class.php");
|
||||
|
||||
class GraphLignesCommandesWeek extends GraphBar {
|
||||
class GraphLignesCommandesWeek extends GraphBarAcc {
|
||||
|
||||
Function GraphLignesCommandesWeek($DB, $file)
|
||||
{
|
||||
@ -32,7 +32,7 @@ class GraphLignesCommandesWeek extends GraphBar {
|
||||
$this->client = 0;
|
||||
$this->titre = "Commandes Lignes par semaine";
|
||||
|
||||
$this->barcolor = "blue";
|
||||
$this->barcolor = "green";
|
||||
$this->showframe = true;
|
||||
}
|
||||
|
||||
@ -40,7 +40,9 @@ class GraphLignesCommandesWeek extends GraphBar {
|
||||
{
|
||||
$num = 0;
|
||||
|
||||
$sql = "SELECT date_format(date_commande,'%x%v'), count(*)";
|
||||
$labels = array();
|
||||
|
||||
$sql = "SELECT date_format(date_commande,'%y%v'), count(*)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||
$sql .= " WHERE date_commande IS NOT NULL ";
|
||||
|
||||
@ -49,85 +51,106 @@ class GraphLignesCommandesWeek extends GraphBar {
|
||||
$sql .= " AND fk_commercial = ".$commercial;
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY date_format(date_commande,'%x%v') ASC";
|
||||
$sql .= " GROUP BY date_format(date_commande,'%y%v') ASC";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
$datas = array();
|
||||
$labels = array();
|
||||
$oldyear == 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
$row = $this->db->fetch_row();
|
||||
|
||||
if ($oldyear == 0)
|
||||
{
|
||||
$oldyear = substr($row[0],0,4);
|
||||
}
|
||||
|
||||
if ($oldyear == substr($row[0],0,4) && $j > 0 && substr($row[0],-2) <> ($labels[$j-1] +1 ) )
|
||||
{
|
||||
$datas[$j] = 0;
|
||||
$labels[$j] = $labels[$j-1] + 1;
|
||||
$j++;
|
||||
}
|
||||
|
||||
$datas[$j] = $row[1];
|
||||
$labels[$j] = substr($row[0],-2);
|
||||
|
||||
$row = $this->db->fetch_row();
|
||||
$datas[$row[0]] = $row[1];
|
||||
array_push($labels, $row[0]);
|
||||
$i++;
|
||||
$j++;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . ' ' . $sql;
|
||||
}
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
/* Lignes rejetées */
|
||||
$sql = "SELECT date_format(date_commande,'%y%v'), count(*)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||
$sql .= " WHERE date_commande IS NOT NULL ";
|
||||
$sql .= " AND statut = 7";
|
||||
|
||||
if ($commercial > 0)
|
||||
{
|
||||
$sql .= " AND fk_commercial = ".$commercial;
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY date_format(date_commande,'%y%v') ASC";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
$datas_rej = array();
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row();
|
||||
|
||||
$datas_rej[$row[0]] = $row[1];
|
||||
array_push($labels, $row[0]);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
/* == */
|
||||
|
||||
$datas_new = array();
|
||||
$labels_new = array();
|
||||
$j = 0 ;
|
||||
|
||||
$datas_new[0] = $datas[0];
|
||||
$labels_new[0] = ceil(substr($labels[0],-2));
|
||||
$max = max($labels);
|
||||
$week = $max;
|
||||
$year = substr($week,0,2);
|
||||
$smwee = substr($max, -2);
|
||||
|
||||
for ($i = 1 ; $i < sizeof($labels) ; $i++)
|
||||
for ($i = 0 ; $i < 18 ; $i++)
|
||||
{
|
||||
if (substr($labels[$i], -2) - substr($labels[$i-1], -2) > 1)
|
||||
|
||||
$datas_new[$i] = $datas[$year.$smwee] - $datas_rej[$year.$smwee];
|
||||
$datas_new_rej[$i] = $datas_rej[$year.$smwee];
|
||||
$labels_new[$i] = $smwee;
|
||||
|
||||
if (($smwee - 1) == 0)
|
||||
{
|
||||
for ($k = 1 ; $k < ($labels[$i] - $labels[$i-1]) ; $k++)
|
||||
$smwee = strftime("%V",mktime(12,0,2,12,31,"20".substr("00".($year - 1), -2)));
|
||||
|
||||
if ($smwee == '01')
|
||||
{
|
||||
$datas_new[$i+$j] = 0;
|
||||
$labels_new[$i+$j] = ceil(substr($labels[$i-1], -2) + $k) ; // suppression du 0
|
||||
|
||||
$j++;
|
||||
$smwee = 52;
|
||||
}
|
||||
|
||||
$year = substr("00".($year - 1), -2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$smwee = substr("00".($smwee -1), -2);
|
||||
}
|
||||
|
||||
$datas_new[$i+$j] = $datas[$i];
|
||||
$labels_new[$i+$j] = ceil(substr($labels[$i], - 2));
|
||||
}
|
||||
|
||||
$nbel = sizeof($datas_new);
|
||||
$datas_new = array_reverse($datas_new);
|
||||
$datas_new_rej = array_reverse($datas_new_rej);
|
||||
$labels_new = array_reverse($labels_new);
|
||||
|
||||
for ($i = 0 ; $i < ($nbel - 18) ; $i++)
|
||||
{
|
||||
array_shift($datas_new);
|
||||
array_shift($labels_new);
|
||||
}
|
||||
|
||||
|
||||
$this->GraphDraw($this->file, $datas_new, $labels_new);
|
||||
$this->GraphDraw($this->file, $datas_new, $labels_new, $datas_new_rej);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user