RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / cust_pay_pending.html
1 <% include('/elements/header-popup.html', $title ) %>
2 % if ( $error ) {
3   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error |h %></FONT>
4 % } else {
5     <SCRIPT TYPE="text/javascript">
6       topreload();
7     </SCRIPT>
8 % }
9 </BODY>
10 </HTML>
11 <%init>
12
13 my $curuser = $FS::CurrentUser::CurrentUser;
14
15 die "access denied"
16   unless $curuser->access_right('Edit customer pending payments');
17
18 $cgi->param('action') =~ /^(\w+)$/ or die 'illegal action';
19 my $action = $1;
20
21 $cgi->param('paypendingnum') =~ /^(\d+)$/ or die 'illegal paypendingnum';
22 my $paypendingnum = $1;
23 my $cust_pay_pending =
24   qsearchs({
25     'select'    => 'cust_pay_pending.*',
26     'table'     => 'cust_pay_pending',
27     'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
28     'hashref'   => { 'paypendingnum' => $paypendingnum },
29     'extra_sql' => ' AND '. $curuser->agentnums_sql,
30   })
31   or die 'unknown paypendingnum';
32
33 my $error;
34 my $title;
35 if ( $action eq 'delete' ) {
36
37   $error = $cust_pay_pending->delete;
38   if ( $error ) {
39     $title = 'Error deleting pending payment';
40   } else {
41     $title = 'Pending payment deletion successful';
42   }
43
44 } elsif ( $action eq 'insert_cust_pay' ) { 
45
46   $error = $cust_pay_pending->insert_cust_pay;
47   if ( $error ) {
48     $title = 'Error completing pending payment';
49   } else {
50     $title = 'Pending payment completed';
51   }
52
53 } elsif ( $action eq 'decline' ) {
54
55   $error = $cust_pay_pending->decline;
56   if ( $error ) {
57     $title = 'Error declining pending payment';
58   } else {
59     $title = 'Pending payment completed (decline)';
60   }
61
62 } elsif ( $action eq 'reverse' ) {
63
64   $error = $cust_pay_pending->reverse;
65   if ( $error ) {
66     $title = 'Error reversing pending payment';
67   } else {
68     $title = 'Pending payment completed (reverse)';
69   }
70
71 } else {
72
73   die "unknown action $action";
74
75 }
76
77 </%init>