X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fcust_pay_or_refund.html;h=5808e5f3edbb2e334f7f75c72ca918330c5cc86e;hb=c0c5709fb022b83a482d0b35f7094505766d5868;hp=b5172fb36d297750e802207079e733906b1e614e;hpb=5f4452d8d9cfe03330e3dc1da529ff6cf0f65882;p=freeside.git
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html
index b5172fb36..5808e5f3e 100755
--- a/httemplate/search/elements/cust_pay_or_refund.html
+++ b/httemplate/search/elements/cust_pay_or_refund.html
@@ -39,7 +39,7 @@ Examples:
)
%doc>
-<& search.html,
+<& grouped-search.html,
'title' => $title, # XXX: translate
'name_singular' => $name_singular,
'query' => $sql_query,
@@ -54,6 +54,17 @@ Examples:
'link_onclicks' => \@link_onclicks,
'color' => \@color,
'style' => \@style,
+
+ 'group_column' => 'payby',
+ 'group_label' => 'payby_name',
+ 'subtotal' => { $opt{name_verb} => "sum($amount_field)" },
+ 'subtotal_row' => [ 'Subtotal',
+ sub { sprintf($money, $_[0]->$amount_field) },
+ ],
+ 'total_row' => [ 'Total',
+ sub { sprintf("$money", $_[0]->$amount_field) },
+ ],
+ 'show_combined' => 1,
&>
<%init>
@@ -61,6 +72,9 @@ my %opt = @_;
my $curuser = $FS::CurrentUser::CurrentUser;
+my $conf = FS::Conf->new;
+my $money = ($conf->config('money_char') || '$') . '%.2f';
+
die "access denied"
unless $curuser->access_right('Financial reports');
@@ -165,16 +179,16 @@ push @header, "\u$name_singular",
$align .= 'rr';
push @links, '', '';
push @fields, 'payby_payinfo_pretty',
- sub { sprintf('$%.2f', shift->$amount_field() ) },
+ sub { sprintf($money, shift->$amount_field() ) },
;
push @link_onclicks, $sub_receipt, '';
-push @sort_fields, '', $amount_field;
+push @sort_fields, 'paysort', $amount_field;
if ( $unapplied ) {
push @header, emt('Unapplied');
$align .= 'r';
push @links, '';
- push @fields, sub { sprintf('$%.2f', shift->unapplied_amount) };
+ push @fields, sub { sprintf($money, shift->unapplied_amount) };
push @sort_fields, '';
}
@@ -230,6 +244,7 @@ if ( $cgi->param('magic') ) {
my @search = ();
my @select = (
"$table.*",
+ "( $table.payby || ' ' || coalesce($table.paymask, $table.payinfo) ) AS paysort",
FS::UI::Web::cust_sql_fields(),
'cust_main.custnum AS cust_main_custnum',
);
@@ -252,14 +267,10 @@ if ( $cgi->param('magic') ) {
$title = $part_referral->referral. " $title";
}
- # cust_classnum (false laziness w/ elements/cust_main_dayranges.html, prepaid_income.html, cust_bill_pay.html, cust_bill_pkg.html cust_bill_pkg_referral.html, unearned_detail.html, cust_credit.html, cust_credit_refund.html, cust_main::Search::search_sql)
- if ( grep { $_ eq 'cust_classnum' } $cgi->param ) {
- my @classnums = grep /^\d*$/, $cgi->param('cust_classnum');
- push @search, 'COALESCE( cust_main.classnum, 0) IN ( '.
- join(',', map { $_ || '0' } @classnums ).
- ' )'
- if @classnums;
- }
+ # cust_classnum - standard matching
+ push @search, $m->comp('match-classnum',
+ param => 'cust_classnum', field => 'cust_main.classnum'
+ );
if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
push @search, "$table.custnum = $1";
@@ -271,7 +282,7 @@ if ( $cgi->param('magic') ) {
foreach my $payby ( $cgi->param('payby') ) {
$payby =~
- /^(CARD|CHEK|BILL|CASH|PPAL|APPL|ANRD|PREP|WIRE|WEST|EDI|MCRD)(-(VisaMC|Amex|Discover|Maestro|Tokenized))?$/
+ /^(CARD|CHEK|BILL|CASH|PPAL|APPL|ANRD|PREP|WIRE|WEST|EDI|MCRD|MCHK)(-(VisaMC|Amex|Discover|Maestro|Tokenized))?$/
or die "illegal payby $payby";
my $payby_search = "$table.payby = '$1'";
@@ -321,7 +332,6 @@ if ( $cgi->param('magic') ) {
} elsif ( $cardtype eq 'Discover' ) {
- my $conf = new FS::Conf;
my $country = $conf->config('countrydefault') || 'US';
$search =
@@ -402,7 +412,8 @@ if ( $cgi->param('magic') ) {
if ( $cgi->param('payinfo') ) {
$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/
or die "illegal payinfo ". $cgi->param('payinfo');
- push @search, "$table.payinfo = '$1'";
+ my $regexp = regexp_sql();
+ push @search, "$table.payinfo $regexp '^0*$1\$'";
}
if ( $cgi->param('ccpay') =~ /^([\w-:]+)$/ ) {
@@ -436,7 +447,7 @@ if ( $cgi->param('magic') ) {
"$table.void_date <= $v_ending";
}
- push @search, FS::UI::Web::parse_lt_gt($cgi, "$table.$amount_field" );
+ push @search, FS::UI::Web::parse_lt_gt($cgi, $amount_field, $table);
$orderby = '_date';
@@ -538,6 +549,7 @@ if ( $cgi->param('magic') ) {
} else {
#hmm... is this still used?
+ warn "undefined search magic";
$cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo";
my $payinfo = $1;