summaryrefslogtreecommitdiff
path: root/FS/FS/part_event
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-11-02 17:46:49 -0800
committerIvan Kohler <ivan@freeside.biz>2014-11-02 17:46:49 -0800
commitfabfdd343fd431ef431ebc4cbfa48f166d7bc386 (patch)
tree83ef62eac2b3a6f5d130e90f96acad716252d48d /FS/FS/part_event
parent34add44f0e88aac782264a2febc59b8f48d7ca52 (diff)
add condition on lack of customer tag, RT#28784
Diffstat (limited to 'FS/FS/part_event')
-rw-r--r--FS/FS/part_event/Condition/hasnt_cust_tag.pm49
1 files changed, 49 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/hasnt_cust_tag.pm b/FS/FS/part_event/Condition/hasnt_cust_tag.pm
new file mode 100644
index 000000000..e56151d26
--- /dev/null
+++ b/FS/FS/part_event/Condition/hasnt_cust_tag.pm
@@ -0,0 +1,49 @@
+package FS::part_event::Condition::hasnt_cust_tag;
+use base qw( FS::part_event::Condition );
+
+use strict;
+#use FS::Record qw( qsearch );
+
+sub description {
+ 'Customer does not have (any selected) tag',
+}
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+sub option_fields {
+ (
+ 'tagnum' => { 'label' => 'Customer tag',
+ 'type' => 'select-cust_tag',
+ 'multiple' => 1,
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my $hashref = $self->option('tagnum') || {};
+ ! grep $hashref->{ $_->tagnum }, $cust_main->cust_tag;
+
+}
+
+sub condition_sql {
+ my( $self, $table ) = @_;
+
+ my $matching_tags =
+ "SELECT tagnum FROM cust_tag WHERE cust_tag.custnum = $table.custnum".
+ " AND cust_tag.tagnum IN ".
+ $self->condition_sql_option_option_integer('tagnum');
+
+ "NOT EXISTS($matching_tags)";
+}
+
+1;
+