client reporting
Bo Daley <[email protected]>
| Newsgroups | gmane.comp.horde.whups |
|---|---|
| Message-ID | <[email protected]> |
Quoting Chuck Hagenbuch <[email protected]>: > How about a patch to Whups for generating reports by client? :) I tried this a few different ways, and something like the attached patch is about the only way I can see this working without causing the server to grind to a complete halt! I should point out that I have no idea whether this actually produces visible graphs as I still haven't managed to get GD 2 to install on my machine. Is there a way to see the new graphs with GD 1.8? One way or another I'd expect that there would be some debugging to do before this is commitable ;) bo. -- Whups mailing list Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
client_reports.diff
(text/diff, 4 KB)
Index: lib/Links/sql.php
===================================================================
RCS file: /repository/horde/lib/Links/sql.php,v
retrieving revision 1.10
diff -u -r1.10 sql.php
--- lib/Links/sql.php 19 Jul 2003 18:13:26 -0000 1.10
+++ lib/Links/sql.php 11 Aug 2003 10:28:34 -0000
@@ -134,6 +134,36 @@
}
}
+
+ /**
+ * This function gets basic statistics about a type of link for reporting purposes.
+ *
+ * @param string $link_type
+ *
+ * @param string $to_provider
+ *
+ * @param string $from_type The variable name of the object to be reported on
+ *
+ * @access public
+ */
+ function getStatistics($link_type, $to_provider, $from_type)
+ {
+ $wildcard = '%' . $from_type . '%';
+ $this->_connect();
+ $query = sprintf('SELECT link_to_parameter, count(link_id) FROM %s
+ WHERE link_type = %s AND link_from_provider= %s AND link_to_provider = %s
+ AND link_from_parameter LIKE %s
+ GROUP BY link_to_parameter ',
+ $this->_params['table'],
+ $this->_db->quote($link_type),
+ $this->_db->quote($this->_from_application),
+ $this->_db->quote($to_provider),
+ $this->_db->quote($wildcard));
+ $result = $this->_db->getAll($query, null, DB_FETCHMODE_ORDERED);
+
+ return $result;
+ }
+
/**
* This function retrieves all the links to the current object.
*
@@ -187,6 +217,7 @@
}
return true;
}
+
/**
* Attempts to open a persistent connection to the SQL server.
Index: whups/graph.php
===================================================================
RCS file: /repository/whups/graph.php,v
retrieving revision 1.17
diff -u -r1.17 graph.php
--- whups/graph.php 8 Aug 2003 03:20:55 -0000 1.17
+++ whups/graph.php 11 Aug 2003 10:28:34 -0000
@@ -22,13 +22,32 @@
exit('no report specified.');
}
-$reporter = &new Whups_Reports($whups);
-$data = $reporter->getDataSet($report);
-if (is_a($data, 'PEAR_Error')) {
- Horde::fatal($data, __FILE__, __LINE__);
-} elseif (!count($data)) {
- exit(_("There is no data for this graph."));
+
+list ($type, $field) = explode('|', $report);
+if ($field == 'client') {
+
+ include HORDE_BASE . '/lib/Links.php';
+ $links = &Horde_Links::singleton($registry->getApp());
+ $statistics = $links->getStatistics('client', 'contacts', 'ticket_id');
+ foreach ($statistics as $stat) {
+ $client = unserialize($stat[0]);
+ $clientInfo = $GLOBALS['registry']->call('clients/getClient', array($client['id']));
+ $client_name = $clientInfo['name'];
+ $data[$client_name] = (int)$stat[1];
+ }
+
+} else {
+
+ $reporter = &new Whups_Reports($whups);
+ $data = $reporter->getDataSet($report);
+ if (is_a($data, 'PEAR_Error')) {
+ Horde::fatal($data, __FILE__, __LINE__);
+ } elseif (!count($data)) {
+ exit(_("There is no data for this graph."));
+ }
+
}
+
$graph = &new Horde_Graph(array('width' => 500, 'height' => 400));
$graph->set('title', $graphs[$report]);
Index: whups/lib/Reports.php
===================================================================
RCS file: /repository/whups/lib/Reports.php,v
retrieving revision 1.16
diff -u -r1.16 Reports.php
--- whups/lib/Reports.php 8 Aug 2003 03:20:55 -0000 1.16
+++ whups/lib/Reports.php 11 Aug 2003 10:28:34 -0000
@@ -6,6 +6,7 @@
'open|_priority_name' => _("Open Tickets by Priority"),
'open|user_id_requester' => _("Open Tickets by Requester"),
'open|owner' => _("Open Tickets by Owner"),
+ 'all|client' => _("All Tickets by Client"),
'@closed:avg:open|owner' => _("Average days to close by Owner"),
'@closed:avg:open|user_id_requester' => _("Average days to close by Requester"),
'@closed:avg:open|_module_name' => _("Average days to close by Module"));