summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-12-05 15:30:19 -0800
committerJeremy Davis <jeremyd@freeside.biz>2014-12-09 13:52:29 -0500
commit44f4f5987dd09783b74fef7b569aabdc5c67d8cd (patch)
tree57c86ff7dccebe11b5c7a977f7ae87f0472adb5f /FS
parent6199f898a744f2cc2f9f03450d49286866a3f4d0 (diff)
add condition on signupdate age, RT#31213
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_event/Condition/signupdate_age.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/signupdate_age.pm b/FS/FS/part_event/Condition/signupdate_age.pm
new file mode 100644
index 000000000..70b4bbd7b
--- /dev/null
+++ b/FS/FS/part_event/Condition/signupdate_age.pm
@@ -0,0 +1,44 @@
+package FS::part_event::Condition::signupdate_age;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description { 'Customer signup age'; }
+
+#lots of falze laziness w/cust_bill_age, basically just swapped out the field
+
+sub option_fields {
+ (
+ 'age' => { label=>'Age', type=>'freq', },
+ );
+}
+
+sub condition {
+ my( $self, $cust_bill, %opt ) = @_;
+
+ my $age = $self->option_age_from('age', $opt{'time'} );
+
+ ( $cust_main->signupdate - 60 ) <= $age;
+
+}
+
+sub condition_sql {
+ my( $class, $table, %opt ) = @_;
+
+ my $age = $class->condition_sql_option_age_from('age', $opt{'time'} );
+
+ "( cust_main.signupdate - 60 ) <= $age";
+}
+
+# i don't think it really matters what order, since we're a customer condition?
+# this is for ordering different events for a customer
+sub order_sql {
+ shift->condition_sql_option_age('age');
+}
+
+sub order_sql_weight {
+ -1;
+}
+
+1;
+1;