From 831e170793e3871adf8429af4c62eb7525c45547 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 4 Jul 2008 04:23:15 +0000 Subject: [PATCH] * Baby steps toward more useful graphs * Make handling of dcontext more user friendly --- graphgen.php | 19 +++++++++++++++++-- lib/Form/SearchCDR.php | 5 ++--- lib/Operator.php | 18 +++++++++++++++++- search.php | 5 ++++- viewgraph.php | 5 ++++- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/graphgen.php b/graphgen.php index 149ea4ae2..b5b8370d8 100644 --- a/graphgen.php +++ b/graphgen.php @@ -1,6 +1,6 @@ * @@ -17,13 +17,28 @@ require_once OPERATOR_BASE . '/lib/base.php'; require_once 'Image/Graph.php'; $graphtype = Util::getFormData('graph'); -#$graphname = Util::getFormData('name'); +$graphname = Operator::getGraphName(Util::getFormData('name')); $cachekey = Util::getFormData('key'); $stats = unserialize($cache->get($cachekey, 0)); Horde::logMessage(print_r($stats, true), __FILE__, __LINE__, PEAR_LOG_ERR); $graph = Image_Graph::factory('graph', array(600, 400)); $plotarea = $graph->addNew('plotarea'); +#$graph->add(Image_Graph::vertical( +# Image_Graph::factory('title', array($graphname, 11)), +# Image_Graph::vertical( +# $plotarea = $graph->addNew('plotarea'), +# $legend = Image_Graph::factory('legend'), +# 90 +# ), +# 5 +#)); +#$legend->setPlotArea($plotarea); +$grid =& $plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY); +$grid->setFillStyle(Image_Graph::factory( + 'gradient', + array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey') +)); $dataset = Image_Graph::factory('dataset'); foreach ($stats as $month => $stats) { $dataset->addPoint($month, $stats[$graphtype]); diff --git a/lib/Form/SearchCDR.php b/lib/Form/SearchCDR.php index b0d2a47cd..a142de4ed 100644 --- a/lib/Form/SearchCDR.php +++ b/lib/Form/SearchCDR.php @@ -2,7 +2,7 @@ /** * SearchCDRForm Class * - * $Horde: incubator/operator/lib/Form/SearchCDR.php,v 1.4 2008/07/03 14:29:18 bklang Exp $ + * $Horde: incubator/operator/lib/Form/SearchCDR.php,v 1.5 2008/07/04 04:23:15 bklang Exp $ * * Copyright 2008 Alkaloid Networks LLC * @@ -62,8 +62,7 @@ class SearchCDRForm extends Horde_Form { $format_out, $show_seconds); $this->addVariable(_("Account Code"), 'accountcode', 'enum', false, false, null, array(Operator::getAccountCodes())); - //$this->addVariable(_("Account Code"), 'accountcode', 'text', false, false, _("An empty account code will select records with an empty account code. To search for all records account codes use %")); - $this->addVariable(_("Destination Context"), 'dcontext', 'text', false, false, _("An empty destination context will select records with an empty destination context. To search for all destination contexts use %")); + $this->addVariable(_("Destination Context"), 'dcontext', 'text', false, false, _("An empty destination context will match all destination contexts.")); $this->addVariable(_("Start Date/Time"), 'startdate', 'datetime', true, false, null, $params); $this->addVariable(_("End Date/Time"), 'enddate', 'datetime', true, false, null, $params); } diff --git a/lib/Operator.php b/lib/Operator.php index 9f2da310f..9dade62bd 100644 --- a/lib/Operator.php +++ b/lib/Operator.php @@ -2,7 +2,7 @@ /** * Operator Base Class. * - * $Horde: incubator/operator/lib/Operator.php,v 1.4 2008/07/03 14:29:16 bklang Exp $ + * $Horde: incubator/operator/lib/Operator.php,v 1.5 2008/07/04 04:23:16 bklang Exp $ * * Copyright 2008 Alkaloid Networks LLC * @@ -124,4 +124,20 @@ class Operator { return $accountcodes; } + + function getGraphName($graphid) + { + switch($graphid) { + case 'numcalls': + return _("Number of Calls"); + break; + case 'minutes': + return _("Total Minutes Used"); + break; + case 'failed': + return _("Number of Failed Calls"); + break; + } + } + } diff --git a/search.php b/search.php index b587fb504..891057dc6 100644 --- a/search.php +++ b/search.php @@ -1,6 +1,6 @@ * @@ -39,6 +39,9 @@ $form = new SearchCDRForm(_("Search CDR Data"), $vars); if ($form->isSubmitted() && $form->validate($vars, true)) { $accountcode = $vars->get('accountcode'); $dcontext = $vars->get('dcontext'); + if (empty($dcontext)) { + $dcontext = '%'; + } $start = new Horde_Date($vars->get('startdate')); $end = new Horde_Date($vars->get('enddate')); $data = $operator_driver->getData($start, $end, $accountcode, $dcontext, diff --git a/viewgraph.php b/viewgraph.php index de820ea4a..cf58597f9 100644 --- a/viewgraph.php +++ b/viewgraph.php @@ -1,6 +1,6 @@ * @@ -26,6 +26,9 @@ $form = new SearchCDRForm(_("Graph CDR Data"), $vars); if ($form->isSubmitted() && $form->validate($vars, true)) { $accountcode = $vars->get('accountcode'); $dcontext = $vars->get('dcontext'); + if (empty($dcontext)) { + $dcontext = '%'; + } $start = new Horde_Date($vars->get('startdate')); $end = new Horde_Date($vars->get('enddate')); -- 2.11.0