merge
[freeside.git] / httemplate / search / cust_pay_pending.html
1 <& elements/cust_pay_or_refund.html,
2                 'thing'         => 'pay_pending',
3                 'amount_field'  => 'paid',
4                 'name_singular' => 'pending payment',
5                 'name_verb'     => 'pending',
6                 'disable_link'  => 1,
7                 'disable_by'    => 1, #add otaker to cust_pay_pending?
8                 'addl_header'   => [ 'Time', 'Payment Status', ],
9                 'addl_fields'   => [ sub { time2str('%r', shift->_date ) },
10                                      $status_sub,
11                                    ],
12                 'redirect_empty' => $redirect_empty,
13 &>
14 <%init>
15
16 my %statusaction = (
17   'new'        => 'delete',
18   'pending'    => 'complete',
19   #'authorized' => '',
20   'captured'   => 'capture',
21   #'declined'   => '',
22   #wouldn't need to take action on a done state#'done'
23 );
24
25 my $edit_pending =
26   $FS::CurrentUser::CurrentUser->access_right('Edit customer pending payments');
27
28 my $status_sub = sub {
29   my $pending = shift;
30   my $return = $pending->status;
31   if ( $pending->failure_status ) {
32     $return = $pending->display_status;
33   }
34   my $action = $statusaction{$pending->status};
35   return $return unless $action && $edit_pending;
36   my $link = include('/elements/popup_link.html',
37                        'action' => $p. 'edit/cust_pay_pending.html'.
38                                      '?paypendingnum='. $pending->paypendingnum.
39                                      ";action=$action",
40                        'label'  => $action,
41                        'color'  => '#ff0000',
42                        'width'  => 655,
43                        'height' => ( $action eq 'delete' ? 480 : 575 ),
44                        'actionlabel' => ucfirst($action). ' pending payment',
45                     );
46   $return. qq! <FONT SIZE="-1">($link)</FONT>!;
47 };
48
49 my $redirect_empty = sub {
50   my $cgi = shift;
51   if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
52     $p. "view/cust_main.cgi?$1";
53   } else {
54     '';
55   }
56 };
57
58 </%init>