[freeside-commits] branch master updated. 5e6bfa1548ac370d2cf316e0db44785d83baa453

Ivan ivan at 420.am
Mon Oct 5 19:09:34 PDT 2015


The branch, master has been updated
       via  5e6bfa1548ac370d2cf316e0db44785d83baa453 (commit)
      from  883e34abf9c9a59cf039c2c698b930b2f305be7f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5e6bfa1548ac370d2cf316e0db44785d83baa453
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Oct 5 19:09:33 2015 -0700

    ticket_system-appointment-custom_field, RT#34237

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index fa4ff41..647ae0b 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3188,6 +3188,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'ticket_system-appointment-custom_field',
+    'section'     => 'ticketing',
+    'description' => 'Custom field from the ticketing system to use as an appointment classification.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'ticket_system-escalation',
     'section'     => 'ticketing',
     'description' => 'Enable priority escalation of tickets as part of daily batch processing.',
diff --git a/FS/FS/TicketSystem/RT_Internal.pm b/FS/FS/TicketSystem/RT_Internal.pm
index 6fb2c18..b70ac53 100644
--- a/FS/FS/TicketSystem/RT_Internal.pm
+++ b/FS/FS/TicketSystem/RT_Internal.pm
@@ -111,7 +111,7 @@ properly.
 # create an RT::Tickets object for a specified custnum or svcnum
 
 sub _tickets_search {
-  my( $self, $type, $number, $limit, $priority, $status ) = @_;
+  my( $self, $type, $number, $limit, $priority, $status, $queueid ) = @_;
 
   $type =~ /^Customer|Service$/ or die "invalid type: $type";
   $number =~ /^\d+$/ or die "invalid custnum/svcnum: $number";
@@ -159,6 +159,8 @@ sub _tickets_search {
                       join(' OR ', map { "Status = '$_'" } @statuses).
                ' ) ';
 
+  $rtql .= " AND Queue = $queueid " if $queueid;
+
   warn "$me _customer_tickets_search:\n$rtql\n" if $DEBUG;
   $Tickets->FromSQL($rtql);
 
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 6afbd1c..2d6d459 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4053,6 +4053,30 @@ sub tickets {
   (@tickets);
 }
 
+=item appointments [ STATUS ]
+
+Returns an array of hashes representing the customer's RT tickets which
+are appointments.
+
+=cut
+
+sub appointments {
+  my $self = shift;
+  my $status = ( @_ && $_[0] ) ? shift : '';
+
+  return () unless $conf->config('ticket_system');
+
+  my $queueid = $conf->config('ticket_system-appointment-queueid');
+
+  @{ FS::TicketSystem->customer_tickets( $self->custnum,
+                                         99,
+                                         undef,
+                                         $status,
+                                         $queueid,
+                                       )
+  };
+}
+
 # Return services representing svc_accts in customer support packages
 sub support_services {
   my $self = shift;
diff --git a/httemplate/view/cust_main/appointments.html b/httemplate/view/cust_main/appointments.html
index c907b25..9bf5be1 100644
--- a/httemplate/view/cust_main/appointments.html
+++ b/httemplate/view/cust_main/appointments.html
@@ -19,7 +19,9 @@
 
 <THEAD>
 <TR>
-  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
+% if ( $custom_field ) {
+    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
+% }
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
@@ -41,10 +43,12 @@
 %       if $starts > 86400;
 
   <TR>
-  
-    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-      <A HREF=<%$href%>><% 'custom field magic type' %></A>
-    </TD>
+
+%   if ( $custom_field ) {
+      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+        <A HREF=<%$href%>><% $ticket->{"CF.{$custom_field}"} |h %></A>
+      </TD>
+%   }
   
     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
       <A HREF=<%$href%>><% $starts_pretty %></A>
@@ -78,20 +82,22 @@ return '' unless $conf->config('ticket_system');
 
 #my $object = $opt{'object'};
 #$object = $object->cust_svc if $object->isa('FS::svc_Common');
-my( @tickets )  = $object->tickets; #XXX but actually appointments... filter by presense of the necessary CF?  RT::Appointment instead of RT::Ticket ?
+my @tickets = $object->appointments;
 
-my ($openlabel, $open_link, $res_link, $thing);
-$openlabel = join('/', FS::TicketSystem->statuses );
+my $custom_field = $conf->config('ticket_system-appointment-custom_field');
+
+# my ($openlabel, $open_link, $res_link, $thing);
+# $openlabel = join('/', FS::TicketSystem->statuses );
 
 # not the nicest way to do this--FS::has_tickets_Common?
 #if ( $object->isa('FS::cust_main') ) {
-  $thing  = 'customer';
-  $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
-
-  $res_link  = FS::TicketSystem->href_customer_tickets(
-                    $object->custnum,
-                    { 'statuses' => [ 'resolved' ] }
-                  );
+#  $thing  = 'customer';
+#  $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
+#
+#  $res_link  = FS::TicketSystem->href_customer_tickets(
+#                    $object->custnum,
+#                    { 'statuses' => [ 'resolved' ] }
+#                  );
 #} elsif ( $object->isa('FS::cust_svc') ) {
 #
 #  return '' unless $object->pkgnum;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                               |    7 ++++++
 FS/FS/TicketSystem/RT_Internal.pm           |    4 ++-
 FS/FS/cust_main.pm                          |   24 ++++++++++++++++++
 httemplate/view/cust_main/appointments.html |   36 ++++++++++++++++-----------
 4 files changed, 55 insertions(+), 16 deletions(-)




More information about the freeside-commits mailing list