[freeside-commits] branch FREESIDE_3_BRANCH updated. f33281a9f445b06e319c45f393c71577701eff67

Jonathan Prykop jonathan at 420.am
Wed Aug 31 21:37:06 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  f33281a9f445b06e319c45f393c71577701eff67 (commit)
       via  0b8f014e86b3464cca92fd925159e457ae54c2b8 (commit)
      from  d5461ef7f534030b662ce5c6ee81eafd5f18cbec (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 f33281a9f445b06e319c45f393c71577701eff67
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Aug 31 23:34:48 2016 -0500

    71696: OFM Request for additional action on Billing Events [v3 fixes]

diff --git a/FS/FS/part_event/Action/rt_ticket.pm b/FS/FS/part_event/Action/rt_ticket.pm
index a6a6160..4a2b993 100644
--- a/FS/FS/part_event/Action/rt_ticket.pm
+++ b/FS/FS/part_event/Action/rt_ticket.pm
@@ -66,12 +66,12 @@ sub do_action {
   
   FS::TicketSystem->init();
 
-  my $cust_msg = $msg_template->prepare(
+  my %msg = $msg_template->prepare(
     'cust_main' => $cust_main,
     'object'    => $object,
   );
 
-  my $subject = $cust_msg->entity->head->get('Subject');
+  my $subject = $msg{'subject'};
   chomp($subject);
 
   my $requestor = $self->option('requestor')
@@ -87,7 +87,7 @@ sub do_action {
     'queue'     => $queueid,
     'subject'   => $subject,
     'requestor' => $requestor,
-    'message'   => $cust_msg->preview,
+    'message'   => $msg{'html_body'},
     'mime_type' => 'text/html',
     'custnum'   => $cust_main->custnum,
     'svcnum'    => $svcnum,

commit 0b8f014e86b3464cca92fd925159e457ae54c2b8
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Sat Aug 6 00:10:39 2016 -0500

    RT#71696: OFM Request for additional action on Billing Events

diff --git a/FS/FS/part_event/Action/rt_ticket.pm b/FS/FS/part_event/Action/rt_ticket.pm
new file mode 100644
index 0000000..a6a6160
--- /dev/null
+++ b/FS/FS/part_event/Action/rt_ticket.pm
@@ -0,0 +1,100 @@
+package FS::part_event::Action::rt_ticket;
+
+use strict;
+use base qw( FS::part_event::Action );
+use FS::Record qw( qsearchs );
+use FS::msg_template;
+
+sub description { 'Open an RT ticket for the customer' }
+
+#need to be valid for msg_template substitution
+sub eventtable_hashref {
+    { 'cust_main'      => 1,
+      'cust_bill'      => 1,
+      'cust_pkg'       => 1,
+      'cust_pay'       => 1,
+      'svc_acct'       => 1,
+    };
+}
+
+sub option_fields {
+  (
+    'msgnum'    => { 'label'    => 'Template',
+                     'type'     => 'select-table',
+                     'table'    => 'msg_template',
+                     'name_col' => 'msgname',
+                     'hashref'  => { disabled => '' },
+                     'disable_empty' => 1,
+                   },
+    'queueid'   => { 'label' => 'Queue',
+                     'type'  => 'select-rt-queue',
+                   },
+    'requestor' => { 'label'   => 'Requestor',
+                     'type'    => 'select',
+                     'options' => [ 0, 1 ],
+                     'labels'  => {
+                       0 => 'Customer\'s invoice address',
+                       1 => 'Template From: address',
+                     },
+                   },
+
+  );
+}
+
+sub default_weight { 59; }
+
+sub do_action {
+
+  my( $self, $object ) = @_;
+
+  my $cust_main = $self->cust_main($object)
+    or die "Could not load cust_main";
+
+  my $msgnum = $self->option('msgnum');
+  my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
+    or die "Template $msgnum not found";
+
+  my $queueid = $self->option('queueid')
+    or die "No queue specified";
+
+  # technically this only works if create_ticket is implemented,
+  # and it is only implemented in RT_Internal,
+  # but we can let create_ticket throw that error
+  my $conf = new FS::Conf;
+  die "rt_ticket event - no ticket system configured"
+    unless $conf->config('ticket_system');
+  
+  FS::TicketSystem->init();
+
+  my $cust_msg = $msg_template->prepare(
+    'cust_main' => $cust_main,
+    'object'    => $object,
+  );
+
+  my $subject = $cust_msg->entity->head->get('Subject');
+  chomp($subject);
+
+  my $requestor = $self->option('requestor')
+                ? $msg_template->from_addr
+                : [ $cust_main->invoicing_list_emailonly ];
+
+  my $svcnum = ref($object) eq 'FS::svc_acct'
+             ? $object->svcnum
+             : undef;
+
+  my $err_or_ticket = FS::TicketSystem->create_ticket(
+    '', #session should already exist
+    'queue'     => $queueid,
+    'subject'   => $subject,
+    'requestor' => $requestor,
+    'message'   => $cust_msg->preview,
+    'mime_type' => 'text/html',
+    'custnum'   => $cust_main->custnum,
+    'svcnum'    => $svcnum,
+  );
+  die $err_or_ticket unless ref($err_or_ticket);
+  return '';
+
+}
+
+1;
diff --git a/httemplate/elements/select-rt-queue.html b/httemplate/elements/select-rt-queue.html
index 4ae8bc9..2893365 100644
--- a/httemplate/elements/select-rt-queue.html
+++ b/httemplate/elements/select-rt-queue.html
@@ -1,4 +1,4 @@
-<SELECT NAME="<% $opt{'name'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>>
+<SELECT NAME="<% $opt{'name'} || $opt{'field'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>>
 % while ( @fields ) {
 %   my $value = shift @fields;
 %   my $label = shift @fields;
diff --git a/httemplate/elements/tr-select-rt-queue.html b/httemplate/elements/tr-select-rt-queue.html
new file mode 100644
index 0000000..ac3689b
--- /dev/null
+++ b/httemplate/elements/tr-select-rt-queue.html
@@ -0,0 +1,7 @@
+
+<& 'tr-td-label.html', @_ &>
+<TD>
+<& 'select-rt-queue.html', @_ &>
+</TD>
+</TR>
+

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

Summary of changes:
 FS/FS/part_event/Action/rt_ticket.pm        |  100 +++++++++++++++++++++++++++
 httemplate/elements/select-rt-queue.html    |    2 +-
 httemplate/elements/tr-select-rt-queue.html |    7 ++
 3 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 FS/FS/part_event/Action/rt_ticket.pm
 create mode 100644 httemplate/elements/tr-select-rt-queue.html




More information about the freeside-commits mailing list