Nouveau fichier
This commit is contained in:
parent
b26b96b8d7
commit
3ff8a09c1f
125
htdocs/telephonie/script/graph-statistiques-distributeurs.php
Normal file
125
htdocs/telephonie/script/graph-statistiques-distributeurs.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 relatifs aux distributeurs
|
||||
*
|
||||
*/
|
||||
require ("../../master.inc.php");
|
||||
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php");
|
||||
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
|
||||
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/commercial.ca.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/commercial.gain.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/groupes/groupe.gain.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/groupes/groupe.ca.class.php");
|
||||
|
||||
$error = 0;
|
||||
|
||||
/*
|
||||
* Création des répertoires
|
||||
*
|
||||
*/
|
||||
$dirs[0] = DOL_DATA_ROOT."/graph/";
|
||||
$dirs[1] = DOL_DATA_ROOT."/graph/telephonie/";
|
||||
$dirs[2] = DOL_DATA_ROOT."/graph/telephonie/distributeurs/";
|
||||
|
||||
$img_root = DOL_DATA_ROOT."/graph/telephonie/";
|
||||
|
||||
if (is_array($dirs))
|
||||
{
|
||||
foreach ($dirs as $key => $value)
|
||||
{
|
||||
$dir = $value;
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! @mkdir($dir, 0755))
|
||||
{
|
||||
print "Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer.";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $dir ." créé\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Distributeurs
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT distinct fk_distributeur";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($row = $db->fetch_row($resql))
|
||||
{
|
||||
/* Gain */
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/distributeurs/distributeur.gain.class.php");
|
||||
$dir = $img_root . "distributeurs/".$row[0]."/";
|
||||
_cdir($dir);
|
||||
$file = $dir."gain.mensuel.png";
|
||||
if ($verbose) print "Graph : gain distributeur $file\n";
|
||||
$graph = new GraphDistributeurGain($db, $file);
|
||||
$graph->width = 500;
|
||||
$graph->GraphMakeGraph($row[0]);
|
||||
|
||||
/* Commission */
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/distributeurs/distributeur.commission.class.php");
|
||||
$dir = $img_root . "distributeurs/".$row[0]."/";
|
||||
_cdir($dir);
|
||||
$file = $dir."commission.mensuel.png";
|
||||
if ($verbose) print "Graph : commission distributeur $file\n";
|
||||
$graph = new GraphDistributeurCommission($db, $file);
|
||||
$graph->width = 500;
|
||||
$graph->GraphMakeGraph($row[0]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _cdir($dir)
|
||||
{
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! @mkdir($dir, 0755))
|
||||
{
|
||||
print "Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer.";
|
||||
}
|
||||
else
|
||||
{
|
||||
//print $dir ." créé\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -0,0 +1,93 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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$
|
||||
*
|
||||
*/
|
||||
|
||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
|
||||
|
||||
class GraphDistributeurCommission extends GraphBar {
|
||||
|
||||
Function GraphDistributeurCommission($DB, $file)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->file = $file;
|
||||
|
||||
$this->client = 0;
|
||||
$this->titre = "Commission mensuelle";
|
||||
|
||||
$this->barcolor = "orange";
|
||||
$this->showframe = true;
|
||||
}
|
||||
|
||||
Function GraphMakeGraph($distributeur=0)
|
||||
{
|
||||
$num = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";
|
||||
$sql .= " WHERE graph='distributeur.commission.mensuel.".$distributeur."';";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
$sql = "SELECT date, montant";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission";
|
||||
$sql .= " WHERE fk_distributeur = ".$distributeur;
|
||||
$sql .= " ORDER BY date ASC";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
$j = -1;
|
||||
$datas = array();
|
||||
$labels = array();
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
|
||||
$datas[$i] = $row[1];
|
||||
$labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2);
|
||||
|
||||
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats";
|
||||
$sqli .= " (graph,ord,legend,valeur)";
|
||||
$sqli .= " VALUES ('distributeur.commission.mensuel.".$distributeur."'";
|
||||
$sqli .= ",'$i','".$row[0]."','".$datas[$i]."');";
|
||||
|
||||
$resqli = $this->db->query($sqli);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . ' ' . $sql;
|
||||
}
|
||||
|
||||
if (sizeof($datas))
|
||||
{
|
||||
$this->GraphDraw($this->file, $datas, $labels);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user