X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fcust_pay_or_refund.html;h=7d7fb73e9962a62062edbe7d40613c9641ed22b0;hb=9ece94ae50eaa9c326fc801d904565bbbd28b9ed;hp=1fea67c1946bcf76112276662274b380271ed9d1;hpb=cf512ab17435a0199ae13a8faefef94600a7a61b;p=freeside.git diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 1fea67c19..7d7fb73e9 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -26,6 +26,7 @@ Examples: 'html_init' => '', 'addl_header' => [], 'addl_fields' => [], + 'addl_sort_fields' => [], 'redirect_empty' => $redirect_empty, ) @@ -57,12 +58,12 @@ Examples: 'group_column' => 'payby', 'group_label' => 'payby_name', - 'subtotal' => { $opt{name_verb} => "sum($amount_field)" }, + 'subtotal' => { $opt{amount_field} => "sum($amount_field)" }, 'subtotal_row' => [ 'Subtotal', sub { sprintf($money, $_[0]->$amount_field) }, ], 'total_row' => [ 'Total', - sub { sprintf("$money", $_[0]->$amount_field) }, + sub { warn Dumper @_; sprintf("$money", $_[0]->$amount_field) }, ], 'show_combined' => 1, &> @@ -80,6 +81,8 @@ die "access denied" my $table = $opt{'table'} || 'cust_'.$opt{'thing'}; +my $has_reason = dbdef->table($table)->column('reasonnum') ? 1 : 0; + my $amount_field = $opt{'amount_field'}; my $name_singular = $opt{'name_singular'}; @@ -217,6 +220,7 @@ unless ( $opt{'disable_by'} ) { $o = 'customer self-service' if $o eq 'fs_selfservice'; $o; }; + push @sort_fields, ''; } if ( $tax_names ) { @@ -233,6 +237,7 @@ if ( $tax_names ) { split('\|', shift->tax_names) ); }; + push @sort_fields, '', ''; } push @header, FS::UI::Web::cust_header(); @@ -242,11 +247,14 @@ push @links, map { $_ ne 'Cust. Status' ? $cust_link : '' } my @color = ( ( map '', @fields ), FS::UI::Web::cust_colors() ); my @style = ( ( map '', @fields ), FS::UI::Web::cust_styles() ); push @fields, \&FS::UI::Web::cust_fields; +push @sort_fields, FS::UI::Web::cust_sort_fields; push @header, @{ $opt{'addl_header'} } if $opt{'addl_header'}; push @fields, @{ $opt{'addl_fields'} } if $opt{'addl_fields'}; +push @sort_fields, @{ $opt{'addl_sort_fields'} } + if $opt{'addl_sort_fields'}; my( $count_query, $sql_query, @count_addl ); if ( $cgi->param('magic') ) { @@ -292,7 +300,7 @@ if ( $cgi->param('magic') ) { foreach my $payby ( $cgi->param('payby') ) { $payby =~ - /^(CARD|CHEK|BILL|CASH|PPAL|APPL|ANRD|PREP|WIRE|WEST|EDI|MCRD|MCHK)(-(VisaMC|Amex|Discover|Maestro|Tokenized))?$/ + /^(CARD|CHEK|BILL|CASH|PPAL|APPL|ANRD|PREP|WIRE|WEST|IDTP|EDI|MCRD|MCHK)(-(VisaMC|Amex|Discover|Maestro|Tokenized))?$/ or die "illegal payby $payby"; my $payby_search = "$table.payby = '$1'"; @@ -432,6 +440,7 @@ if ( $cgi->param('magic') ) { push @search, "($table.auth LIKE '$1%') OR ($table.order_number LIKE '$1%')"; push @fields, 'auth', 'order_number'; push @header, 'Auth #', 'Transaction #'; + push @sort_fields, '', ''; $align .= 'rr'; } @@ -513,6 +522,18 @@ if ( $cgi->param('magic') ) { my $addl_from = FS::UI::Web::join_cust_main($table); my $group_by = ''; + # reasons, for refunds and voided payments + if ( $has_reason ) { + push @select, "reason.reason"; + $addl_from .= " LEFT JOIN reason USING (reasonnum)\n"; + push @fields, 'reason'; + push @sort_fields, 'reason.reason'; + push @header, emt('Reason'); + if ( $cgi->param('reasonnum') =~ /^(\d+)$/ ) { + push @search, "COALESCE(reasonnum, 0) = $1"; + } + } + if ( $cgi->param('tax_names') ) { if ( dbh->{Driver}->{Name} =~ /^Pg/i ) {