| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: ProcessGraphClients.class.php,v 1.9 2005/10/20 19:18:22 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/ProcessGraphClients.class.php,v $ 20 * 21 * 22 * Generation des graphiques clients 23 * 24 * 25 */ 26 require ("../../master.inc.php"); 27 28 require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); 29 require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php"); 30 require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php"); 31 require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php"); 32 33 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/ca.class.php"); 34 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/gain.class.php"); 35 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/heureappel.class.php"); 36 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/joursemaine.class.php"); 37 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php"); 38 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php"); 39 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php"); 40 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbminutes.class.php"); 41 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php"); 42 43 /* 44 * Process 45 * 46 */ 47 48 class ProcessGraphClients 49 { 50 var $ident; 51 52 function ProcessGraphClients( $ident , $cpc) 53 { 54 global $conf; 55 56 $this->ident = $ident; 57 $this->cpc = $cpc; 58 $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1); 59 } 60 61 function go() 62 { 63 dolibarr_syslog("Debut client ".$this->ident); 64 $error = 0; 65 66 $img_root = DOL_DATA_ROOT."/graph/telephonie/"; 67 68 $min = $this->ident * $this->cpc; 69 $max = ($this->ident + 1 ) * $this->cpc; 70 71 /* 72 * Lecture des clients 73 * 74 */ 75 $sql = "SELECT s.idp as socidp, s.nom, count(l.ligne) as ligne"; 76 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; 77 $sql .= ",".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; 78 $sql .= " WHERE l.fk_client_comm = s.idp "; 79 $sql .= " AND s.idp >= ".$min; 80 $sql .= " AND s.idp < ".$max; 81 $sql .= " GROUP BY s.idp"; 82 83 $resql = $this->db->query($sql); 84 85 if ($resql) 86 { 87 $clients = array(); 88 89 $num = $this->db->num_rows($resql); 90 print "$this->ident : $num client a traiter ($min - $max)\n"; 91 $i = 0; 92 93 while ($i < $num) 94 { 95 $obj = $this->db->fetch_object($resql); 96 $clients[$i] = $obj->socidp; 97 $i++; 98 } 99 $this->db->free($resql); 100 } 101 else 102 { 103 print $sql; 104 exit("Erreur recuperation des clients"); 105 } 106 107 if (sizeof($clients)) 108 { 109 foreach ($clients as $client) 110 { 111 $img_root = DOL_DATA_ROOT."/graph/".substr($client,-1)."/telephonie/client/"; 112 113 $file = $img_root . $client."/graphca.png"; 114 $graphca = new GraphCa($this->db, $file); 115 $graphca->client = $client; 116 $graphca->GraphDraw(); 117 118 $file = $img_root . $client."/graphgain.png"; 119 120 $graphgain = new GraphGain ($this->db, $file); 121 $graphgain->client = $client; 122 $graphgain->show_console = 0 ; 123 $graphgain->GraphDraw(); 124 125 $marge = 0; 126 127 if ($graphgain->total_cout > 0) 128 { 129 $marge = ( $graphgain->total_gain / $graphgain->total_ca * 100); 130 } 131 132 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_client_stats (fk_client_comm, gain, ca, cout, marge)"; 133 $sql .= " VALUES (".$client.",'".ereg_replace(",",".",$graphgain->total_gain)."'"; 134 $sql .= ",'".ereg_replace(",",".",$graphgain->total_ca)."'"; 135 $sql .= ",'".ereg_replace(",",".",$graphgain->total_cout)."'"; 136 $sql .= ",'".ereg_replace(",",".",$marge)."')"; 137 138 if (($graphgain->total_ca * $graphgain->total_gain * $graphgain->total_cout) <> 0) 139 { 140 $this->db->query($sql); 141 } 142 143 144 $file = $img_root . $client."/graphappelsdureemoyenne.png"; 145 146 $graphduree = new GraphAppelsDureeMoyenne ($this->db, $file); 147 $graphduree->client = $client; 148 $graphduree->show_console = 0 ; 149 $graphduree->Graph(); 150 151 $file = $img_root . $client."/nb-comm-mensuel.png"; 152 153 $graphx = new GraphCommNbMensuel ($this->db, $file); 154 $graphx->client = $client; 155 $graphx->show_console = 0 ; 156 $graphx->Graph(); 157 158 159 $file = $img_root . $client."/nb-minutes-mensuel.png"; 160 161 $graphx = new GraphCommNbMinutes ($this->db, $file); 162 $graphx->client = $client; 163 $graphx->show_console = 0 ; 164 $graphx->Graph(); 165 166 } 167 } 168 169 dolibarr_syslog("Fin client ".$this->ident); 170 171 } 172 } 173 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
|