diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-03-13 18:11:08 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-03-13 18:11:08 -0700 |
commit | b4c6c58d3f10be9fcd18a449afd3c0d77fb67137 (patch) | |
tree | 536b6e08f9bb74346ae3307c8e8a5c46c5be6b4e | |
parent | 65bead8e2353121c19cc55f9483f2662c9f3bb23 (diff) |
multiple payment types on payment and refund reports, RT#21061
-rwxr-xr-x | httemplate/search/elements/cust_pay_or_refund.html | 179 | ||||
-rw-r--r-- | httemplate/search/elements/report_cust_pay_or_refund.html | 69 |
2 files changed, 128 insertions, 120 deletions
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 3dc54d936..4212daa23 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -263,78 +263,121 @@ if ( $cgi->param('magic') ) { } if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ - /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ - or die "illegal payby ". $cgi->param('payby'); - push @search, "$table.payby = '$1'"; - if ( $3 ) { - - my $cardtype = $3; - - 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]' ". - " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49033[5-9]' ". - " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49110[1-2]' ". - " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49117[4-9]' ". - " AND substring($table.payinfo from 1 for 6) ". - " NOT SIMILAR TO '49118[1-2]' ". - " )". - " OR substring($table.payinfo from 1 for 2) = '51' ". - " OR substring($table.payinfo from 1 for 2) = '52' ". - " OR substring($table.payinfo from 1 for 2) = '53' ". - " OR substring($table.payinfo from 1 for 2) = '54' ". - " OR substring($table.payinfo from 1 for 2) = '54' ". - " OR substring($table.payinfo from 1 for 2) = '55' ". - " OR substring($table.payinfo from 1 for 2) = '36' ". #Diner's int'l processed as Visa/MC inside US - " ) "; - } 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' ) { - $search = - " ( substring($table.payinfo from 1 for 4 ) = '6011' ". - " OR substring($table.payinfo from 1 for 2 ) = '65' ". - " OR substring($table.payinfo from 1 for 3 ) = '622' ". #China Union Pay processed as Discover outside CN - " ) "; - } 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]' ". - " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49033[5-9]' ". - " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49110[1-2]' ". - " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49117[4-9]' ". - " OR substring($table.payinfo from 1 for 6 ) ". - " SIMILAR TO '49118[1-2]' ". - " ) "; - } else { - die "unknown card type $cardtype"; - } - my $masksearch = $search; - $masksearch =~ s/$table\.payinfo/$table.paymask/gi; + my @all_payby_search = (); + foreach my $payby ( $cgi->param('payby') ) { + + $payby =~ + /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/ + or die "illegal payby $payby"; + + my $payby_search = "$table.payby = '$1'"; + + if ( $3 ) { + + my $cardtype = $3; + + 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]' ". + " AND substring($table.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49033[5-9]' ". + " AND substring($table.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49110[1-2]' ". + " AND substring($table.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49117[4-9]' ". + " AND substring($table.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49118[1-2]' ". + " )". + " OR substring($table.payinfo from 1 for 2) = '51' ". + " OR substring($table.payinfo from 1 for 2) = '52' ". + " OR substring($table.payinfo from 1 for 2) = '53' ". + " OR substring($table.payinfo from 1 for 2) = '54' ". + " OR substring($table.payinfo from 1 for 2) = '54' ". + " 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; + my $country = $conf->config('countrydefault') || 'US'; + + $search = + " ( substring($table.payinfo from 1 for 4 ) = '6011' ". + " OR substring($table.payinfo from 1 for 2 ) = '65' ". + " OR substring($table.payinfo from 1 for 3 ) = '300' ". + " OR substring($table.payinfo from 1 for 3 ) = '301' ". + " OR substring($table.payinfo from 1 for 3 ) = '302' ". + " OR substring($table.payinfo from 1 for 3 ) = '303' ". + " OR substring($table.payinfo from 1 for 3 ) = '304' ". + " OR substring($table.payinfo from 1 for 3 ) = '305' ". + " OR substring($table.payinfo from 1 for 4 ) = '3095' ". + " OR substring($table.payinfo from 1 for 2 ) = '36' ". + " OR substring($table.payinfo from 1 for 2 ) = '38' ". + " OR substring($table.payinfo from 1 for 2 ) = '39' ". + " OR substring($table.payinfo from 1 for 3 ) = '644' ". + " OR substring($table.payinfo from 1 for 3 ) = '645' ". + " OR substring($table.payinfo from 1 for 3 ) = '646' ". + " OR substring($table.payinfo from 1 for 3 ) = '647' ". + " OR substring($table.payinfo from 1 for 3 ) = '648' ". + " OR substring($table.payinfo from 1 for 3 ) = '649' ". + ( $country =~ /^(US|CA)$/ + ?" OR substring($table.payinfo from 1 for 4 ) = '3528' ". # JCB cards in the 3528-3589 range identified as Discover inside US/CA + " OR substring($table.payinfo from 1 for 4 ) = '3529' ". + " OR substring($table.payinfo from 1 for 3 ) = '353' ". + " OR substring($table.payinfo from 1 for 3 ) = '354' ". + " OR substring($table.payinfo from 1 for 3 ) = '355' ". + " OR substring($table.payinfo from 1 for 3 ) = '356' ". + " OR substring($table.payinfo from 1 for 3 ) = '357' ". + " OR substring($table.payinfo from 1 for 3 ) = '358' " + :"" + ). + " OR substring($table.payinfo from 1 for 3 ) = '622' ". #China Union Pay processed as Discover outside CN + " ) "; + } 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]' ". + " OR substring($table.payinfo from 1 for 6 ) ". + " SIMILAR TO '49033[5-9]' ". + " OR substring($table.payinfo from 1 for 6 ) ". + " SIMILAR TO '49110[1-2]' ". + " OR substring($table.payinfo from 1 for 6 ) ". + " SIMILAR TO '49117[4-9]' ". + " OR substring($table.payinfo from 1 for 6 ) ". + " SIMILAR TO '49118[1-2]' ". + " ) "; + } else { + die "unknown card type $cardtype"; + } + + my $masksearch = $search; + $masksearch =~ s/$table\.payinfo/$table.paymask/gi; + + $payby_search = "( $payby_search AND ( $search OR ( $table.paymask IS NOT NULL AND $masksearch ) ) )"; + + } - push @search, - "( $search OR ( $table.paymask IS NOT NULL AND $masksearch ) )"; + push @all_payby_search, $payby_search; } + + push @search, join(' OR ', @all_payby_search) if @all_payby_search; + } if ( $cgi->param('payinfo') ) { diff --git a/httemplate/search/elements/report_cust_pay_or_refund.html b/httemplate/search/elements/report_cust_pay_or_refund.html index 0e04ab0dd..872031de5 100644 --- a/httemplate/search/elements/report_cust_pay_or_refund.html +++ b/httemplate/search/elements/report_cust_pay_or_refund.html @@ -30,68 +30,33 @@ Examples: <TR> <TD ALIGN="right"><% ucfirst(PL($name_singular)) %> of type: </TD> <TD> - <SELECT NAME="payby" onChange="payby_changed(this)"> - <OPTION VALUE=""><% mt('all') |h %></OPTION> - <OPTION VALUE="CARD"><% mt('credit card (all)') |h %></OPTION> - <OPTION VALUE="CARD-VisaMC"><% mt('credit card (Visa/MasterCard)') |h %></OPTION> - <OPTION VALUE="CARD-Amex"><% mt('credit card (American Express)') |h %></OPTION> - <OPTION VALUE="CARD-Discover"><% mt('credit card (Discover)') |h %></OPTION> - <OPTION VALUE="CARD-Maestro"><% mt('credit card (Maestro/Switch/Solo)') |h %></OPTION> - <OPTION VALUE="CHEK"><% mt('electronic check / ACH') |h %></OPTION> - <OPTION VALUE="BILL"><% mt('check') |h %></OPTION> - <OPTION VALUE="PREP"><% mt('prepaid card') |h %></OPTION> - <OPTION VALUE="CASH"><% mt('cash') |h %></OPTION> - <OPTION VALUE="WEST"><% mt('Western Union') |h %></OPTION> - <OPTION VALUE="MCRD"><% mt('manual credit card') |h %></OPTION> + <SELECT NAME="payby" SIZE=10 MULTIPLE> +%# <OPTION VALUE=""><% mt('all') |h %></OPTION> +%# <OPTION VALUE="CARD"><% mt('credit card (all)') |h %></OPTION> + <OPTION VALUE="CARD-VisaMC" SELECTED><% mt('credit card (Visa/MasterCard)') |h %></OPTION> + <OPTION VALUE="CARD-Amex" SELECTED><% mt('credit card (American Express)') |h %></OPTION> + <OPTION VALUE="CARD-Discover" SELECTED><% mt('credit card (Discover)') |h %></OPTION> + <OPTION VALUE="CARD-Maestro" SELECTED><% mt('credit card (Maestro/Switch/Solo)') |h %></OPTION> + <OPTION VALUE="CHEK" SELECTED><% mt('electronic check / ACH') |h %></OPTION> + <OPTION VALUE="BILL" SELECTED><% mt('check') |h %></OPTION> + <OPTION VALUE="PREP" SELECTED><% mt('prepaid card') |h %></OPTION> + <OPTION VALUE="CASH" SELECTED><% mt('cash') |h %></OPTION> + <OPTION VALUE="WEST" SELECTED><% mt('Western Union') |h %></OPTION> + <OPTION VALUE="MCRD" SELECTED><% mt('manual credit card') |h %></OPTION> </SELECT> </TD> </TR> - <SCRIPT TYPE="text/javascript"> - - function payby_changed(what) { - if ( what.value == 'BILL' ) { - show('payinfo'); - hide('ccpay'); - } else if ( what.value.match(/^CARD|CHEK/) ) { - hide('payinfo'); - show('ccpay'); - } else { - hide('payinfo'); - hide('ccpay'); - } - } - - function show(what) { - document.getElementById(what+'_caption').style.color = '#000000'; - document.getElementById(what).disabled = false; - document.getElementById(what).style.backgroundColor = '#ffffff'; - } - - function hide(what) { - document.getElementById(what+'_caption').style.color = '#bbbbbb'; - document.getElementById(what).disabled = true; - document.getElementById(what).style.backgroundColor = '#dddddd'; - } - - - - </SCRIPT> - <TR> - <TD ALIGN="right"><FONT ID="payinfo_caption" COLOR="#bbbbbb"><% mt('Check #:') |h %> </FONT></TD> + <TD ALIGN="right"><% mt('Check #:') |h %> </TD> <TD> - <INPUT TYPE="text" ID="payinfo" NAME="payinfo" DISABLED STYLE="background-color: #dddddd"> + <INPUT TYPE="text" ID="payinfo" NAME="payinfo"> </TD> </TR> <TR> - <TD ALIGN="right"> - <FONT ID="ccpay_caption" COLOR="#bbbbbb"> - <% mt('Transaction #') |h %> - </FONT> - </TD> + <TD ALIGN="right"><% mt('Transaction #:') |h %> </TD> <TD> - <INPUT TYPE="text" ID="ccpay" NAME="ccpay" DISABLED STYLE="background-color: #dddddd"> + <INPUT TYPE="text" ID="ccpay" NAME="ccpay"> </TD> </TR> |