this ACL has been around for long enough (and almost nobody uses batched payments...
[freeside.git] / httemplate / view / cust_main / payment_history.html
index a23ca9a..cbe143d 100644 (file)
   <BR>
 % } 
 
+% if ( $conf->exists('batch-enable')
+%      && $curuser->access_right('View customer batched payments')
+%    ) { 
+  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 = ();
 %
 %  my $link = $curuser->access_right('View invoices')
 %               ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!
 %               : '';
+%  my $events = '';
+%  if ( $cust_bill->num_cust_event
+%       && (    $curuser->access_right('Billing event reports')
+%            || $curuser->access_right('View customer billing events')
+%          )
+%     ) {
+%    $events =
+%      qq!<BR><FONT SIZE="-1"><A HREF="${p}search/cust_event.html?invnum=!.
+%      $cust_bill->invnum. '">(&nbsp;View invoice events&nbsp;)</A></FONT>';
+%  }
 %  push @history, {
 %    'date'   => $cust_bill->_date,
 %    'desc'   => $link. $pre.
 %                "Invoice #$invnum (Balance \$". $cust_bill->owed. ')'.
-%                $post. ( $link ? '</A>' : '' ),
+%                $post. ( $link ? '</A>' : '' ). $events,
 %    'charge' => $cust_bill->charged,
 %  };
 %}
 %    #completely unapplied
 %    $pre = '<B><FONT COLOR="#FF0000">Unapplied ';
 %    $post = '</FONT></B>';
-%    $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!.
-%             $cust_pay->paynum.
-%             qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
-%
+%    if ( $curuser->access_right('Apply payment') ) {
+%      $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!.
+%               $cust_pay->paynum.
+%               qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
+%    }
 %  } elsif (    scalar(@cust_bill_pay)   == 1
 %            && scalar(@cust_pay_refund) == 0
 %            && $cust_pay->unapplied == 0     ) {
 %    if ( $cust_pay->unapplied > 0 ) {
 %      $desc .= '&nbsp;&nbsp;'.
 %               '<B><FONT COLOR="#FF0000">$'.
-%               $cust_pay->unapplied. ' unapplied</FONT></B>'.
-%               qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!.
-%               $cust_pay->paynum. 
-%               qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!.
-%               '<BR>';
+%               $cust_pay->unapplied. ' unapplied</FONT></B>';
+%      if ( $curuser->access_right('Apply payment') ) {
+%        $desc .= qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_bill_pay.cgi?!.
+%                 $cust_pay->paynum. 
+%                 qq!', 392, 336, 'cust_bill_pay_popup' ), CAPTION, 'Apply payment', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
+%      }
+%      $desc .= '<BR>';
 %    }
 %  }
 %
+%  my $view = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}view/cust_pay.html?link=popup;paynum=!.
+%             $cust_pay->paynum.
+%             qq!', 540, 336, 'view_cust_pay_popup' ), CAPTION, 'Payment Receipt', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">view receipt</A>)!;
+%
 %  my $refund = '';
 %  my $refund_days = $conf->config('card_refund-days') || 120;
 %  if (    $cust_pay->closed !~ /^Y/i
 %  push @history, {
 %    'date'    => $cust_pay->_date,
 %    'desc'    => $pre. "Payment$post$info$desc".
-%                 "$apply$refund$void$delete$unapply",
+%                 "$view$apply$refund$void$delete$unapply",
 %    'payment' => $cust_pay->paid,
 %    'target'  => $target,
 %  };
 %    #completely unapplied
 %    $pre = '<B><FONT COLOR="#FF0000">Unapplied ';
 %    $post = '</FONT></B>';
-%    $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!.
-%             $cust_credit->crednum.
-%             qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
+%    if ( $curuser->access_right('Apply credit') ) {
+%      $apply = qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!.
+%               $cust_credit->crednum.
+%               qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
+%    }
 %  } elsif (    scalar(@cust_credit_bill)   == 1
 %            && scalar(@cust_credit_refund) == 0
 %            && $cust_credit->credited == 0      ) {
 %    }
 %    if ( $cust_credit->credited > 0 ) {
 %      $desc .= '&nbsp;&nbsp;<B><FONT COLOR="#FF0000">$'.
-%               $cust_credit->credited. ' unapplied</FONT></B>'.
-%               qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!.
-%               $cust_credit->crednum.
-%               qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!.
-%               '<BR>';
+%               $cust_credit->credited. ' unapplied</FONT></B>';
+%      if ( $curuser->access_right('Apply credit') ) {
+%        $desc .= qq! (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}edit/cust_credit_bill.cgi?!.
+%                 $cust_credit->crednum.
+%                 qq!', 392, 336, 'cust_credit_bill_popup' ), CAPTION, 'Apply credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">apply</A>)!;
+%      }
+%      $desc .= '<BR>';
 %    }
 %  }
 %#
 %  $payby =~ s/^CHEK$/Electronic check /;
 %  $payby =~ s/^(CARD|COMP)$/$1 /;
 %
+%  my $delete = '';
+%  if ( $cust_refund->closed !~ /^Y/i
+%       && $conf->exists('deleterefunds')
+%       && $curuser->access_right('Delete refund')
+%     )
+%  {
+%    $delete = qq! (<A HREF="javascript:areyousure('!.
+%              qq!${p}misc/delete-cust_refund.cgi?!. $cust_refund->refundnum.
+%              qq!', 'Are you sure you want to delete this refund?')"!.
+%              qq! TITLE="Delete this refund from the database completely - not recommended"!.
+%              qq!>delete</A>)!;
+%  }
+%
 %  push @history, {
 %    'date'   => $cust_refund->_date,
-%    'desc'   => "Refund ($payby$payinfo) by ". $cust_refund->otaker,
+%    'desc'   => "Refund ($payby$payinfo) by ". $cust_refund->otaker. "<BR>".
+%                $delete,
 %    'refund' => $cust_refund->refund,
 %  };
 %
@@ -570,4 +616,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>