/[dolibarr]/dolibarr/htdocs/telephonie/script/graph-statistiques-ca.php
ViewVC logotype

Diff of /dolibarr/htdocs/telephonie/script/graph-statistiques-ca.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by rodolphe, Tue Nov 8 15:04:55 2005 UTC revision 1.14 by rodolphe, Wed Nov 9 10:08:26 2005 UTC
# Line 43  require_once (DOL_DOCUMENT_ROOT."/teleph Line 43  require_once (DOL_DOCUMENT_ROOT."/teleph
43  $error = 0;  $error = 0;
44    
45  $datetime = time();  $datetime = time();
   
46  $date = strftime("%d%h%Y%Hh%Mm%S",$datetime);  $date = strftime("%d%h%Y%Hh%Mm%S",$datetime);
   
47  $month = strftime("%m", $datetime);  $month = strftime("%m", $datetime);
48  $year = strftime("%Y", $datetime);  $year = strftime("%Y", $datetime);
49    
# Line 74  $sql .= " WHERE graph IN ('factures.fact Line 72  $sql .= " WHERE graph IN ('factures.fact
72  $resql = $db->query($sql);  $resql = $db->query($sql);
73    
74    
75  $sql = "SELECT date_format(tf.date,'%m'), sum(tf.cout_vente), sum(tf.cout_achat), sum(tf.gain), count(tf.cout_vente)";  $sql = "SELECT date_format(tf.date,'%Y%m'), sum(tf.cout_vente), sum(tf.cout_achat), sum(tf.gain), count(tf.cout_vente)";
76    
77  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf";  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf";
78  $sql .= " GROUP BY date_format(tf.date,'%Y%m') ASC ";  $sql .= " GROUP BY date_format(tf.date,'%Y%m') ASC ";
# Line 95  if ($resql) Line 93  if ($resql)
93    $gain_moyen = array();    $gain_moyen = array();
94    
95    $num = $db->num_rows($resql);    $num = $db->num_rows($resql);
   
96    $i = 0;    $i = 0;
97    
98    while ($i < $num)    while ($i < $num)
# Line 118  if ($resql) Line 115  if ($resql)
115        $cout_vente_moyen[$i] = ($row[1]/$row[4]);        $cout_vente_moyen[$i] = ($row[1]/$row[4]);
116        $nb_factures[$i] = $row[4];        $nb_factures[$i] = $row[4];
117        $labels[$i] = $row[0];        $labels[$i] = $row[0];
118          $short_labels[$i] = substr($row[0],-2);
119    
120        $sqli = " INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats";        $sqli = " INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats";
121        $sqli .= " (graph, ord, legend, valeur) VALUES (";        $sqli .= " (graph, ord, legend, valeur) VALUES (";
# Line 142  else Line 140  else
140    print $db->error();    print $db->error();
141  }  }
142  $file = $img_root . "/factures/ca_mensuel.png";  $file = $img_root . "/factures/ca_mensuel.png";
143    print "Graph $file\n";
144  $graph = new GraphBar ($db, $file);  $graph = new GraphBar ($db, $file);
145  $graph->titre = "Chiffre d'affaire par mois en euros HT";  $graph->titre = "Chiffre d'affaire par mois en euros HT";
146  $graph->width = 440;  $graph->width = 440;
147  $graph->GraphDraw($file, $cout_vente, $labels);  $graph->GraphDraw($file, $cout_vente, $short_labels);
148    
149  $file = $img_root . "/factures/facture_moyenne.png";  $file = $img_root . "/factures/facture_moyenne.png";
150    print "Graph $file\n";
151  $graph = new GraphBar ($db, $file, $labels);  $graph = new GraphBar ($db, $file, $labels);
152  $graph->titre = "Facture moyenne";  $graph->titre = "Facture moyenne";
153  $graph->barcolor = "blue";  $graph->barcolor = "blue";
154  $graph->width = 440;  $graph->width = 440;
155  $graph->GraphDraw($file, $cout_vente_moyen, $labels);  $graph->GraphDraw($file, $cout_vente_moyen, $short_labels);
156    
157  $file = $img_root . "/factures/gain_mensuel.png";  $file = $img_root . "/factures/gain_mensuel.png";
158    print "Graph $file\n";
159  $graph = new GraphBar ($db, $file);  $graph = new GraphBar ($db, $file);
160  $graph->titre = "Gain par mois en euros HT";  $graph->titre = "Gain par mois en euros HT";
161  $graph->width = 440;  $graph->width = 440;
162  $graph->GraphDraw($file, $gain, $labels);  $graph->GraphDraw($file, $gain, $short_labels);
163    
164  $file = $img_root . "/factures/gain_moyen.png";  $file = $img_root . "/factures/gain_moyen.png";
165    print "Graph $file\n";
166  $graph = new GraphBar ($db, $file);  $graph = new GraphBar ($db, $file);
167  $graph->titre = "Gain moyen par facture par mois";  $graph->titre = "Gain moyen par facture par mois";
168  $graph->width = 440;  $graph->width = 440;
169  $graph->barcolor = "blue";  $graph->barcolor = "blue";
170  $graph->GraphDraw($file, $gain_moyen, $labels);  $graph->GraphDraw($file, $gain_moyen, $short_labels);
171    
172  $file = $img_root . "/factures/nb_facture.png";  $file = $img_root . "/factures/nb_facture.png";
173    print "Graph $file\n";
174  $graph = new GraphBar ($db, $file);  $graph = new GraphBar ($db, $file);
175  $graph->titre = "Nb de facture mois";  $graph->titre = "Nb de facture mois";
176  $graph->width = 440;  $graph->width = 440;
177  $graph->barcolor = "yellow";  $graph->barcolor = "yellow";
178  $graph->GraphDraw($file, $nb_factures, $labels);  $graph->GraphDraw($file, $nb_factures, $short_labels);
   
179    
180    
181  $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";  $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";
# Line 264  if ($resql) Line 266  if ($resql)
266    while ($i < $num)    while ($i < $num)
267      {      {
268        $row = $db->fetch_row($resql);            $row = $db->fetch_row($resql);    
   
269        $cvc[$row[0]] = $row[1];        $cvc[$row[0]] = $row[1];
270    
271        $i++;        $i++;
# Line 280  $i = 0; Line 281  $i = 0;
281  foreach ($labels as $labl)  foreach ($labels as $labl)
282  {  {
283    $cout_vente_prelev[$i] = $cvp[$labl];    $cout_vente_prelev[$i] = $cvp[$labl];
284    $cout_vente_autre[$i] = $cva[$labl];    $cout_vente_autre[$i]  = $cva[$labl];
285    $cout_achat[$i] = $cvc[$labl];    $cout_achat[$i]        = $cvc[$labl];
286    $labels[$i] = substr($labl, -2);    $labels[$i] = substr($labl, -2);
287    $i++;    $i++;
288  }  }
289    
290    
291  $file = $img_root . "/factures/ca_mensuel_preleve.png";  $file = $img_root . "/factures/ca_mensuel_preleve.png";
292    print "Graph $file\n";
293  $graph = new GraphBarAccumul ($db, $file);  $graph = new GraphBarAccumul ($db, $file);
294  $graph->titre = "Chiffre d'affaire par méthode de réglement";  $graph->titre = "Chiffre d'affaire par méthode de réglement";
295  $graph->width = 640;  $graph->width = 640;
# Line 296  $graph->barcolor = "yellow"; Line 298  $graph->barcolor = "yellow";
298    
299  $xdatas[0] = array($cout_vente_prelev, $cout_vente_autre);  $xdatas[0] = array($cout_vente_prelev, $cout_vente_autre);
300  $xdatas[1] = array($cout_achat);  $xdatas[1] = array($cout_achat);
301    print_r($xdatas);
302  $graph->legend[0][0] = "Factures prélevées";  $graph->legend[0][0] = "Factures prélevées";
303  $graph->legend[0][1] = "Factures non-prélevées";  $graph->legend[0][1] = "Factures non-prélevées";
304  $graph->legend[1][0] = "Coût fournisseur";  $graph->legend[1][0] = "Coût fournisseur";

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26