summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/part_event/Condition/has_pkg_class_cancelled.pm43
-rw-r--r--FS/FS/part_event/Condition/has_pkgpart_cancelled.pm45
-rw-r--r--FS/FS/svc_Common.pm2
3 files changed, 90 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm b/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm
new file mode 100644
index 000000000..d6e25a4f7
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm
@@ -0,0 +1,43 @@
+package FS::part_event::Condition::has_pkg_class_cancelled;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description {
+ 'Customer has canceled package with class';
+}
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+#something like this
+sub option_fields {
+ (
+ 'pkgclass' => { 'label' => 'Package Class',
+ 'type' => 'select-pkg_class',
+ 'multiple' => 1,
+ },
+ 'age' => { 'label' => 'Cacnellation in last',
+ 'type' => 'freq',
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object, %opt ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my $age = $self->option_age_from('age', $opt{'time'} );
+
+ #XXX test
+ my $hashref = $self->option('pkgclass') || {};
+ grep { $hashref->{ $_->part_pkg->classnum } && $_->get('cancel') > $age }
+ $cust_main->cancelled_pkgs;
+}
+
+1;
diff --git a/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm b/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm
new file mode 100644
index 000000000..7e2a5671c
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm
@@ -0,0 +1,45 @@
+package FS::part_event::Condition::has_pkgpart_cancelled;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description { 'Customer has canceled specific package(s)'; }
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+sub option_fields {
+ (
+ 'if_pkgpart' => { 'label' => 'Only packages: ',
+ 'type' => 'select-part_pkg',
+ 'multiple' => 1,
+ },
+ 'age' => { 'label' => 'Cancellation in last',
+ 'type' => 'freq',
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object, %opt ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my $age = $self->option_age_from('age', $opt{'time'} );
+
+ my $if_pkgpart = $self->option('if_pkgpart') || {};
+ grep { $if_pkgpart->{ $_->pkgpart } && $_->get('cancel') > $age }
+ $cust_main->cancelled_pkgs;
+
+}
+
+#XXX
+#sub condition_sql {
+#
+#}
+
+1;
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index 4fd2d0b63..1dd9ffb63 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -719,6 +719,8 @@ sub setx {
sub part_svc {
my $self = shift;
+ cluck 'svc_X->part_svc called' if $DEBUG;
+
#get part_svc
my $svcpart;
if ( $self->get('svcpart') ) {