X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fcust_pay_or_refund.html;h=697cf844bb365b66232367a8806501b104083d20;hb=4d7a5f06cbab1f4f9614d9915641557f4edad1cf;hp=ce513ab15ed3e150eb9e41af7b550a73c18753d9;hpb=062f38f2f5d0da64c6fd0702d4df2e805473a1f5;p=freeside.git
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html
index ce513ab15..697cf844b 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,13 +58,14 @@ Examples:
'group_column' => 'payby',
'group_label' => 'payby_name',
- 'subtotal' => { 'paid' => 'sum(paid)' },
+ 'subtotal' => { $opt{name_verb} => "sum($amount_field)" },
'subtotal_row' => [ 'Subtotal',
- sub { sprintf($money, $_[0]->paid) },
+ sub { sprintf($money, $_[0]->$amount_field) },
],
'total_row' => [ 'Total',
- sub { sprintf("$money", $_[0]->paid) },
+ sub { sprintf("$money", $_[0]->$amount_field) },
],
+ 'show_combined' => 1,
&>
<%init>
@@ -79,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'};
@@ -181,7 +185,17 @@ push @fields, 'payby_payinfo_pretty',
sub { sprintf($money, shift->$amount_field() ) },
;
push @link_onclicks, $sub_receipt, '';
-push @sort_fields, '', $amount_field;
+push @sort_fields, 'paysort', $amount_field;
+
+if ($opt{'show_card_type'}) {
+ push @header, emt('Card Type');
+ $align .= 'r';
+ push @links, '';
+ push @fields, sub {
+ (($_[0]->payby eq 'CARD') && ($_[0]->paymask !~ /N\/A/)) ? cardtype($_[0]->paymask) : ''
+ };
+ push @sort_fields, '';
+}
if ( $unapplied ) {
push @header, emt('Unapplied');
@@ -206,6 +220,7 @@ unless ( $opt{'disable_by'} ) {
$o = 'customer self-service' if $o eq 'fs_selfservice';
$o;
};
+ push @sort_fields, '';
}
if ( $tax_names ) {
@@ -222,6 +237,7 @@ if ( $tax_names ) {
split('\|', shift->tax_names)
);
};
+ push @sort_fields, '', '';
}
push @header, FS::UI::Web::cust_header();
@@ -231,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') ) {
@@ -243,6 +262,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',
);
@@ -280,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'";
@@ -420,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';
}
@@ -501,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 ) {