1 package FS::part_event::Condition::once;
4 use FS::Record qw( qsearch );
8 use base qw( FS::part_event::Condition );
10 sub description { "Don't run this event again after it has completed successfully"; }
12 sub implicit_flag { 10; }
15 'Are you sure you want to remove this condition? Doing so will allow this event to run every time the other conditions are satisfied, even if it has already run sucessfully.'; #better error msg?
19 my($self, $object, %opt) = @_;
21 my $obj_pkey = $object->primary_key;
22 my $tablenum = $object->$obj_pkey();
24 my @existing = qsearch( {
25 'table' => 'cust_event',
27 'eventpart' => $self->eventpart,
28 'tablenum' => $tablenum,
29 'status' => { op=>'!=', value=>'failed' },
31 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
32 ? " AND eventnum != $1 "
42 my( $self, $table ) = @_;
44 my %tablenum = %{ FS::part_event->eventtable_pkey_sql };
46 "NOT EXISTS ( SELECT 1 FROM cust_event
47 WHERE cust_event.eventpart = part_event.eventpart
48 AND cust_event.tablenum = $tablenum{$table}
49 AND status != 'failed'