1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package FS::part_event::Condition::has_cust_tag;
use base qw( FS::part_event::Condition );
use strict;
#use FS::Record qw( qsearch );
sub description {
'Customer has 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 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');
"EXISTS($matching_tags)";
}
1;
|