X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fcust_pay_or_refund.html;h=8aece0cc24f30f692a1f1ae34628609c09571141;hb=af501d08494e5930d53da1cb1f02e65e2a6ebd07;hp=7b2a17058901d4c0b431a6eee8f8a42f5f66296c;hpb=f3e0ac2b009c4edd5692cb587ff709dac2223ebe;p=freeside.git diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 7b2a17058..8aece0cc2 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -108,7 +108,7 @@ my $cust_link = sub { # only valid for $table == 'cust_pay' atm my $tax_names = ''; if ( $cgi->param('tax_names') ) { - if ( dbh->{Driver}->{Name} eq 'Pg' ) { + if ( dbh->{Driver}->{Name} =~ /^Pg/i ) { $tax_names = " array_to_string( @@ -167,7 +167,7 @@ push @links, '', ''; push @fields, 'payby_payinfo_pretty', sub { sprintf('$%.2f', shift->$amount_field() ) }, ; -push @link_onclicks, $sub_receipt, '', +push @link_onclicks, $sub_receipt, ''; push @sort_fields, '', $amount_field; if ( $unapplied ) { @@ -271,7 +271,7 @@ if ( $cgi->param('magic') ) { foreach my $payby ( $cgi->param('payby') ) { $payby =~ - /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ + /^(CARD|CHEK|BILL|CASH|PPAL|APPL|ANRD|PREP|WIRE|WEST|EDI|MCRD)(-(VisaMC|Amex|Discover|Maestro|Tokenized))?$/ or die "illegal payby $payby"; my $payby_search = "$table.payby = '$1'"; @@ -280,22 +280,28 @@ if ( $cgi->param('magic') ) { my $cardtype = $3; + my $similar_to = dbh->{Driver}->{Name} =~ /^mysql/i + ? 'REGEXP' #doesn't behave exactly the same, but + #should work for our patterns + : 'SIMILAR TO'; + my $search; if ( $cardtype eq 'VisaMC' ) { + #avoid posix regexes for portability $search = " ( ( substring($table.payinfo from 1 for 1) = '4' ". " AND substring($table.payinfo from 1 for 4) != '4936' ". " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49030[2-9]' ". + " NOT $similar_to '49030[2-9]' ". " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49033[5-9]' ". + " NOT $similar_to '49033[5-9]' ". " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49110[1-2]' ". + " NOT $similar_to '49110[1-2]' ". " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49117[4-9]' ". + " NOT $similar_to '49117[4-9]' ". " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49118[1-2]' ". + " NOT $similar_to '49118[1-2]' ". " )". " OR substring($table.payinfo from 1 for 2) = '51' ". " OR substring($table.payinfo from 1 for 2) = '52' ". @@ -305,11 +311,14 @@ if ( $cgi->param('magic') ) { " OR substring($table.payinfo from 1 for 2) = '55' ". # " OR substring($table.payinfo from 1 for 2) = '36' ". #Diner's int'l was processed as Visa/MC inside US, now Discover " ) "; + } elsif ( $cardtype eq 'Amex' ) { + $search = " ( substring($table.payinfo from 1 for 2 ) = '34' ". " OR substring($table.payinfo from 1 for 2 ) = '37' ". " ) "; + } elsif ( $cardtype eq 'Discover' ) { my $conf = new FS::Conf; @@ -347,23 +356,30 @@ if ( $cgi->param('magic') ) { ). " OR substring($table.payinfo from 1 for 3 ) = '622' ". #China Union Pay processed as Discover outside CN " ) "; - } elsif ( $cardtype eq 'Maestro' ) { + + } elsif ( $cardtype eq 'Maestro' ) { + $search = " ( substring($table.payinfo from 1 for 2 ) = '63' ". " OR substring($table.payinfo from 1 for 2 ) = '67' ". " OR substring($table.payinfo from 1 for 6 ) = '564182' ". " OR substring($table.payinfo from 1 for 4 ) = '4936' ". " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49030[2-9]' ". + " $similar_to '49030[2-9]' ". " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49033[5-9]' ". + " $similar_to '49033[5-9]' ". " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49110[1-2]' ". + " $similar_to '49110[1-2]' ". " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49117[4-9]' ". + " $similar_to '49117[4-9]' ". " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49118[1-2]' ". + " $similar_to '49118[1-2]' ". " ) "; + + } elsif ( $cardtype eq 'Tokenized' ) { + + $search = " substring($table.payinfo from 1 for 2 ) = '99' "; + } else { die "unknown card type $cardtype"; } @@ -429,8 +445,6 @@ if ( $cgi->param('magic') ) { $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ or die "illegal paybatch: ". $cgi->param('paybatch'); - push @search, "paybatch = '$1'"; - $orderby = "LOWER(company || ' ' || last || ' ' || first )"; } elsif ( $cgi->param('magic') eq 'batchnum' ) { @@ -446,6 +460,10 @@ if ( $cgi->param('magic') ) { die "unknown search magic: ". $cgi->param('magic'); } + if ( $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ ) { + push @search, "paybatch = '$1'"; + } + #unapplied payment/refund if ( $unapplied ) { push @select, '(' . "FS::$table"->unapplied_sql . ') AS unapplied_amount'; @@ -475,7 +493,7 @@ if ( $cgi->param('magic') ) { my $group_by = ''; if ( $cgi->param('tax_names') ) { - if ( dbh->{Driver}->{Name} eq 'Pg' ) { + if ( dbh->{Driver}->{Name} =~ /^Pg/i ) { 0;#twiddle thumbs