diff --git a/include/class.export.php b/include/class.export.php index 1cf4d9bf49a9651c30af925ee5fd7fe4bcc47fc3..d62d4460723d8641e31c5d992dadd5b0f71e74c9 100644 --- a/include/class.export.php +++ b/include/class.export.php @@ -74,6 +74,10 @@ class Export { ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1))) ->filter(array('entries__attachments__inline' => 0)) ->aggregate(array('count' => SqlAggregate::COUNT('entries__attachments__id'))), + 'reopen_count' => TicketThread::objects() + ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1))) + ->filter(array('events__annulled' => 0, 'events__state' => 'reopened')) + ->aggregate(array('count' => SqlAggregate::COUNT('events__id'))), 'thread_count' => TicketThread::objects() ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1))) ->exclude(array('entries__flags__hasbit' => ThreadEntry::FLAG_HIDDEN)) diff --git a/include/class.queue.php b/include/class.queue.php index a37accc7abb9b9b42fdf25e01da405b4cf8fc64e..338b582bb9e6b0db518244109bdff626938b338c 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -1437,6 +1437,37 @@ extends QueueColumnAnnotation { } } +class TicketReopenCount +extends QueueColumnAnnotation { + static $icon = 'folder-open-alt'; + static $qname = '_reopen_count'; + static $desc = /* @trans */ 'Reopen Count'; + + function annotate($query) { + return $query->annotate(array( + static::$qname => TicketThread::objects() + ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1))) + ->filter(array('events__annulled' => 0, 'events__state' => 'reopened')) + ->aggregate(array('count' => SqlAggregate::COUNT('events__id'))) + )); + } + + function getDecoration($row, $text) { + $reopencount = $row[static::$qname]; + if ($reopencount) { + return sprintf( + ' <small class="faded-more"><i class="icon-%s"></i> %s</small>', + static::$icon, + $reopencount > 1 ? $reopencount : '' + ); + } + } + + function isVisible($row) { + return $row[static::$qname]; + } +} + class ThreadAttachmentCount extends QueueColumnAnnotation { static $icon = 'paperclip';