[ 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: commerciaux.po.class.php,v 1.6 2005/11/29 09:56:25 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/commerciaux/commerciaux.po.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/graph.class.php"); 24 25 class GraphCommerciauxPO { 26 27 Function GraphCommerciauxPO($DB, $file) 28 { 29 $this->db = $DB; 30 $this->file = $file; 31 32 $this->client = 0; 33 $this->titre = "Prises d'ordre mensuelle"; 34 $this->showframe = true; 35 $this->barcolor = array("green","blue","yellow","pink","orange"); 36 $this->commerciaux = array(2,5,7,18); 37 } 38 39 Function GraphMakeGraph() 40 { 41 $width = 800; 42 $height = 300; 43 $graph = new Graph($width, $height,"auto"); 44 $graph->SetScale("textlin"); 45 46 $graph->yaxis->scale->SetGrace(20); 47 $graph->SetFrame($this->showframe); 48 49 $graph->img->SetMargin(50,120,20,35); 50 $gbspl = array(); 51 $i = 0; 52 53 $sql = "SELECT rowid, firstname, name"; 54 $sql .= " FROM ".MAIN_DB_PREFIX."user"; 55 $resql = $this->db->query($sql); 56 $comm_names = array(); 57 if ($resql) 58 { 59 while ($row = $this->db->fetch_row($resql)) 60 { 61 $comm_names[$row[0]]= $row[1];//." ".$row[2]; 62 } 63 } 64 $datetime = time(); 65 66 67 $sql = "SELECT date_format(datepo, '%m'), sum(montant)"; 68 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p"; 69 $sql .= " WHERE p.fk_distributeur > 0"; 70 $sql .= " AND date_format(datepo, '%Y') = '".strftime('%Y',$datetime)."'"; 71 $sql .= " GROUP BY date_format(datepo, '%Y%m')"; 72 $resql = $this->db->query($sql); 73 $x_dis_datas = array(); 74 if ($resql) 75 { 76 while ($row = $this->db->fetch_row($resql)) 77 { 78 $x_dis_datas[$row[0]]= $row[1]; 79 } 80 } 81 else 82 { 83 print $sql; 84 } 85 86 87 foreach ($this->commerciaux as $commercial) 88 { 89 $datas = array(); 90 $xdatas = array(); 91 $sql = "SELECT date_format(datepo, '%m'), sum(montant)"; 92 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p"; 93 $sql .= " WHERE p.fk_commercial = ".$commercial; 94 $sql .= " AND date_format(datepo, '%Y') = '".strftime('%Y',$datetime)."'"; 95 $sql .= " GROUP BY date_format(datepo, '%Y%m')"; 96 $resql = $this->db->query($sql); 97 98 if ($resql) 99 { 100 while ($row = $this->db->fetch_row($resql)) 101 { 102 $xdatas[$row[0]]= $row[1]; 103 } 104 } 105 else 106 { 107 print $sql; 108 } 109 110 for ($j = 0; $j < 12 ; $j++) 111 { 112 $datas[$j] = 0; // on pre-remplit de 0 sinon bug de jpgraph 113 if ($xdatas[substr("00".($j+1),-2)]) 114 $datas[$j] = $xdatas[substr("00".($j+1),-2)]; 115 } 116 117 if ($commercial == 18) 118 { 119 for ($j = 0; $j < 12 ; $j++) 120 { 121 if ($x_dis_datas[substr("00".($j+1),-2)]) 122 { 123 $datas[$j] = $datas[$j] + $x_dis_datas[substr("00".($j+1),-2)]; 124 } 125 } 126 } 127 128 $bplot = new BarPlot($datas); 129 $bplot->SetFillColor($this->barcolor[$i]); 130 $bplot->SetLegend($comm_names[$commercial]); 131 if ($commercial == 18) 132 { 133 $bplot->SetLegend($comm_names[$commercial]."+DIS"); 134 } 135 //$bplot->value->Show(); 136 //$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); 137 //$bplot->value->SetAngle(45); 138 //$bplot->value->SetFormat('%0.1f'); 139 140 array_push($gbspl, $bplot); 141 $i++; 142 } 143 144 $gbplot = new GroupBarPlot ($gbspl); 145 146 // Adjust the legend position 147 $graph->legend->Pos(0.86,0.1,"left","top"); 148 149 $graph->Add($gbplot); 150 151 $graph->xaxis->scale->SetGrace(20); 152 153 $graph->title->Set($this->titre); 154 $labels= array(); 155 for ($j = 0; $j < 12 ; $j++) 156 { 157 $labels[$j] = strtoupper(substr(strftime("%B",mktime(1,1,1,($j+1),1,2005)),0,1)); 158 } 159 160 161 $graph->xaxis->SetTickLabels($labels); 162 163 // Display the graph 164 $graph->img->SetImgFormat("png"); 165 166 print $graph->Stroke($this->file); 167 } 168 } 169 170 ?>
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 |
![]() |