X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Fhas_cust_payby_auto.pm;h=f13b639aba470ea46a7c66be54cd0dd875fffd58;hp=edfb7eccb962a4724f1c92860fba6582f41676ce;hb=d2e75a0a9f47cfe1ecafce0fe8811dcb419d67d0;hpb=a4d4d3df88b33a6db30b565921f6d62efb252351 diff --git a/FS/FS/part_event/Condition/has_cust_payby_auto.pm b/FS/FS/part_event/Condition/has_cust_payby_auto.pm index edfb7eccb..f13b639ab 100644 --- a/FS/FS/part_event/Condition/has_cust_payby_auto.pm +++ b/FS/FS/part_event/Condition/has_cust_payby_auto.pm @@ -1,10 +1,10 @@ package FS::part_event::Condition::has_cust_payby_auto; +use base qw( FS::part_event::Condition ); use strict; use Tie::IxHash; use FS::payby; - -use base qw( FS::part_event::Condition ); +use FS::Record qw( qsearch dbh ); sub description { 'Customer has automatic payment information'; @@ -30,11 +30,24 @@ sub condition { my $cust_main = $self->cust_main($object); + #handle multiple (HASH) type options migrated from a v3 payby.pm condition + # (and maybe we should be a select-multiple or checkbox-multiple too?) + my @payby = (); + my $payby = $self->option('payby'); + if ( ref($payby) ) { + @payby = keys %$payby; + } elsif ( $payby ) { + @payby = ( $payby ); + } + scalar( qsearch({ 'table' => 'cust_payby', 'hashref' => { 'custnum' => $cust_main->custnum, - 'payby' => $self->option('payby') + #'payby' => $self->option('payby') }, + 'extra_sql' => 'AND payby IN ( '. + join(',', map dbh->quote($_), @payby). + ' ) ', 'order_by' => 'LIMIT 1', }) );