From 3c04ef681a145145cde8aaf75a13f22cbcce24a2 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 15 Jun 2005 14:04:51 +0000 Subject: [PATCH] Bugfix --- .../commande/commande.tableur.class.php | 5 + .../graph-statistiques-communications.php | 159 ++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 htdocs/telephonie/script/graph-statistiques-communications.php diff --git a/htdocs/telephonie/fournisseur/commande/commande.tableur.class.php b/htdocs/telephonie/fournisseur/commande/commande.tableur.class.php index 47e45cdaf59..48e26dbc8f4 100644 --- a/htdocs/telephonie/fournisseur/commande/commande.tableur.class.php +++ b/htdocs/telephonie/fournisseur/commande/commande.tableur.class.php @@ -249,6 +249,11 @@ class CommandeMethodeTableur extends CommandeMethode $worksheet->write($j, 5, "Ajouter", $formatccb); $worksheet->write($j, 6, strftime("%d/%m/%y",$this->date), $formatcc); } + elseif ($obj->statut == 8) + { + $worksheet->write($j, 5, "Ajouter", $formatccb); + $worksheet->write($j, 6, strftime("%d/%m/%y",$this->date), $formatcc); + } elseif($obj->statut == 4) { $worksheet->write($j, 5, "A Résilier", $formatccbr); diff --git a/htdocs/telephonie/script/graph-statistiques-communications.php b/htdocs/telephonie/script/graph-statistiques-communications.php new file mode 100644 index 00000000000..da6ae281668 --- /dev/null +++ b/htdocs/telephonie/script/graph-statistiques-communications.php @@ -0,0 +1,159 @@ + + * + * 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$ + * + * + * Generation des graphiques + * + * + * + */ +require ("../../master.inc.php"); + +require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php"); + +$img_root = DOL_DATA_ROOT."/graph/telephonie/"; + +$nbval = 14; + +$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; +$sql .= " WHERE graph = 'communications.duree'"; + +$resql = $db->query($sql); + +$sql = "SELECT date_format(date, '%m'), sum(duree), count(duree)"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; +$sql .= " GROUP BY date_format(date, '%Y%m') ASC"; + +$resql = $db->query($sql); + + +_deal($db, $resql, "communications.duree", $kilomindurees, $labels); + + +$file = $img_root . "communications/duree.png"; +$graphgain = new GraphBar ($db, $file); +$graphgain->show_console = 0 ; +$graphgain->width = 480 ; +$graphgain->titre = "Nb minutes (milliers)"; +print $graphgain->titre."\n"; +$graphgain->GraphDraw($file, $kilomindurees, $labels); + +/* + * + * + */ + +$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; +$sql .= " WHERE graph = 'communications.duree_mobiles'"; + +$resql = $db->query($sql); + +$sql = "SELECT date_format(date, '%m'), sum(duree), count(duree)"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; +$sql .= " WHERE numero like '06%'"; +$sql .= " GROUP BY date_format(date, '%Y%m') ASC"; + +$resql = $db->query($sql); + +if ($resql) +{ + $durees = array(); + $kilomindurees = array(); + $labels = array(); + + $num = $db->num_rows($resql); + $lim = ($num - $nbval); + $i = 0; + $j = 0; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($i >= $lim ) + { + $labels[$j] = $row[0]; + $durees[$j] = $row[1]; + $kilomindurees_mob[$j] = ($row[1]/60000); + + $sqli = " INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; + $sqli .= " (graph, ord, legend, valeur) VALUES ("; + $sqli .= "'communications.duree_mobiles','".$j."','".$row[0]."','".($row[1]/60)."')"; + + if (!$resqli = $db->query($sqli)) + { + print $db->error(); + } + $j++; + } + $i++; + } +} + +$file = $img_root . "communications/duree_mob.png"; +$graphgain = new GraphBar ($db, $file); +$graphgain->show_console = 0 ; +$graphgain->width = 480 ; +$graphgain->titre = "Nb minutes -> portables (milliers)"; +print $graphgain->titre."\n"; +$graphgain->GraphDraw($file, $kilomindurees_mob, $labels); + + + + + +function _deal($db, $resql, $graph, &$data, &$labels) +{ + global $nbval; + +if ($resql) +{ + + $num = $db->num_rows($resql); + $lim = ($num - $nbval); + $i = 0; + $j = 0; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + + if ($i >= $lim ) + { + $labels[$j] = $row[0]; + $data[$j] = ($row[1]/60000); + + $sqli = " INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; + $sqli .= " (graph, ord, legend, valeur) VALUES ("; + $sqli .= "'".$graph."','".$j."','".$row[0]."','".($row[1]/60)."')"; + + if (!$resqli = $db->query($sqli)) + { + print $db->error(); + } + $j++; + } + $i++; + } +} + + +} + +?>