[freeside-commits] freeside/FS/FS/part_event/Action svc_acct_notice.pm, NONE, 1.1 pkg_cancel.pm, 1.1, 1.2 pkg_suspend.pm, 1.1, 1.2

Mark Wells mark at wavetail.420.am
Wed Aug 31 22:13:10 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Action
In directory wavetail.420.am:/tmp/cvs-serv1936/FS/FS/part_event/Action

Modified Files:
	pkg_cancel.pm pkg_suspend.pm 
Added Files:
	svc_acct_notice.pm 
Log Message:
svc_acct events for usage limits, #13202

Index: pkg_suspend.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Action/pkg_suspend.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- pkg_suspend.pm	23 Feb 2011 21:50:52 -0000	1.1
+++ pkg_suspend.pm	1 Sep 2011 05:13:07 -0000	1.2
@@ -6,7 +6,8 @@
 sub description { 'Suspend this package'; }
 
 sub eventtable_hashref {
-  { 'cust_pkg' => 1 };
+  { 'cust_pkg' => 1,
+    'svc_acct' => 1, };
 }
 
 sub option_fields {
@@ -21,7 +22,8 @@
 sub default_weight { 20; }
 
 sub do_action {
-  my( $self, $cust_pkg, $cust_event ) = @_;
+  my( $self, $object, $cust_event ) = @_;
+  my $cust_pkg = $self->cust_pkg($object);
 
   my $error = $cust_pkg->suspend( 'reason' => $self->option('reasonnum') );
   die $error if $error;

--- NEW FILE: svc_acct_notice.pm ---
package FS::part_event::Action::svc_acct_notice;

use strict;
use base qw( FS::part_event::Action );
use FS::Record qw( qsearchs );
use FS::svc_acct;
use FS::msg_template;

sub description { 'Email a notice to this account'; }

sub eventtable_hashref {
  { 'svc_acct' => 1 }
};

sub option_fields {
  (
    'msgnum' => { 'label'    => 'Template',
                  'type'     => 'select-table',
                  'table'    => 'msg_template',
                  'name_col' => 'msgname',
                  'disable_empty' => 1,
                },
  );
}

sub default_weight { 56; } #?

sub do_action {
  my( $self, $svc_acct ) = @_;

  my $cust_main = $self->cust_main($svc_acct)
      or die "No customer found for svcnum ".$svc_acct->svcnum;
    # this will never be run for unlinked services, for several reasons

  my $msgnum = $self->option('msgnum');

  my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
      or die "Template $msgnum not found";

  my $email = $svc_acct->email
      or die "No email associated with svcnum ".$svc_acct->svcnum;

  $msg_template->send(
    'cust_main' => $cust_main,
    'object'    => $svc_acct,
    'to'        => $email,
  );

}

1;

Index: pkg_cancel.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Action/pkg_cancel.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- pkg_cancel.pm	22 Nov 2010 01:30:09 -0000	1.1
+++ pkg_cancel.pm	1 Sep 2011 05:13:07 -0000	1.2
@@ -21,7 +21,8 @@
 sub default_weight { 20; }
 
 sub do_action {
-  my( $self, $cust_pkg, $cust_event ) = @_;
+  my( $self, $object, $cust_event ) = @_;
+  my $cust_pkg = $self->cust_pkg($object);
 
   my $error = $cust_pkg->cancel( 'reason' => $self->option('reasonnum') );
   die $error if $error;



More information about the freeside-commits mailing list