add link to some batched payment info to customer view
authorivan <ivan>
Sun, 4 Feb 2007 01:47:51 +0000 (01:47 +0000)
committerivan <ivan>
Sun, 4 Feb 2007 01:47:51 +0000 (01:47 +0000)
httemplate/search/cust_pay_batch.cgi
httemplate/view/cust_main/payment_history.html

index fec3dfd..e378ffa 100755 (executable)
 %>
 <%init>
 
+my $conf = new FS::Conf;
+
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports')
-      || $FS::CurrentUser::CurrentUser->access_right('Process batches');
+      || $FS::CurrentUser::CurrentUser->access_right('Process batches')
+      || ( $cgi->param('custnum') 
+           && $conf->exists('batch-enable')
+           #&& $FS::CurrentUser::CurrentUser->access_right('View customer batched payments')
+         );
 
 my( $count_query, $sql_query );
 my $hashref = {};
@@ -75,6 +81,14 @@ if ( $cgi->param('batchnum') && $cgi->param('batchnum') =~ /^(\d+)$/ ) {
   $batchnum = $pay_batch->batchnum;
 }
 
+if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
+  push @search, "custnum = $1";
+}
+
+if ( $cgi->param('status') && $cgi->param('status') =~ /^(\w)$/ ) {
+  push @search, "pay_batch.status = '$1'";
+}
+
 if ( $cgi->param('payby') ) {
   $cgi->param('payby') =~ /^(CARD|CHEK)$/
     or die "illegal payby " . $cgi->param('payby');
@@ -111,7 +125,6 @@ $sql_query = "SELECT paybatchnum,invnum,custnum,cpb.last,cpb.first," .
 
 my $html_init = '';
 if ( $pay_batch ) {
-  my $conf = new FS::Conf;
   my $fixed = $conf->config('batch-fixed_format-'. $pay_batch->payby);
   if (
        $pay_batch->status eq 'O' 
index 43c55e8..b2d98cc 100644 (file)
   <BR>
 % } 
 
+% if ( $conf->exists('batch-enable')
+%      #&& $curuser->access_right('View customer tax exemptions')
+%    ) { 
+  View batched payments:
+%   foreach my $status (qw( Queued In-transit Complete All )) {
+      <A HREF="<% $p %>search/cust_pay_batch.cgi?status=<% $status{$status} %>;custnum=<% $custnum %>"><% $status %></A> 
+      <% $status ne 'All' ? '|' : '' %>
+%   }
+  <BR>
+% } 
+
 %#get payment history
 %my @history = ();
 %
@@ -584,4 +595,11 @@ my @payby = grep /\w/, $conf->config('payby');
   unless @payby;
 my %payby = map { $_=>1 } @payby;
 
+my %status = (
+  'Queued'     => 'O', #Open
+  'In-transit' => 'I',
+  'Complete'   => 'R', #Resolved
+  'All'        => '',
+);
+
 </%init>