first part of ACL and re-skinning work and some other small stuff
[freeside.git] / httemplate / view / cust_main / payment_history.html
index f794ccf..f0cd993 100644 (file)
@@ -4,10 +4,10 @@
 
   my $conf = new FS::Conf;
 
-  my @payby = $conf->config('payby');
+  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 grep /\w/, @payby;
+    unless @payby;
   my %payby = map { $_=>1 } @payby;
 
   my $s = 0;
 
 <% } %>
 
-<BR><A HREF="<%= $p %>edit/cust_credit.cgi?<%= $custnum %>">Post credit</A>
+<BR>
+
+<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 )">Post credit</A>
+
 <BR>
 
 <%
@@ -115,8 +118,10 @@ foreach my $cust_pay ($cust_main->cust_pay) {
     #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_credit_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK )">apply</A>)!;
+
   } elsif (    scalar(@cust_bill_pay)   == 1
             && scalar(@cust_pay_refund) == 0
             && $cust_pay->unapplied == 0     ) {
@@ -151,8 +156,9 @@ foreach my $cust_pay ($cust_main->cust_pay) {
       $desc .= '&nbsp;&nbsp;'.
                '<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_credit_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK )">apply</A>)!.
                '<BR>';
     }
   }
@@ -229,11 +235,24 @@ foreach my $cust_pay_void ($cust_main->cust_pay_void) {
   $payby =~ s/^(CARD|COMP)$/$1 /;
   my $info = $payby ? " ($payby$payinfo)" : '';
 
+  my $unvoid = '';
+  if ( $cust_pay_void->closed !~ /^Y/i && $conf->exists('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,
   };
 
@@ -251,8 +270,9 @@ foreach my $cust_credit ($cust_main->cust_credit) {
     #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_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK )">apply</A>)!;
   } elsif (    scalar(@cust_credit_bill)   == 1
             && scalar(@cust_credit_refund) == 0
             && $cust_credit->credited == 0      ) {
@@ -286,8 +306,9 @@ foreach my $cust_credit ($cust_main->cust_credit) {
     if ( $cust_credit->credited > 0 ) {
       $desc .= '&nbsp;&nbsp;<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_popup' ), CAPTION, 'Post credit', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK )">apply</A>)!.
                '<BR>';
     }
   }
@@ -313,7 +334,10 @@ foreach my $cust_credit ($cust_main->cust_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,
   };
@@ -342,7 +366,7 @@ foreach my $cust_refund ($cust_main->cust_refund) {
 
 %>
 
-<%= table() %>
+<%= include("/elements/table.html") %>
 <TR>
   <TH>Date</TH>
   <TH>Description</TH>