[freeside-commits] branch FREESIDE_4_BRANCH updated. 0ea99482851f5c4d7afa6cfc9c08c3b29f0732a8

Jonathan Prykop jonathan at 420.am
Mon Apr 25 11:59:12 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  0ea99482851f5c4d7afa6cfc9c08c3b29f0732a8 (commit)
       via  b30092c51c12237a3da8d9efcb42af407d5239f2 (commit)
      from  092a6224ced3404893632c0d9c5a59bb91fc2cdd (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 0ea99482851f5c4d7afa6cfc9c08c3b29f0732a8
Merge: b30092c 092a622
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Apr 25 13:59:03 2016 -0500

    Merge branch 'FREESIDE_4_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_4_BRANCH


commit b30092c51c12237a3da8d9efcb42af407d5239f2
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Apr 25 13:49:57 2016 -0500

    RT#37544 Prevent billing events from running on weekends

diff --git a/FS/FS/part_event/Condition/day_of_week.pm b/FS/FS/part_event/Condition/day_of_week.pm
new file mode 100644
index 0000000..6b84310
--- /dev/null
+++ b/FS/FS/part_event/Condition/day_of_week.pm
@@ -0,0 +1,49 @@
+package FS::part_event::Condition::day_of_week;
+
+use strict;
+use base qw( FS::part_event::Condition );
+use FS::Record qw( dbh );
+
+tie my %dayofweek, 'Tie::IxHash', 
+  0 => 'Sunday',
+  1 => 'Monday',
+  2 => 'Tuesday',
+  3 => 'Wednesday',
+  4 => 'Thursday',
+  5 => 'Friday',
+  6 => 'Saturday',
+;
+
+sub description {
+  "Run only on certain days of the week",
+}
+
+sub option_fields {
+  (
+    'dayofweek' => {
+       label         => 'Days to run',
+       type          => 'checkbox-multiple',
+       options       => [ values %dayofweek ],
+       option_labels => { map { $_ => $_ } values %dayofweek },
+    },
+  );
+}
+
+sub condition { # is this even necessary? condition_sql is exact.
+  my( $self, $object, %opt ) = @_;
+
+  my $today = $dayofweek{(localtime($opt{'time'}))[6]};
+  if (grep { $_ eq $today } (keys %{$self->option('dayofweek')})) {
+    return 1;
+  }
+  '';
+}
+
+sub condition_sql {
+  my( $class, $table, %opt ) = @_;
+  my $today = $dayofweek{(localtime($opt{'time'}))[6]};
+  my $day = $class->condition_sql_option_option('dayofweek');
+  return dbh->quote($today) . " IN $day";
+}
+
+1;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_event/Condition/day_of_week.pm |   49 +++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 FS/FS/part_event/Condition/day_of_week.pm




More information about the freeside-commits mailing list