Stub of page to display per-month call stats
authorBen Klang <ben@alkaloid.net>
Thu, 26 Jun 2008 17:31:47 +0000 (17:31 +0000)
committerBen Klang <ben@alkaloid.net>
Sun, 10 Jan 2010 04:05:27 +0000 (23:05 -0500)
viewgraph.php [new file with mode: 0644]

diff --git a/viewgraph.php b/viewgraph.php
new file mode 100644 (file)
index 0000000..a40ccaa
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * $Horde: incubator/operator/viewgraph.php,v 1.1 2008/06/26 17:31:47 bklang Exp $
+ *
+ * Copyright 2008 Alkaloid Networks LLC <http://projects.alkaloid.net>
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Ben Klang <ben@alkaloid.net>
+ */
+
+@define('OPERATOR_BASE', dirname(__FILE__));
+require_once OPERATOR_BASE . '/lib/base.php';
+
+// Form libraries.
+require_once 'Horde/Form.php';
+require_once 'Horde/Form/Renderer.php';
+require_once 'Horde/Variables.php';
+require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php';
+
+$renderer = new Horde_Form_Renderer();
+$vars = Variables::getDefaultVariables();
+
+$form = new SearchCDRForm($vars);
+if ($form->isSubmitted() && $form->validate($vars, true)) {
+    if ($vars->exists('accountcode')) {
+        $accountcode = $vars->get('accountcode');
+    } else {
+        $accountcode = '';
+    }
+    $start = new Horde_Date($vars->get('startdate'));
+    $end = new Horde_Date($vars->get('enddate'));
+    $data = $operator_driver->getData($accountcode, $start, $end);
+    $_SESSION['operator']['lastsearch']['params'] = array(
+        'accountcode' => $vars->get('accountcode'),
+        'startdate' => $vars->get('startdate'),
+        'enddate' => $vars->get('enddate'));
+    $_SESSION['operator']['lastsearch']['data'] = $data;
+} else {
+    if (isset($_SESSION['operator']['lastsearch']['params'])) {
+        foreach($_SESSION['operator']['lastsearch']['params'] as $var => $val) {
+            $vars->set($var, $val);
+        }
+    }
+    if (isset($_SESSION['operator']['lastsearch']['data'])) {
+        $data = $_SESSION['operator']['lastsearch']['data'];
+    }
+}
+
+$startdate = array('year' => 2007,
+                   'month' => 1,
+                   'mday' => 1);
+$enddate = array('year' => date('Y'),
+                 'month' => date('n'),
+                 'mday' => date('j'));
+
+$startdate = new Horde_Date($startdate);
+$enddate = new Horde_Date($enddate);
+$accountcode = null;
+$dcontext = null;
+
+$stats = $operator_driver->getCallStats($startdate, $enddate, $accountcode, $dcontext);
+
+$title = _("Call Statistics");
+Horde::addScriptFile('stripe.js', 'horde', true);
+
+require OPERATOR_TEMPLATES . '/common-header.inc';
+require OPERATOR_TEMPLATES . '/menu.inc';
+
+print_r($stats);
+require $registry->get('templates', 'horde') . '/common-footer.inc';