summaryrefslogtreecommitdiff
path: root/FS/FS/part_event
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2017-11-19 00:25:51 +0000
committerMitch Jackson <mitch@freeside.biz>2017-11-19 00:25:51 +0000
commitbe9a6369ff99184be0772c506e3fa9dce8d1b932 (patch)
tree509c8c5edb1ec8cd43ccbc80d6ef1307b6f1fe9f /FS/FS/part_event
parente1b3d8c0c08dd559ea7c18c1b53f2a79168c8627 (diff)
RT# 73211 - Add billing event: remove customer tag
- Created billing event removetag, named to match addtag - Weighted addtag and removetag both at 21, to group them in menus
Diffstat (limited to 'FS/FS/part_event')
-rw-r--r--FS/FS/part_event/Action/addtag.pm4
-rw-r--r--FS/FS/part_event/Action/removetag.pm49
2 files changed, 51 insertions, 2 deletions
diff --git a/FS/FS/part_event/Action/addtag.pm b/FS/FS/part_event/Action/addtag.pm
index c4e9820..c929b41 100644
--- a/FS/FS/part_event/Action/addtag.pm
+++ b/FS/FS/part_event/Action/addtag.pm
@@ -25,12 +25,12 @@ sub option_fields {
);
}
-sub default_weight { 20; }
+sub default_weight { 21; }
sub do_action {
my( $self, $object, $tagnum ) = @_;
- my %exists = map { $_->tagnum => $_->tagnum }
+ my %exists = map { $_->tagnum => $_->tagnum }
qsearch({
table => 'cust_tag',
hashref => { custnum => $object->custnum, },
diff --git a/FS/FS/part_event/Action/removetag.pm b/FS/FS/part_event/Action/removetag.pm
new file mode 100644
index 0000000..41cf917
--- /dev/null
+++ b/FS/FS/part_event/Action/removetag.pm
@@ -0,0 +1,49 @@
+package FS::part_event::Action::removetag;
+
+use strict;
+use base qw( FS::part_event::Action );
+use FS::Record qw( qsearch );
+
+sub description { 'Remove customer tag'; }
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ 'cust_pay' => 1,
+ 'cust_pay_batch' => 1,
+ 'cust_statement' => 1,
+ };
+}
+
+sub option_fields {
+ (
+ 'tagnum' => { 'label' => 'Customer tag',
+ 'type' => 'select-cust_tag',
+ 'multiple' => 1,
+ },
+ );
+}
+
+sub default_weight { 21; }
+
+sub do_action {
+ my( $self, $object, $tagnum ) = @_;
+
+ # Get hashref of tags applied to selected customer record
+ my %cust_tag = map { $_->tagnum => $_ } qsearch({
+ table => 'cust_tag',
+ hashref => { custnum => $object->custnum, },
+ });
+
+ # Remove tags chosen for this billing event from the customer record
+ foreach my $tagnum ( split(/\,/, $self->option('tagnum') ) ) {
+ if ( exists $cust_tag{$tagnum} ) {
+ my $error = $cust_tag{$tagnum}->delete;
+ die $error if $error;
+ }
+ }
+ '';
+}
+
+1;