pkg_cancel event action, RT#10141
authormark <mark>
Mon, 22 Nov 2010 01:30:09 +0000 (01:30 +0000)
committermark <mark>
Mon, 22 Nov 2010 01:30:09 +0000 (01:30 +0000)
FS/FS/part_event/Action/cancel.pm
FS/FS/part_event/Action/pkg_cancel.pm [new file with mode: 0644]

index b9d6d29..b93682b 100644 (file)
@@ -3,7 +3,7 @@ package FS::part_event::Action::cancel;
 use strict;
 use base qw( FS::part_event::Action );
 
-sub description { 'Cancel'; }
+sub description { 'Cancel all of this customer\'s packages'; }
 
 sub option_fields {
   ( 
diff --git a/FS/FS/part_event/Action/pkg_cancel.pm b/FS/FS/part_event/Action/pkg_cancel.pm
new file mode 100644 (file)
index 0000000..2bfd35c
--- /dev/null
@@ -0,0 +1,32 @@
+package FS::part_event::Action::pkg_cancel;
+
+use strict;
+use base qw( FS::part_event::Action );
+
+sub description { 'Cancel this package'; }
+
+sub eventtable_hashref {
+  { 'cust_pkg' => 1 };
+}
+
+sub option_fields {
+  ( 
+    'reasonnum' => { 'label'        => 'Reason',
+                     'type'         => 'select-reason',
+                     'reason_class' => 'C',
+                   },
+  );
+}
+
+sub default_weight { 20; }
+
+sub do_action {
+  my( $self, $cust_pkg, $cust_event ) = @_;
+
+  my $error = $cust_pkg->cancel( 'reason' => $self->option('reasonnum') );
+  die $error if $error;
+  
+  '';
+}
+
+1;