[ 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: graph-statistiques-commerciaux.php,v 1.11 2005/12/07 15:31:56 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/graph-statistiques-commerciaux.php,v $ 20 * 21 * 22 * Generation des graphiques relatifs aux commerciaux 23 * 24 */ 25 require ("../../master.inc.php"); 26 $verbose = 0; 27 for ($i = 1 ; $i <= sizeof($argv) ; $i++) 28 { 29 if ($argv[$i] == "-v") 30 $verbose = 1; 31 if ($argv[$i] == "-vv") 32 $verbose = 2; 33 } 34 35 require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); 36 require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php"); 37 require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php"); 38 require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php"); 39 40 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php"); 41 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php"); 42 43 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/commercial.ca.class.php"); 44 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/commercial.gain.class.php"); 45 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/groupes/groupe.gain.class.php"); 46 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/groupes/groupe.ca.class.php"); 47 $year = strftime("%Y",time()); 48 $error = 0; 49 50 /* 51 * Création des répertoires 52 * 53 */ 54 $dirs[0] = DOL_DATA_ROOT."/graph/"; 55 $dirs[1] = DOL_DATA_ROOT."/graph/telephonie/"; 56 $dirs[2] = DOL_DATA_ROOT."/graph/telephonie/commercials/"; 57 $dirs[2] = DOL_DATA_ROOT."/graph/telephonie/distributeurs/"; 58 59 $img_root = DOL_DATA_ROOT."/graph/telephonie/"; 60 61 if (is_array($dirs)) 62 { 63 foreach ($dirs as $key => $value) 64 { 65 $dir = $value; 66 67 if (! file_exists($dir)) 68 { 69 umask(0); 70 if (! @mkdir($dir, 0755)) 71 { 72 print "Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer."; 73 } 74 else 75 { 76 print $dir ." créé\n"; 77 } 78 } 79 } 80 } 81 82 $sql = "SELECT distinct fk_commercial_sign"; 83 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; 84 85 $resql = $db->query($sql); 86 if ($resql) 87 { 88 $num = $db->num_rows($resql); 89 $i = 0; 90 91 while ($i < $num) 92 { 93 $row = $db->fetch_row($resql); 94 95 /* Chiffre d'affaire mensuel */ 96 97 $file = $img_root . "commercials/".$row[0]."/ca.mensuel.$year.png"; 98 if ($verbose) print "CA ".$row[0]."\n"; 99 $graph = new GraphCommercialChiffreAffaire($db, $file, $year); 100 $graph->width = 400; 101 $graph->GraphMakeGraph($row[0]); 102 103 /* Gain */ 104 105 $file = $img_root . "commercials/".$row[0]."/gain.mensuel.$year.png"; 106 if ($verbose) print "Gain ".$row[0]."\n"; 107 $graph = new GraphCommercialGain($db, $file, $year); 108 $graph->width = 400; 109 $graph->GraphMakeGraph($row[0]); 110 111 /* 112 * Statut des lignes 113 * 114 */ 115 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/lignes/statut.class.php"); 116 117 $file = $img_root . "commercials/".$row[0]."/lignes.statut.png"; 118 if ($verbose) print "Graph : Lignes statut $file\n"; 119 $graph = new GraphLignesStatut($db, $file); 120 $graph->GraphMakeGraph($row[0]); 121 122 $i++; 123 } 124 } 125 126 /* 127 * Groupes 128 * 129 */ 130 $sql = "SELECT rowid"; 131 $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as u"; 132 133 $resql = $db->query($sql); 134 if ($resql) 135 { 136 $num = $db->num_rows($resql); 137 $i = 0; 138 139 while ($i < $num) 140 { 141 $row = $db->fetch_row($resql); 142 143 /* Gain */ 144 145 $file = $img_root . "commerciaux/groupes/".$row[0]."/gain.mensuel.png"; 146 if ($verbose) print "Graph : Lignes commandes$file\n"; 147 $graph = new GraphGroupeGain($db, $file); 148 $graph->width = 400; 149 $graph->GraphMakeGraph($row[0]); 150 151 /* Chiffre d'affaire */ 152 153 $file = $img_root . "commerciaux/groupes/".$row[0]."/ca.mensuel.png"; 154 if ($verbose) print "Graph : Lignes commandes$file\n"; 155 $graph = new GraphGroupeChiffreAffaire($db, $file); 156 $graph->width = 400; 157 $graph->GraphMakeGraph($row[0]); 158 159 $i++; 160 } 161 } 162 163 /* 164 * Contrats 165 * 166 */ 167 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/contrats.class.php"); 168 169 $file = $img_root . "commercials/contrats-suivis.png"; 170 if ($verbose) print "Graph : Commerciaux contrats $file\n"; 171 $graph = new GraphCommerciauxContrats($db, $file); 172 $graph->GraphMakeGraph("suivi"); 173 174 $file = $img_root . "commercials/contrats-signes.png"; 175 if ($verbose) print "Graph : Commerciaux contrats $file\n"; 176 $graph = new GraphCommerciauxContrats($db, $file); 177 $graph->GraphMakeGraph("signe"); 178 179 /* 180 * Prises d'ordres 181 * 182 */ 183 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/commerciaux/commercial.po.class.php"); 184 185 $sql = "SELECT date_format(datepo,'%Y%m'), sum(montant), fk_commercial, fk_distributeur"; 186 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre"; 187 $sql .= " WHERE year(now()) = year(datepo)"; 188 $sql .= " GROUP BY date_format(datepo,'%Y%m'), fk_commercial, fk_distributeur"; 189 $sql .= " ORDER BY date_format(datepo,'%Y%m') ASC"; 190 191 $resql = $db->query($sql); 192 if ($resql) 193 { 194 $datas_comm = array(); 195 $labels_comm = array(); 196 197 $datas_dist = array(); 198 $labels_dist = array(); 199 200 while ( $row = $db->fetch_row($resql) ) 201 { 202 $datas_comm[$row[2]][$row[0]] += $row[1]; 203 $datas_dist[$row[3]][$row[0]] += $row[1]; 204 } 205 206 foreach($datas_comm as $comm => $value) 207 { 208 //print $comm."\n"; 209 210 $file = $img_root . "commercials/".$comm."/po.$year.mensuel.png"; 211 if ($verbose) print "Graph : Lignes commandes$file\n"; 212 $graph = new GraphCommercialPO($db, $file); 213 $graph->width = 400; 214 $graph->GraphMakeGraph($value); 215 } 216 } 217 218 function _cdir($dir) 219 { 220 if (! file_exists($dir)) 221 { 222 umask(0); 223 if (! @mkdir($dir, 0755)) 224 { 225 print "Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer."; 226 } 227 else 228 { 229 //print $dir ." créé\n"; 230 } 231 } 232 } 233 234 ?>
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 |
![]() |