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