record and show batch payment status info, #21117
[freeside.git] / httemplate / search / elements / cust_pay_or_refund.html
index dc3cb2a..b9da7ef 100755 (executable)
@@ -51,6 +51,7 @@ Examples:
                 'sort_fields'    => \@sort_fields,
                 'align'          => $align,
                 'links'          => \@links,
+                'link_onclicks'  => \@link_onclicks,
                 'color'          => \@color,
                 'style'          => \@style,
 &>
@@ -134,11 +135,12 @@ if ( $cgi->param('tax_names') ) {
   }
 }
 
-my @header = ();
-my @fields = ();
-my @sort_fields = ();
+my @header;
+my @fields;
+my @sort_fields;
 my $align = '';
-my @links = ();
+my @links;
+my @link_onclicks;
 if ( $opt{'pre_header'} ) {
   push @header, @{ $opt{'pre_header'} };
   $align .= 'c' x scalar(@{ $opt{'pre_header'} });
@@ -147,6 +149,16 @@ if ( $opt{'pre_header'} ) {
   push @sort_fields, @{ $opt{'pre_fields'} };
 }
 
+my $sub_receipt = sub {
+  my $obj = shift;
+  my $objnum = $obj->primary_key . '=' . $obj->get($obj->primary_key);
+
+  include('/elements/popup_link_onclick.html',
+    'action'  => $p.'view/cust_pay.html?link=popup;'.$objnum,
+    'actionlabel' => emt('Payment Receipt'),
+  );
+};
+
 push @header, "\u$name_singular",
               'Amount',
 ;
@@ -155,6 +167,7 @@ push @links, '', '';
 push @fields, 'payby_payinfo_pretty',
               sub { sprintf('$%.2f', shift->$amount_field() ) },
 ;
+push @link_onclicks, $sub_receipt, '',
 push @sort_fields, '', $amount_field;
 
 if ( $unapplied ) {
@@ -239,6 +252,12 @@ if ( $cgi->param('magic') ) {
       $title = $part_referral->referral. " $title";
     }
 
+    if ( $cgi->param('cust_classnum') ) {
+      my @classnums = grep /^\d+$/, $cgi->param('cust_classnum');
+      push @search, 'cust_main.classnum IN('.join(',',@classnums).')'
+        if @classnums;
+    }
+
     if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
       push @search, "custnum = $1";
     }
@@ -324,6 +343,16 @@ if ( $cgi->param('magic') ) {
       push @search, "$table.payinfo = '$1'";
     }
 
+    if ( $cgi->param('ccpay') =~ /^([\w-:]+)$/ ) {
+      # I think that's all the characters we need to allow.
+      # To avoid confusion, this parameter searches both auth and order_number.
+      push @search, "($table.auth LIKE '$1%') OR ($table.order_number LIKE '$1%')";
+      push @fields, 'auth', 'order_number';
+      push @header, 'Auth #', 'Transaction #';
+      $align .= 'rr';
+
+    }
+
     if ( $cgi->param('usernum') =~ /^(\d+)$/ ) {
       push @search, "$table.usernum = $1";
     }
@@ -357,6 +386,15 @@ if ( $cgi->param('magic') ) {
 
     $orderby = "LOWER(company || ' ' || last || ' ' || first )";
 
+  } elsif ( $cgi->param('magic') eq 'batchnum' ) {
+
+    $cgi->param('batchnum') =~ /^(\d+)$/
+      or die "illegal batchnum: ".$cgi->param('batchnum');
+
+    push @search, "batchnum = $1";
+
+    $orderby = "LOWER(company || ' ' || last || ' ' || first )";
+
   } else {
     die "unknown search magic: ". $cgi->param('magic');
   }