X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_event.pm;h=93743c44782d8bc8da53fb15ca391e999babc81c;hb=8ff31f04ed1e2da3e09c56e72ab0f879d0b7ab75;hp=b29ab71bb5acd2a2fcbc8cd3e2d5fe0dc4671dc0;hpb=429a48b18a54917b73b3add468d930f60bcdb2fe;p=freeside.git diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm index b29ab71bb..93743c447 100644 --- a/FS/FS/cust_event.pm +++ b/FS/FS/cust_event.pm @@ -9,9 +9,10 @@ use FS::Record qw( qsearch qsearchs dbdef ); use FS::cust_main; use FS::cust_pkg; use FS::cust_bill; +use FS::cust_pay; use FS::svc_acct; -$DEBUG = 0; +$DEBUG = 1; $me = '[FS::cust_event]'; =head1 NAME @@ -53,6 +54,13 @@ L and L for conversion functions. =item statustext - additional status detail (i.e. error or progress message) +=item no_action - 'Y' if the event action wasn't performed. Some actions +contain an internal check to see if the action is going to be impossible (for +example, emailing a notice to a customer who has no email address), and if so, +won't attempt the action. It shouldn't be reported as a failure because +there's no need to retry it. However, the action should set no_action = 'Y' +so that there's a record. + =back =head1 METHODS @@ -140,6 +148,7 @@ sub check { || $self->ut_number('_date') || $self->ut_enum('status', [qw( new locked done failed initial)]) || $self->ut_anything('statustext') + || $self->ut_flag('no_action') ; return $error if $error; @@ -302,14 +311,16 @@ sub join_sql { JOIN part_event USING ( eventpart ) LEFT JOIN cust_bill ON ( eventtable = 'cust_bill' AND tablenum = invnum ) LEFT JOIN cust_pkg ON ( eventtable = 'cust_pkg' AND tablenum = pkgnum ) - + LEFT JOIN cust_pay ON ( eventtable = 'cust_pay' AND tablenum = paynum ) LEFT JOIN cust_svc ON ( eventtable = 'svc_acct' AND tablenum = svcnum ) LEFT JOIN cust_pkg AS cust_pkg_for_svc ON ( cust_svc.pkgnum = cust_pkg_for_svc.pkgnum ) - LEFT JOIN cust_main ON ( ( eventtable = 'cust_main' AND tablenum = cust_main.custnum ) - OR ( eventtable = 'cust_bill' AND cust_bill.custnum = cust_main.custnum ) - OR ( eventtable = 'cust_pkg' AND cust_pkg.custnum = cust_main.custnum ) - OR ( eventtable = 'svc_acct' AND cust_pkg_for_svc.custnum = cust_main.custnum ) - ) + LEFT JOIN cust_main ON ( + ( eventtable = 'cust_main' AND tablenum = cust_main.custnum ) + OR ( eventtable = 'cust_bill' AND cust_bill.custnum = cust_main.custnum ) + OR ( eventtable = 'cust_pkg' AND cust_pkg.custnum = cust_main.custnum ) + OR ( eventtable = 'cust_pay' AND cust_pay.custnum = cust_main.custnum ) + OR ( eventtable = 'svc_acct' AND cust_pkg_for_svc.custnum = cust_main.custnum ) + ) "; } @@ -337,10 +348,6 @@ specified in HASHREF. Valid parameters are =item ending -=item payby - -=item - =back =cut @@ -373,11 +380,49 @@ sub search_sql_where { push @search, "cust_event._date <= $1"; } - if ( $param->{'failed'} ) { - push @search, "statustext != ''", - "statustext IS NOT NULL", - "statustext != 'N/A'"; - } + #if ( $param->{'failed'} ) { + # push @search, "statustext != ''", + # "statustext IS NOT NULL", + # "statustext != 'N/A'"; + #} + # huh? + + my @event_status = ref($param->{'event_status'}) + ? @{ $param->{'event_status'} } + : split(',', $param->{'event_status'}); + if ( @event_status ) { + my @status; + + my ($done_Y, $done_N); + foreach (@event_status) { + if ($_ eq 'done_Y') { + $done_Y = 1; + } elsif ( $_ eq 'done_N' ) { + $done_N = 1; + } else { + push @status, $_; + } + } + if ( $done_Y or $done_N ) { + push @status, 'done'; + } + if ( @status ) { + push @search, "cust_event.status IN(" . + join(',', map "'$_'", @status) . + ')'; + } + + if ( $done_Y and not $done_N ) { + push @search, "cust_event.no_action IS NULL"; + } elsif ( $done_N and not $done_Y ) { + push @search, "cust_event.no_action = 'Y'"; + } # else they're both true, so don't add a constraint, or both false, + # and it doesn't matter. + + } # event_status + + # always hide initialization + push @search, 'cust_event.status != \'initial\''; if ( $param->{'custnum'} =~ /^(\d+)$/ ) { push @search, "cust_main.custnum = '$1'"; @@ -393,6 +438,11 @@ sub search_sql_where { "tablenum = '$1'"; } + if ( $param->{'paynum'} =~ /^(\d+)$/ ) { + push @search, "part_event.eventtable = 'cust_pay'", + "tablenum = '$1'"; + } + if ( $param->{'svcnum'} =~ /^(\d+)$/ ) { push @search, "part_event.eventtable = 'svc_acct'", "tablenum = '$1'"; @@ -434,13 +484,9 @@ sub process_refax { process_re_X('fax', @_); } -use Storable qw(thaw); use Data::Dumper; -use MIME::Base64; sub process_re_X { - my( $method, $job ) = ( shift, shift ); - - my $param = thaw(decode_base64(shift)); + my( $method, $job, $param ) = @_; warn Dumper($param) if $DEBUG; re_X( @@ -485,9 +531,10 @@ sub re_X { my $modenum = $part_event->option('modenum') || ''; my $invoice_from = $part_event->option('agent_invoice_from') || ''; $cust_X->set('mode' => $modenum); - $cust_X->$method( { template => $template, - modenum => $modenum, - invoice_from => $invoice_from } ); + $cust_X->$method( { template => $template, + modenum => $modenum, + from => $invoice_from, + } ); if ( $job ) { #progressbar foo $num++;