* Baby steps toward more useful graphs
authorBen Klang <ben@alkaloid.net>
Fri, 4 Jul 2008 04:23:15 +0000 (04:23 +0000)
committerBen Klang <ben@alkaloid.net>
Sun, 10 Jan 2010 04:05:28 +0000 (23:05 -0500)
* Make handling of dcontext more user friendly

graphgen.php
lib/Form/SearchCDR.php
lib/Operator.php
search.php
viewgraph.php

index 149ea4a..b5b8370 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: incubator/operator/graphgen.php,v 1.1 2008/06/27 17:17:10 bklang Exp $
+ * $Horde: incubator/operator/graphgen.php,v 1.2 2008/07/04 04:23:16 bklang Exp $
  *
  * Copyright 2008 Alkaloid Networks LLC <http://projects.alkaloid.net>
  *
@@ -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]);
index b0d2a47..a142de4 100644 (file)
@@ -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 <http://projects.alkaloid.net>
  *
@@ -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);
     }
index 9f2da31..9dade62 100644 (file)
@@ -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 <http://projects.alkaloid.net>
  *
@@ -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;
+         }
+    }
+
 }
index b587fb5..891057d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: incubator/operator/search.php,v 1.4 2008/07/03 14:29:15 bklang Exp $
+ * $Horde: incubator/operator/search.php,v 1.5 2008/07/04 04:23:16 bklang Exp $
  *
  * Copyright 2008 Alkaloid Networks LLC <http://projects.alkaloid.net>
  *
@@ -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,
index de820ea..cf58597 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: incubator/operator/viewgraph.php,v 1.5 2008/07/03 14:29:15 bklang Exp $
+ * $Horde: incubator/operator/viewgraph.php,v 1.6 2008/07/04 04:23:16 bklang Exp $
  *
  * Copyright 2008 Alkaloid Networks LLC <http://projects.alkaloid.net>
  *
@@ -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'));