1: <?php
2: 3: 4:
5: class Whups_Block_Queuesummary extends Horde_Core_Block
6: {
7: 8:
9: public function __construct($app, $params = array())
10: {
11: parent::__construct($app, $params);
12:
13: $this->_name = _("Queue Summary");
14: }
15:
16: 17:
18: protected function _content()
19: {
20: global $whups_driver;
21:
22: $queues = Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::READ);
23: $qsummary = $whups_driver->getQueueSummary(array_keys($queues));
24: if (!$qsummary) {
25: return '<p><em>' . _("There are no open tickets.") . '</em></p>';
26: }
27:
28: $summary = $types = array();
29: foreach ($qsummary as $queue) {
30: $types[$queue['type']] = $queue['type'];
31: if (!isset($summary[$queue['id']])) {
32: $summary[$queue['id']] = $queue;
33: }
34: $summary[$queue['id']][$queue['type']] = $queue['open_tickets'];
35: }
36:
37: $html = '<thead><tr>';
38: $sortby = 'queue_name';
39: foreach (array_merge(array('queue_name' => _("Queue")), $types) as $column => $name) {
40: $html .= '<th' . ($sortby == $column ? ' class="sortdown"' : '') . '>' . $name . '</th>';
41: }
42: $html .= '</tr></thead><tbody>';
43:
44: foreach ($summary as $queue) {
45: $html .= '<tr><td>' . Horde::link(Whups::urlFor('queue', $queue, true), $queue['description']) . htmlspecialchars($queue['name']) . '</a></td>';
46: foreach ($types as $type) {
47: $html .= '<td>' . (isset($queue[$type]) ? $queue[$type] : ' ') . '</td>';
48: }
49: $html .= '</tr>';
50: }
51:
52: Horde::addScriptFile('tables.js', 'horde', true);
53:
54: return '<table id="whups_block_queuesummary" cellspacing="0" class="tickets striped sortable">' . $html . '</tbody></table>';
55: }
56:
57: }
58: