1 package FS::part_event::Condition::stagger;
4 use FS::Record qw( qsearch );
8 use base qw( FS::part_event::Condition );
10 sub description { "Stagger this event across the month" }; #could be clearer?
13 # delay? it's supposed to be arbitrary anyway
17 my($self, $object, %opt) = @_;
19 my $obj_pkey = $object->primary_key;
20 my $tablenum = $object->$obj_pkey();
22 my ($today) = (localtime($opt{'time'}))[3];
24 $today - 1 == ($tablenum - 1) % 28;
28 my( $class, $table, %opt ) = @_;
30 my %tablenum = %{ FS::part_event->eventtable_pkey_sql };
33 if ( $opt{'driver_name'} eq 'Pg' ) {
34 $today = "EXTRACT( DAY FROM TO_TIMESTAMP(".$opt{'time'}.") )::INTEGER";
36 elsif ( $opt{'driver_name'} eq 'mysql' ) {
37 $today = "DAY( FROM_UNIXTIME(".$opt{'time'}.") )";
42 "($today - 1) = ($tablenum{$table} - 1) % 28";