[freeside-commits] branch FREESIDE_3_BRANCH updated. 4dab4c85c1bd5162287ce239861ce1935ce6ed5a
Mark Wells
mark at 420.am
Thu May 8 16:05:05 PDT 2014
The branch, FREESIDE_3_BRANCH has been updated
via 4dab4c85c1bd5162287ce239861ce1935ce6ed5a (commit)
from cbbef4667255ebd902e330581c60a2280eb1d660 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4dab4c85c1bd5162287ce239861ce1935ce6ed5a
Author: Mark Wells <mark at freeside.biz>
Date: Thu May 8 15:44:06 2014 -0700
current day of month condition, #25899
diff --git a/FS/FS/part_event/Condition/day_of_month.pm b/FS/FS/part_event/Condition/day_of_month.pm
new file mode 100644
index 0000000..61cd8d6
--- /dev/null
+++ b/FS/FS/part_event/Condition/day_of_month.pm
@@ -0,0 +1,35 @@
+package FS::part_event::Condition::day_of_month;
+
+use strict;
+use base qw( FS::part_event::Condition );
+
+sub description {
+ "Run only on a certain day of the month",
+}
+
+sub option_fields {
+ (
+ 'day' => { label => 'Day (1-28, separate multiple days with commas)',
+ type => 'text',
+ },
+ );
+}
+
+sub condition { # is this even necessary? condition_sql is exact.
+ my( $self, $object, %opt ) = @_;
+
+ my $today = (localtime($opt{'time'}))[3];
+ if (grep { $_ == $today } split(',', $self->option('day'))) {
+ return 1;
+ }
+ '';
+}
+
+sub condition_sql {
+ my( $class, $table, %opt ) = @_;
+ my $today = (localtime($opt{'time'}))[3];
+ my $day = $class->condition_sql_option('day');
+ "$today = ANY( string_to_array($day, ',')::integer[] )"
+}
+
+1;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_event/Condition/day_of_month.pm | 35 ++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 FS/FS/part_event/Condition/day_of_month.pm
More information about the freeside-commits
mailing list