1 package FS::TicketSystem::RT_External;
4 use vars qw( $conf $priority_field $priority_field_queue $field );
7 install_callback FS::UID sub {
8 my $conf = new FS::Conf;
10 $conf->config('ticket_system-custom_priority_field');
11 if ( $priority_field ) {
12 $priority_field_queue =
13 $conf->config('ticket_system-custom_priority_field_queue');
14 $field = $priority_field_queue
15 ? $priority_field_queue. '.%7B'. $priority_field. '%7D'
18 $priority_field_queue = '';
23 sub num_customer_tickets {
24 my( $self, $custnum, $priority, $dbh ) = @_;
26 #$dbh ||= create one from some config options
29 my $priority_sql = '';
30 if ( defined($priority) ) {
31 if ( length($priority) ) {
32 my $queue_sql = " queue = ( select id from queues where queues.name = ? )
33 or ( ? = '' and queue = 0 )";
35 and ? = ( select content from TicketCustomFieldValues
36 where ticket = tickets.id
37 and customfield = ( select id from customfields
43 push @param, $priority,
45 $priority_field_queue,
46 $priority_field_queue;
48 return '0nothandledyet0';
53 select count(*) from tickets
54 where ( status = 'new' or status = 'open' or status = 'stalled' )
55 and target = 'freeside://freeside/cust_main/$custnum'
59 my $sth = $dbh->prepare($sql) or die $dbh->errstr;
60 $sth->execute(@param) or die $sth->errstr;
62 $sth->fetchrow_arrayref->[0];
66 sub href_customer_tickets {
67 my( $self, $custnum, $priority ) = @_;
70 'Search/Results.html?Order=ASC&Query=%20MemberOf%20%3D%20%27freeside%3A%2F%2Ffreeside%2Fcust_main%2F'.
72 '%27%20%20AND%20%28%20Status%20%3D%20%27open%27%20%20OR%20Status%20%3D%20%27new%27%20%20OR%20Status%20%3D%20%27stalled%27%20%29%20'
75 if ( $priority && $field && $priority_field_queue ) {
76 $href .= 'AND%20Queue%20%3D%20%27'. $priority_field_queue. '%27%20';
78 if ( $priority && $field ) {
79 $href .= '%20AND%20%27CF.'. $field. '%27%20%3D%20%27'. $priority. '%27%20';
84 '&Format=%27%20%20%20%3Cb%3E%3Ca%20href%3D%22%2Ffreeside%2Frt%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A%23%27%2C%20%0A%27%3Cb%3E%3Ca%20href%3D%22%2Ffreeside%2Frt%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3ASubject%27%2C%20%0A%27__Status__%27%2C%20';
86 if ( $priority && $field ) {
87 $href .= '%0A%27__CustomField.'. $field. '__%2FTITLE%3ASeverity%27%2C%20';
90 $href .= '%0A%27__QueueName__%27%2C%20%0A%27__OwnerName__%27%2C%20%0A%27__Priority__%27%2C%20%0A%27__NEWLINE__%27%2C%20%0A%27%27%2C%20%0A%27%3Csmall%3E__Requestors__%3C%2Fsmall%3E%27%2C%20%0A%27%3Csmall%3E__CreatedRelative__%3C%2Fsmall%3E%27%2C';
92 if ( $priority && $field ) {
93 $href .= '%20%0A%27__-__%27%2C';
96 $href .= '%20%0A%27%3Csmall%3E__ToldRelative__%3C%2Fsmall%3E%27%2C%20%0A%27%3Csmall%3E__LastUpdatedRelative__%3C%2Fsmall%3E%27%2C%20%0A%27%3Csmall%3E__TimeLeft__%3C%2Fsmall%3E%27';