summaryrefslogtreecommitdiff
path: root/httemplate/search/cust_pay_pending.html
blob: 8b73508535c964cef60c256b98574b57ea561a1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<% include( 'elements/cust_pay_or_refund.html',
                'thing'         => 'pay_pending',
                'amount_field'  => 'paid',
                'name_singular' => 'pending payment',
                'name_verb'     => 'pending',
                'disable_link'  => 1,
                'disable_by'    => 1, #add otaker to cust_pay_pending?
                'html_init'     => include('/elements/init_overlib.html'),
                'addl_header'   => [ 'Time', 'Payment Status', ],
                'addl_fields'   => [ sub { time2str('%r', shift->_date ) },
                                     $status_sub,
                                   ],
                'redirect_empty' => $redirect_empty,
          )
%>
<%init>

my %statusaction = (
  'new'        => 'delete',
  'pending'    => 'complete',
  #'authorized' => '',
  'captured'   => 'capture',
  #'declined'   => '',
  #wouldn't need to take action on a done state#'done'
);

my $edit_pending =
  $FS::CurrentUser::CurrentUser->access_right('Edit customer pending payments');

my $status_sub = sub {
  my $pending = shift;
  my $return = $pending->status;
  my $action = $statusaction{$pending->status};
  return $return unless $action && $edit_pending;
  my $link = include('/elements/popup_link.html',
                       'action' => $p. 'edit/cust_pay_pending.html'.
                                     '?paypendingnum='. $pending->paypendingnum.
                                     ";action=$action",
                       'label'  => $action,
                       'color'  => '#ff0000',
                       'width'  => 655,
                       'height' => ( $action eq 'delete' ? 480 : 575 ),
                       'actionlabel' => ucfirst($action). ' pending payment',
                    );
  $return. qq! <FONT SIZE="-1">($link)</FONT>!;
};

my $redirect_empty = sub {
  my $cgi = shift;
  if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
    $p. "view/cust_main.cgi?$1";
  } else {
    '';
  }
};

</%init>