diff options
Diffstat (limited to 'FS/FS/TicketSystem/RT_External.pm')
-rw-r--r-- | FS/FS/TicketSystem/RT_External.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/FS/FS/TicketSystem/RT_External.pm b/FS/FS/TicketSystem/RT_External.pm index 8ccc937..5c51bdd 100644 --- a/FS/FS/TicketSystem/RT_External.pm +++ b/FS/FS/TicketSystem/RT_External.pm @@ -9,6 +9,7 @@ use URI::Escape; use FS::UID qw(dbh); use FS::Record qw(qsearchs); use FS::cust_main; +use Carp qw(cluck); $me = '[FS::TicketSystem::RT_External]'; $DEBUG = 0; @@ -96,6 +97,31 @@ sub customer_tickets { } +sub comments_on_tickets { + my ($self, $custnum, $limit, $time ) = @_; + $limit ||= 0; + + my( $from_sql, @param) = $self->_from_customer( $custnum ); + my $sql = qq{ + SELECT transactions.*, Attachments.content, Tickets.subject + FROM transactions + JOIN Attachments ON( Attachments.transactionid = transactions.id ) + JOIN Tickets ON ( Tickets.id = transactions.objectid ) + JOIN Links ON ( Tickets.id = Links.LocalBase + AND Links.Base LIKE '%/ticket/' || Tickets.id ) + + + WHERE ( Status = 'new' OR Status = 'open' OR Status = 'stalled' ) + AND Target = 'freeside://freeside/cust_main/$custnum' + AND transactions.type = 'Comment' + AND transactions.created >= (SELECT TIMESTAMP WITH TIME ZONE 'epoch' + $time * INTERVAL '1 second') + LIMIT $limit + }; + cluck $sql if $DEBUG > 0; + #AND created > + $dbh->selectall_arrayref( $sql, { Slice => {} } ) or die $dbh->errstr . " $sql"; +} + sub _from_customer { my( $self, $custnum, $priority ) = @_; |