freeside/FS/FS/TicketSystem RT_Internal.pm,1.4,1.5 RT_External.pm,1.4,1.5

ivan ivan at pouncequick.420.am
Thu Dec 9 01:21:47 PST 2004


Update of /home/cvs/cvsroot/freeside/FS/FS/TicketSystem
In directory pouncequick:/tmp/cvs-serv12514/FS/FS/TicketSystem

Modified Files:
	RT_Internal.pm RT_External.pm 
Log Message:
more RT integration

Index: RT_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_Internal.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- RT_Internal.pm	6 Dec 2004 14:11:22 -0000	1.4
+++ RT_Internal.pm	9 Dec 2004 09:21:42 -0000	1.5
@@ -8,7 +8,7 @@
 
 @ISA = qw( FS::TicketSystem::RT_Libs );
 
-sub sql_customer_tickets {
+sub sql_num_customer_tickets {
   "( select count(*) from tickets
                      join links on ( tickets.id = links.localbase )
      where ( status = 'new' or status = 'open' or status = 'stalled' )
@@ -21,10 +21,27 @@
   $self->SUPER::num_customer_tickets( $custnum, $priority, dbh );
 }
 
+sub customer_tickets {
+  my( $self, $custnum, $limit, $priority ) = ( shift, shift, shift, shift );
+  $self->SUPER::customer_tickets( $custnum, $limit, $priority, dbh );
+}
+
 sub href_customer_tickets {
   my $self = shift;
   # well, 2 is wrong here but will have to do for now
   popurl(2).'rt/'. $self->SUPER::href_customer_tickets(@_);
+}
+
+sub href_new_ticket {
+  my $self = shift;
+  # well, 2 is wrong here but will have to do for now
+  popurl(2).'rt/'. $self->SUPER::href_new_ticket(@_);
+}
+
+sub href_ticket {
+  my $self = shift;
+  # well, 2 is wrong here but will have to do for now
+  popurl(2).'rt/'. $self->SUPER::href_ticket(@_);
 }
 
 1;

Index: RT_External.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_External.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- RT_External.pm	6 Dec 2004 14:15:34 -0000	1.4
+++ RT_External.pm	9 Dec 2004 09:21:43 -0000	1.5
@@ -25,42 +25,93 @@
 
   #$dbh ||= create one from some config options
 
+  my( $from_sql, @param) = $self->_from_customer( $custnum, $priority );
+
+  my $sql = "select count(*) $from_sql";
+  my $sth = $dbh->prepare($sql) or die $dbh->errstr. " preparing $sql";
+  $sth->execute(@param)         or die $sth->errstr. " executing $sql";
+
+  $sth->fetchrow_arrayref->[0];
+
+}
+
+sub customer_tickets {
+  my( $self, $custnum, $limit, $priority, $dbh ) = @_;
+  $limit ||= 0;
+
+  #$dbh ||= create one from some config options
+
+  my( $from_sql, @param) = $self->_from_customer( $custnum, $priority );
+  my $sql = "select * $from_sql order by priority desc limit $limit";
+  my $sth = $dbh->prepare($sql) or die $dbh->errstr. "preparing $sql";
+  $sth->execute(@param)         or die $sth->errstr. "executing $sql";
+
+  #munge column names???  #httemplate/view/cust_main/tickets.html has column
+  #names that might not make sense now...
+  $sth->fetchall_arrayref({});
+
+}
+
+sub _from_customer {
+  my( $self, $custnum, $priority ) = @_;
+
   my @param = ();
-  my $priority_sql = '';
+  my $join = '';
+  my $where = '';
   if ( defined($priority) ) {
+
+    my $queue_sql = " customfields.queue = ( select id from queues
+                                              where queues.name = ? )
+                      or ( ? = '' and customfields.queue = 0 )";
+
     if ( length($priority) ) {
-      my $queue_sql = " queue = ( select id from queues where queues.name = ? )
-                        or ( ? = '' and queue = 0 )";
-      $priority_sql = "
-        and ? = ( select content from TicketCustomFieldValues
-                   where ticket = tickets.id
-                     and customfield = ( select id from customfields
-                                          where name = ?
-                                            and ( $queue_sql )
-                                       )
-                )
-      ";
-      push @param, $priority,
-                   $priority_field,
-                   $priority_field_queue,
-                   $priority_field_queue;
+      #$where = "    
+      #  and ? = ( select content from TicketCustomFieldValues
+      #             where ticket = tickets.id
+      #               and customfield = ( select id from customfields
+      #                                    where name = ?
+      #                                      and ( $queue_sql )
+      #                                 )
+      #          )
+      #";
+      push @param, $priority;
+
+      $join = "join TicketCustomFieldValues
+                 on ( tickets.id = TicketCustomFieldValues.ticket )";
+      
+      $where = "and content = ?
+                and customfield = ( select id from customfields
+                                     where name = ?
+                                       and ( $queue_sql )
+                                  )
+               ";
     } else {
-      return '0nothandledyet0';
+      $where =
+               "and 0 = ( select count(*) from TicketCustomFieldValues
+                           where ticket = tickets.id
+                             and customfield = ( select id from customfields
+                                                  where name = ?
+                                                    and ( $queue_sql )
+                                               )
+                        )
+               ";
     }
+    push @param, $priority_field,
+                 $priority_field_queue,
+                 $priority_field_queue;
   }
 
   my $sql = "
-    select count(*) from tickets
+                    from tickets
+                    join queues on ( tickets.queue = queues.id )
                     join links on ( tickets.id = links.localbase )
+                    $join 
        where ( status = 'new' or status = 'open' or status = 'stalled' )
          and target = 'freeside://freeside/cust_main/$custnum'
-         $priority_sql
+         $where
   ";
 
-  my $sth = $dbh->prepare($sql) or die $dbh->errstr;
-  $sth->execute(@param)         or die $sth->errstr;
-
-  $sth->fetchrow_arrayref->[0];
+  ( $sql, @param );
 
 }
 
@@ -97,6 +148,17 @@
   $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';
 
   $href;
+}
+
+
+sub href_new_ticket {
+  my( $self, $custnum ) = @_;
+  'Ticket/Create.html?Queue=1&new-MemberOf=freeside://freeside/cust_main/'.$custnum;
+}
+
+sub href_ticket {
+  my($self, $ticketnum) = @_;
+  'Ticket/Display.html?id='.$ticketnum;
 }
 
 1;




More information about the freeside-commits mailing list