6 include('elements/ApplicationCommon.html',
7 'error_redirect' => 'cust_bill_pay.cgi',
8 'src_table' => 'cust_pay',
9 'src_thing' => 'payment',
10 'link_table' => 'cust_bill_pay',
14 include('elements/ApplicationCommon.html',
15 'error_redirect' => 'cust_credit_bill.cgi',
16 'src_table' => 'cust_credit',
17 'src_thing' => 'credit',
18 'link_table' => 'cust_credit_bill',
23 % $cgi->param('error', $error);
24 <% $cgi->redirect(popurl(2). $opt{error_redirect}. '?'. $cgi->query_string ) %>
26 <% header("$src_thing application$to sucessful") %>
27 <SCRIPT TYPE="text/javascript">
28 window.top.location.reload();
37 my $src_thing = ucfirst($opt{'src_thing'});
38 my $src_table = $opt{'src_table'};
39 my $src_pkey = dbdef->table($src_table)->primary_key;
41 my $to = $opt{'link_table'} =~ /refund/ ? ' to Refund' : '';
43 $cgi->param($src_pkey) =~ /^(\d+)$/ or die "Illegal $src_pkey!";
44 my $src_pkeyvalue = $1;
46 my $src = qsearchs($src_table, { $src_pkey => $src_pkeyvalue } )
47 or die "No such $src_pkey: $src_pkeyvalue";
49 my $cust_main = qsearchs('cust_main', { 'custnum' => $src->custnum } )
50 or die "Bogus $src_thing: not attached to customer";
52 my $custnum = $cust_main->custnum;
54 my @subnames = grep { /.+/ } map { /^subnum(\d+)$/ ? $1 : '' } $cgi->param;
55 my @subitems = map { [ $cgi->param("subnum$_"), $cgi->param("subamount$_"), $cgi->param("taxXlocationnum$_") ] }
57 { local $^W = 0; @subitems = grep { $_->[1] + 0 } @subitems; }
60 $options{subitems} = \@subitems if scalar(@subitems);
63 # $new = new FS::cust_refund ( {
64 # 'reason' => 'Refunding payment', #enter reason in UI
65 # 'refund' => $cgi->param('amount'),
67 # #'_date' => $cgi->param('_date'),
68 # 'payinfo' => 'Cash', #enter payinfo in UI
69 # 'paynum' => $paynum,
73 my $class = 'FS::'. $opt{link_table};
77 $_ => scalar($cgi->param($_));
78 } fields($opt{link_table})
85 my $error = $new->insert( %options );