<%
my( $cust_main ) = @_;
- my $conf = new FS::Conf;
my $custnum = $cust_main->custnum;
+
+ my $conf = new FS::Conf;
+
+ my $curuser = $FS::CurrentUser::CurrentUser;
+
+ my @payby = grep /\w/, $conf->config('payby');
+ #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
+ @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+ unless @payby;
+ my %payby = map { $_=>1 } @payby;
+
+ my $s = 0;
+
%>
<BR><BR><A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
-<A HREF="<%= $p %>edit/cust_pay.cgi?custnum=<%= $custnum %>">Post cash/check payment</A>
-| <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A>
-| <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A>
-<BR><A HREF="<%= $p %>edit/cust_credit.cgi?<%= $custnum %>">Post credit</A>
+
+<% if ( $payby{'BILL'} && $curuser->access_right('Post payment') ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=BILL;custnum=<%= $custnum %>">Post check payment</A>
+
+<% } %>
+
+<% if ( $payby{'CASH'} && $curuser->access_right('Post payment') ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=CASH;custnum=<%= $custnum %>">Post cash payment</A>
+
+<% } %>
+
+<% if ( $payby{'WEST'} && $curuser->access_right('Post payment') ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=WEST;custnum=<%= $custnum %>">Post Western Union payment</A>
+
+<% } %>
+
+<% if ( ( $payby{'CARD'} || $payby{'DCRD'} )
+ && $curuser->access_right('Process payment')
+ ) {
+%>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>misc/payment.cgi?payby=CARD;custnum=<%= $custnum %>">Process credit card payment</A>
+
+<% } %>
+
+<% if ( ( $payby{'CHEK'} || $payby{'DCHK'} )
+ && $curuser->access_right('Process payment')
+ ) {
+%>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>misc/payment.cgi?payby=CHEK;custnum=<%= $custnum %>">Process electronic check (ACH) payment</A>
+
+<% } %>
+
+<% if ( $payby{'MCRD'} && $curuser->access_right('Post payment') ) { %>
+
+ <%= $s++ ? ' | ' : '' %>
+ <A HREF="<%= $p %>edit/cust_pay.cgi?payby=MCRD;custnum=<%= $custnum %>">Post manual credit card payment</A>
+
+<% } %>
+
<BR>
+<% if ( $curuser->access_right('Post credit') ) { %>
+
+ <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<%= $p %>edit/cust_credit.cgi?<%= $custnum %>', 392, 336, 'cust_credit_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Post credit</A>
+
+ <BR>
+
+<% } %>
+
<%
#get payment history
my @history = ();
: '';
my $post = ( $cust_bill->owed > 0 ) ? '</FONT></B>' : '';
my $invnum = $cust_bill->invnum;
+ my $link = $curuser->access_right('View invoices')
+ ? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!
+ : '';
push @history, {
'date' => $cust_bill->_date,
- 'desc' => qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!. $pre.
+ 'desc' => $link. $pre.
"Invoice #$invnum (Balance \$". $cust_bill->owed. ')'.
- $post. '</A>',
+ $post. ( $link ? '</A>' : '' ),
'charge' => $cust_bill->charged,
};
}
$payby =~ s/^BILL$/Check #/ if $payinfo;
$payby =~ s/^CHEK$/Electronic check /;
$payby =~ s/^PREP$/Prepaid card /;
+ $payby =~ s/^CARD$/Credit card #/;
+ $payby =~ s/^COMP$/Complimentary by /;
+ $payby =~ s/^CASH$/Cash/;
+ $payby =~ s/^WEST$/Western Union/;
+ $payby =~ s/^MCRD$/Manual credit card/;
$payby =~ s/^BILL$//;
- $payby =~ s/^(CARD|COMP)$/$1 /;
my $info = $payby ? " ($payby$payinfo)" : '';
my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' );
#completely unapplied
$pre = '<B><FONT COLOR="#FF0000">Unapplied ';
$post = '</FONT></B>';
- $apply = qq! (<A HREF="${p}edit/cust_bill_pay.cgi?!.
- $cust_pay->paynum. '">apply</A>)';
+ $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 ) {
} elsif ( $app->isa('FS::cust_pay_refund') ) {
$desc .= ' '.
'$'. $app->amount.
- ' refunded on'. time2str("%D", $app->_date).
+ ' refunded on '. time2str("%D", $app->_date).
'<BR>';
} else {
die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund";
$desc .= ' '.
'<B><FONT COLOR="#FF0000">$'.
$cust_pay->unapplied. ' unapplied</FONT></B>'.
- qq! (<A HREF="${p}edit/cust_bill_pay.cgi?!.
- $cust_pay->paynum. '">apply</A>)'.
+ 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->payby =~ /^(CARD|CHEK)$/
&& time-$cust_pay->_date < $refund_days*86400
&& $cust_pay->unrefunded > 0
+ && $curuser->access_right('Refund payment')
) {
$refund = qq! (<A HREF="${p}edit/cust_refund.cgi?payby=$1;!.
qq!paynum=!. $cust_pay->paynum. '"'.
my $void = '';
if ( $cust_pay->closed !~ /^Y/i
- && $cust_pay->payby ne 'CARD'
- && ( $cust_pay->payby ne 'CHEK' || $conf->exists('echeck-void') )
- ) {
+ && ( ( $cust_pay->payby eq 'CARD'
+ && $curuser->access_right('Credit card void')
+ )
+ || ( $cust_pay->payby eq 'CHEK'
+ && $curuser->access_right('Echeck void')
+ )
+ || ( $cust_pay->payby !~ /^(CARD|CHEK)$/
+ && $curuser->access_right('Regular void')
+ )
+ )
+ )
+ {
$void = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum.
qq!', 'Are you sure you want to void this payment?')"!.
qq! TITLE="Void this payment from the database!.
- ( $cust_pay->payby eq 'CHEK'
+ ( $cust_pay->payby =~ /^(CARD|CHEK)$/
? ' (do not send anything to the payment gateway)'
: ''
). '"'.
}
my $delete = '';
- if ( $cust_pay->closed !~ /^Y/i && $conf->exists('deletepayments') ) {
+ if ( $cust_pay->closed !~ /^Y/i
+ && $conf->exists('deletepayments')
+ && $curuser->access_right('Delete payment')
+ )
+ {
$delete = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/delete-cust_pay.cgi?!. $cust_pay->paynum.
qq!', 'Are you sure you want to delete this payment?')"!.
my $unapply = '';
if ( $cust_pay->closed !~ /^Y/i
- && $conf->exists('unapplypayments')
- && scalar(@cust_bill_pay) ) {
+ && scalar(@cust_bill_pay)
+ && $curuser->access_right('Unapply payment')
+ )
+ {
$unapply = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/unapply-cust_pay.cgi?!. $cust_pay->paynum.
qq!', 'Are you sure you want to unapply this payment?')"!.
$payby =~ s/^(CARD|COMP)$/$1 /;
my $info = $payby ? " ($payby$payinfo)" : '';
+ my $unvoid = '';
+ if ( $cust_pay_void->closed !~ /^Y/i
+ && $curuser->access_right('Unvoid')
+ )
+ {
+ $unvoid = qq! (<A HREF="javascript:areyousure('!.
+ qq!${p}misc/unvoid-cust_pay_void.cgi?!. $cust_pay_void->paynum.
+ qq!', 'Are you sure you want to unvoid this payment?')"!.
+ qq! TITLE="Unvoid this payment from the database!.
+ ( $cust_pay_void->payby =~ /^(CARD|CHEK)$/
+ ? ' (do not send anything to the payment gateway)'
+ : ''
+ ). '"'.
+ qq!>unvoid</A>)!;
+ }
+
push @history, {
'date' => $cust_pay_void->_date,
'desc' => "<DEL>Payment $info</DEL> <I>voided ".
time2str("%D", $cust_pay_void->void_date).
- " by ". $cust_pay_void->otaker. '</i>',
+ " by ". $cust_pay_void->otaker. '</i>'. $unvoid,
'void_payment' => $cust_pay_void->paid,
};
#completely unapplied
$pre = '<B><FONT COLOR="#FF0000">Unapplied ';
$post = '</FONT></B>';
- $apply = qq! (<A HREF="${p}edit/cust_credit_bill.cgi?!.
- $cust_credit->crednum. '">apply</A>)';
+ $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 ) {
} elsif ( $app->isa('FS::cust_credit_refund') ) {
$desc .= ' '.
'$'. $app->amount.
- ' refunded on'. time2str("%D", $app->_date).
+ ' refunded on '. time2str("%D", $app->_date).
'<BR>';
} else {
die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund";
if ( $cust_credit->credited > 0 ) {
$desc .= ' <B><FONT COLOR="#FF0000">$'.
$cust_credit->credited. ' unapplied</FONT></B>'.
- qq! (<A HREF="${p}edit/cust_credit_bill.cgi?!.
- $cust_credit->crednum. '">apply</A>)'.
+ 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>';
}
}
#
my $delete = '';
- if ( $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') ) {
+ if ( $cust_credit->closed !~ /^Y/i
+
+ #s'pose deleting a credit isn't bad like deleting a payment
+ # and this needs to be generally available until we have credit voiding..
+ #&& $conf->exists('deletecredits')
+
+ && $curuser->access_right('Delete credit')
+ )
+ {
$delete = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/delete-cust_credit.cgi?!. $cust_credit->crednum.
qq!', 'Are you sure you want to delete this credit?')">!.
my $unapply = '';
if ( $cust_credit->closed !~ /^Y/i
- && $conf->exists('unapplycredits')
- && scalar(@cust_credit_bill) ) {
+ && scalar(@cust_credit_bill)
+ && $curuser->access_right('Unapply credit')
+ )
+ {
$unapply = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/unapply-cust_credit.cgi?!. $cust_credit->crednum.
qq!', 'Are you sure you want to unapply this credit?')">!.
push @history, {
'date' => $cust_credit->_date,
'desc' => $pre. "Credit$post by ". $cust_credit->otaker.
- ' ('. $cust_credit->reason. ')'.
+ ( $cust_credit->reason
+ ? ' ('. $cust_credit->reason. ')'
+ : ''
+ ).
"$desc$apply$delete$unapply",
'credit' => $cust_credit->amount,
};
%>
-<%= table() %>
+<%= include("/elements/table-grid.html") %>
+
+<% my $bgcolor1 = '#eeeeee';
+ my $bgcolor2 = '#ffffff';
+ my $bgcolor = '';
+%>
+
<TR>
- <TH>Date</TH>
- <TH>Description</TH>
- <TH><FONT SIZE=-1>Charge</FONT></TH>
- <TH><FONT SIZE=-1>Payment</FONT></TH>
- <TH><FONT SIZE=-1>In-house<BR>Credit</FONT></TH>
- <TH><FONT SIZE=-1>Refund</FONT></TH>
- <TH><FONT SIZE=-1>Balance</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Date</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Description</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Charge</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>In-house<BR>Credit</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Refund</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Balance</FONT></TH>
</TR>
<%
my $balance = 0;
foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) {
+ if ( $bgcolor eq $bgcolor1 ) {
+ $bgcolor = $bgcolor2;
+ } else {
+ $bgcolor = $bgcolor1;
+ }
+
my $charge = exists($item->{'charge'})
? sprintf('$%.2f', $item->{'charge'})
: '';
%>
<TR>
- <TD>
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
<% unless ( !$target || $target{$target}++ ) { %>
<A NAME="<%= $target %>">
<% } %>
<% } %>
</FONT>
</TD>
- <TD><%= $item->{'desc'} %></TD>
- <TD ALIGN="right"><%= $charge %></TD>
- <TD ALIGN="right"><%= $payment %></TD>
- <TD ALIGN="right"><%= $credit %></TD>
- <TD ALIGN="right"><%= $refund %></TD>
- <TD ALIGN="right"><%= $showbalance %></TD>
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $item->{'desc'} %>
+ </TD>
+ <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $charge %>
+ </TD>
+ <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $payment %>
+ </TD>
+ <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $credit %>
+ </TD>
+ <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $refund %>
+ </TD>
+ <TD ALIGN="right" CLASS="grid" BGCOLOR="<%= $bgcolor %>">
+ <%= $showbalance %>
+ </TD>
</TR>
<% } %>