From 943fc4246ea206f93c8265b1fb02904370594c8a Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Tue, 12 Jan 2010 18:17:58 -0500 Subject: [PATCH] Operator: add graph type selector --- operator/lib/Form/SearchCDR.php | 17 +++++++++++++++++ operator/lib/Operator.php | 10 +++++----- operator/viewgraph.php | 26 ++++++++++++-------------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/operator/lib/Form/SearchCDR.php b/operator/lib/Form/SearchCDR.php index 0899b54a3..6b8f017f7 100644 --- a/operator/lib/Form/SearchCDR.php +++ b/operator/lib/Form/SearchCDR.php @@ -77,6 +77,23 @@ class SearchCDRForm extends Horde_Form { } } +class GraphCDRForm extends SearchCDRForm +{ + public function __construct($title, &$vars) + { + parent::__construct($title, $vars); + + $graphtypes = Operator::getGraphInfo(); + $graphs = array(); + foreach ($graphtypes as $type => $info) { + $graphs[$type] = $info['title']; + } + + $this->addVariable(_("Graph"), 'graph', 'enum', true, false, + null, array($graphs)); + } +} + class ExportCDRForm extends SearchCDRForm { public function __construct($title, &$vars) diff --git a/operator/lib/Operator.php b/operator/lib/Operator.php index 26e0ba120..fa00ad4d1 100644 --- a/operator/lib/Operator.php +++ b/operator/lib/Operator.php @@ -167,11 +167,11 @@ class Operator { 'numberformat' => '%0.1f', ), - 'failed' => array( - 'title' => _("Number of Failed Calls by Month"), - 'axisX' => _("Month"), - 'axisY' => _("Failed Calls"), - ), +// 'failed' => array( +// 'title' => _("Number of Failed Calls by Month"), +// 'axisX' => _("Month"), +// 'axisY' => _("Failed Calls"), +// ), ); } diff --git a/operator/viewgraph.php b/operator/viewgraph.php index 834fcd251..59bf0a363 100644 --- a/operator/viewgraph.php +++ b/operator/viewgraph.php @@ -20,7 +20,7 @@ require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php'; $renderer = new Horde_Form_Renderer(); $vars = Horde_Variables::getDefaultVariables(); -$form = new SearchCDRForm(_("Graph CDR Data"), $vars); +$form = new GraphCDRForm(_("Graph CDR Data"), $vars); if ($form->isSubmitted() && $form->validate($vars, true)) { $accountcode = $vars->get('accountcode'); $dcontext = $vars->get('dcontext'); @@ -83,17 +83,17 @@ if ($form->isSubmitted() && $form->validate($vars, true)) { } } +$graphs = array(); if (!empty($stats)) { - $numcalls_graph = $minutes_graph = $failed_graph = - Horde::applicationUrl('graphgen.php'); - - $numcalls_graph = Horde_Util::addParameter($numcalls_graph, array( - 'graph' => 'numcalls', 'key' => $cachekey)); - $minutes_graph = Horde_Util::addParameter($minutes_graph, array( - 'graph' => 'minutes', 'key' => $cachekey)); - $failed_graph = Horde_Util::addParameter($failed_graph, array( - 'graph' => 'failed', 'key' => $cachekey)); + $url = Horde::applicationUrl('graphgen.php'); + $graphtypes = Operator::getGraphInfo(); + + foreach($graphtypes as $type => $info) { + $graphs[$type] = Horde_Util::addParameter($url, array( + 'graph' => $type, 'key' => $cachekey)); + } } +$curgraph = $vars->get('graph'); $title = _("Call Detail Records Graph"); @@ -102,11 +102,9 @@ require OPERATOR_TEMPLATES . '/menu.inc'; $form->renderActive($renderer, $vars); -if (!empty($stats)) { +if (!empty($stats) && !empty($graphs[$curgraph])) { echo '
'; - echo '
'; - echo '
'; - echo '
'; + echo '
'; } require $registry->get('templates', 'horde') . '/common-footer.inc'; -- 2.11.0