dolibarr/htdocs/telephonie/stats/ProcessGraphLignes.class.php

172 lines
4.8 KiB
PHP
Raw Normal View History

2005-03-15 17:55:55 +01:00
<?php
2006-03-08 11:32:38 +01:00
/* Copyright (C) 2005-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2005-03-15 17:55:55 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*
* Generation des graphiques clients
*
*
*/
require ("../../master.inc.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/ca.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/gain.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbminutes.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/heureappel.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/joursemaine.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
/*
* Process
*
*/
class ProcessGraphLignes
{
var $ident;
2005-08-24 10:55:11 +02:00
function ProcessGraphLignes( $db)
2005-03-15 17:55:55 +01:00
{
global $conf;
2005-03-15 17:55:55 +01:00
$this->ident = $ident;
$this->cpc = $cpc;
2005-08-24 10:55:11 +02:00
$this->db = $db;
$this->labels = array();
$this->nbminutes = array();
$this->nbcomm = array();
$this->duree_moyenne = array();
$this->vente = array();
$this->gain = array();
2005-03-15 17:55:55 +01:00
}
2005-08-24 10:55:11 +02:00
function go($ligne)
2005-03-15 17:55:55 +01:00
{
2005-08-24 10:55:11 +02:00
$this->ligne = $ligne;
$this->GetDatas();
2005-03-15 17:55:55 +01:00
$error = 0;
2005-08-24 10:55:11 +02:00
/* Chiffre d'affaire */
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/";
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$file = $img_root . $ligne."/graphca.png";
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$graphx = new GraphBar ($this->db, $file);
$graphx->ligne = $ligne;
$graphx->width = 360;
$graphx->titre = "Chiffre d'affaire (euros HT)";
$graphx->barcolor = "blue";
$graphx->show_console = 0 ;
$graphx->GraphDraw($file, $this->vente, $this->labels);
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
/* Gain */
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$file = $img_root . $ligne."/graphgain.png";
$graphx = new GraphBar ($this->db, $file);
$graphx->ligne = $ligne;
$graphx->width = 360;
$graphx->titre = "Gain (euros HT)";
$graphx->barcolor = "green";
$graphx->show_console = 0 ;
$graphx->GraphDraw($file, $this->gain, $this->labels);
/* Duree moyenne des appels */
$file = $img_root . $ligne."/graphappelsdureemoyenne.png";
$graphx = new GraphBar ($this->db, $file);
$graphx->ligne = $ligne;
$graphx->width = 360;
$graphx->titre = "Dur<EFBFBD>e moyenne";
$graphx->barcolor = "orange";
$graphx->show_console = 0 ;
$graphx->GraphDraw($file, $this->duree_moyenne, $this->labels);
/* Nb de communication */
$file = $img_root . $ligne."/nb-comm-mensuel.png";
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$graphx = new GraphBar ($this->db, $file);
$graphx->ligne = $ligne;
$graphx->width = 360;
$graphx->titre = "Nombre de communications";
$graphx->show_console = 0 ;
$graphx->GraphDraw($file, $this->nbcomm, $this->labels);
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
/* Nb de minutes */
$file = $img_root . $ligne."/nb-minutes-mensuel.png";
$graphx = new GraphBar ($this->db, $file);
$graphx->ligne = $ligne;
$graphx->width = 360;
$graphx->show_console = 0 ;
$graphx->titre = "Nombre de minutes";
$graphx->barcolor = "bisque2";
$graphx->GraphDraw($file, $this->nbminutes, $this->labels);
}
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
Function GetDatas()
{
$sql = "SELECT date_format(td.date,'%m'), sum(duree), count(*), sum(cout_vente), sum(fourn_montant)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
$sql .= " WHERE td.fk_ligne = ".$this->ligne;
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row();
$this->labels[$i] = $row[0];
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$this->nbminutes[$i] = ceil($row[1] / 60);
$this->nbcomm[$i] = $row[2];
$this->duree_moyenne[$i] = ($this->nbminutes[$i] / $this->nbcomm[$i]);
$this->vente[$i] = $row[3];
$this->gain[$i] = ($row[3] - $row[4]);
2005-03-15 17:55:55 +01:00
2005-08-24 10:55:11 +02:00
$i++;
}
$this->db->free();
}
else
{
dolibarr_syslog("Error");
2005-03-15 17:55:55 +01:00
}
}
}
?>