Nouveau fichier
This commit is contained in:
parent
ec996a4300
commit
e89ad4007f
214
htdocs/telephonie/contrat/stats.php
Normal file
214
htdocs/telephonie/contrat/stats.php
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2004-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("./pre.inc.php");
|
||||||
|
|
||||||
|
$mesg = '';
|
||||||
|
|
||||||
|
llxHeader("","Téléphonie - Contrat");
|
||||||
|
|
||||||
|
if ($cancel == $langs->trans("Cancel"))
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Affichage
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($_GET["id"])
|
||||||
|
{
|
||||||
|
$contrat = new TelephonieContrat($db);
|
||||||
|
|
||||||
|
$result = $contrat->fetch($_GET["id"]);
|
||||||
|
|
||||||
|
if ( $result == 1 )
|
||||||
|
{
|
||||||
|
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||||
|
{
|
||||||
|
$h=0;
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id;
|
||||||
|
$head[$h][1] = $langs->trans("Contrat");
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
$nser = $contrat->count_associated_services();
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id;
|
||||||
|
if ($nser > 0)
|
||||||
|
{
|
||||||
|
$head[$h][1] = $langs->trans("Services")." (".$nser.")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$head[$h][1] = $langs->trans("Services");
|
||||||
|
}
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id;
|
||||||
|
$head[$h][1] = $langs->trans("Stats");
|
||||||
|
$hselected = $h;
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id;
|
||||||
|
$head[$h][1] = $langs->trans("Infos");
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
dolibarr_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref);
|
||||||
|
|
||||||
|
print_fiche_titre('Fiche Contrat', $mesg);
|
||||||
|
|
||||||
|
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||||
|
|
||||||
|
$client_comm = new Societe($db, $contrat->client_comm_id);
|
||||||
|
$client_comm->fetch($contrat->client_comm_id);
|
||||||
|
|
||||||
|
print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
|
||||||
|
print '<td colspan="2">Facturé : '.$contrat->facturable.'</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="20%">Client</td><td>';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
|
||||||
|
|
||||||
|
print $client_comm->nom.'</a></td><td colspan="2">'.$client_comm->code_client;
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$commercial = new User($db, $contrat->commercial_sign_id);
|
||||||
|
$commercial->fetch();
|
||||||
|
$commercial_suiv = new User($db, $contrat->commercial_suiv_id);
|
||||||
|
$commercial_suiv->fetch();
|
||||||
|
|
||||||
|
print '<tr><td width="20%">Commercial Suivi/Signature</td>';
|
||||||
|
print '<td colspan="3">'.$commercial_suiv->fullname.'/'.$commercial->fullname.'</td></tr>';
|
||||||
|
|
||||||
|
/* Fin Contacts */
|
||||||
|
|
||||||
|
print "</table><br />";
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
|
||||||
|
print '<tr><td width="50%" align="center">Chiffre d\'affaire</td>';
|
||||||
|
print '<td width="50%" align="center">Gain</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
$mesg_no_graph = 'Nous avons pas assez de données à ce jour pour générer ce graphique.';
|
||||||
|
|
||||||
|
$img_root = DOL_DATA_ROOT."/graph/".substr($contrat->id,-1)."/telephonie/contrat/";
|
||||||
|
|
||||||
|
$file = $img_root.$contrat->id."/graphca.png";
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $mesg_no_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
$file = $img_root.$contrat->id."/graphgain.png";
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $mesg_no_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="50%" align="center">Appels</td>';
|
||||||
|
print '<td width="50%" align="center">-</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
$file = $img_root.$contrat->id."/graphappelsdureemoyenne.png";
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $mesg_no_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
print " ";
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="50%" align="center">Communications</td>';
|
||||||
|
print '<td width="50%" align="center">Minutes</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
$file = $img_root.$contrat->id."/nb-comm-mensuel.png";
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $mesg_no_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td><td width="50%" valign="top" align="center">';
|
||||||
|
|
||||||
|
$file = $img_root.$contrat->id."/nb-minutes-mensuel.png";
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $mesg_no_graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr></table>';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Barre d'action */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||||
|
?>
|
||||||
@ -31,6 +31,7 @@ class GraphAppelsDureeMoyenne extends GraphBrouzouf{
|
|||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
|
||||||
$this->client = 0;
|
$this->client = 0;
|
||||||
|
$this->contrat = 0;
|
||||||
$this->titre = "Durée moyenne des appels";
|
$this->titre = "Durée moyenne des appels";
|
||||||
|
|
||||||
//$this->type = "LinePlot";
|
//$this->type = "LinePlot";
|
||||||
@ -42,15 +43,14 @@ class GraphAppelsDureeMoyenne extends GraphBrouzouf{
|
|||||||
Function GraphDraw()
|
Function GraphDraw()
|
||||||
{
|
{
|
||||||
$num = 0;
|
$num = 0;
|
||||||
$ligne = new LigneTel($this->db);
|
|
||||||
|
|
||||||
if ($this->client == 0)
|
if ($this->client == 0 && $this->contrat == 0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT date_format(date,'%Y%m'), sum(duree), count(duree)";
|
$sql = "SELECT date_format(date,'%Y%m'), sum(duree), count(duree)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
|
||||||
$sql .= " GROUP BY date_format(date,'%Y%m') ASC ";
|
$sql .= " GROUP BY date_format(date,'%Y%m') ASC ";
|
||||||
}
|
}
|
||||||
else
|
elseif ($this->client > 0 && $this->contrat == 0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT date_format(td.date,'%Y%m'), sum(td.duree), count(td.duree)";
|
$sql = "SELECT date_format(td.date,'%Y%m'), sum(td.duree), count(td.duree)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
|
||||||
@ -58,9 +58,19 @@ class GraphAppelsDureeMoyenne extends GraphBrouzouf{
|
|||||||
|
|
||||||
$sql .= " WHERE td.ligne = s.ligne";
|
$sql .= " WHERE td.ligne = s.ligne";
|
||||||
$sql .= " AND s.fk_client_comm = ".$this->client;
|
$sql .= " AND s.fk_client_comm = ".$this->client;
|
||||||
|
|
||||||
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
|
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
|
||||||
}
|
}
|
||||||
|
elseif ($this->client == 0 && $this->contrat > 0)
|
||||||
|
{
|
||||||
|
$sql = "SELECT date_format(td.date,'%Y%m'), sum(td.duree), count(td.duree)";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
|
||||||
|
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";
|
||||||
|
|
||||||
|
$sql .= " WHERE td.ligne = s.ligne";
|
||||||
|
$sql .= " AND s.fk_contrat = ".$this->contrat;
|
||||||
|
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
|||||||
105
htdocs/telephonie/stats/graph/comm.nbminutes.class.php
Normal file
105
htdocs/telephonie/stats/graph/comm.nbminutes.class.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?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 GraphCommNbMinutes extends GraphBar{
|
||||||
|
|
||||||
|
|
||||||
|
Function GraphCommNbMinutes($DB, $file)
|
||||||
|
{
|
||||||
|
$this->name = "comm.nbminutes";
|
||||||
|
$this->db = $DB;
|
||||||
|
$this->file = $file;
|
||||||
|
$this->showframe = true;
|
||||||
|
$this->client = 0;
|
||||||
|
$this->contrat = 0;
|
||||||
|
$this->titre = "Nombre de minutes";
|
||||||
|
|
||||||
|
$this->barcolor = "bisque2";
|
||||||
|
|
||||||
|
$this->datas = array();
|
||||||
|
$this->labels = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Graph($datas='', $labels='')
|
||||||
|
{
|
||||||
|
$this->GetDatas();
|
||||||
|
|
||||||
|
if (sizeof($this->datas))
|
||||||
|
{
|
||||||
|
$this->GraphDraw($this->file, $this->datas, $this->labels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function GetDatas()
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(td.date,'%Y%m'), sum(duree)";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
|
||||||
|
|
||||||
|
if ($this->client == 0 && $this->contrat == 0)
|
||||||
|
{
|
||||||
|
$sql .= " GROUP BY date_format(td.date, '%Y%m') ASC";
|
||||||
|
}
|
||||||
|
elseif ($this->client > 0 && $this->contrat == 0)
|
||||||
|
{
|
||||||
|
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";
|
||||||
|
|
||||||
|
$sql .= " WHERE td.ligne = s.ligne";
|
||||||
|
$sql .= " AND s.fk_client_comm = ".$this->client;
|
||||||
|
|
||||||
|
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
|
||||||
|
}
|
||||||
|
elseif ($this->client == 0 && $this->contrat > 0)
|
||||||
|
{
|
||||||
|
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";
|
||||||
|
|
||||||
|
$sql .= " WHERE td.ligne = s.ligne";
|
||||||
|
$sql .= " AND s.fk_contrat = ".$this->contrat;
|
||||||
|
|
||||||
|
$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] = substr($row[0],4,2) . '/'.substr($row[0],2,2);
|
||||||
|
$this->datas[$i] = $row[1];
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$this->db->free();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user