summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/credit-cust_bill_pkg.html
blob: 8b2f3f3eaead0f2ed9a40f5eb138d5f7698197b8 (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
%if ($error) {
%  errorpage_popup($error); #XXX redirect back for correction...
%} else {
<& /elements/header-popup.html, 'Credit successful' &>
  <SCRIPT TYPE="text/javascript">
    window.top.location.reload();
  </SCRIPT>
  </BODY></HTML>
% }
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Post credit');

my @billpkgnum_setuprecurs =
  map { $_ =~ /^billpkgnum(\d+\-\w*)$/ or die 'gm#23'; $1; } 
  grep { $_ =~ /^billpkgnum\d+\-\w*$/ && $cgi->param($_) } $cgi->param;

my @billpkgnums = ();
my @setuprecurs = ();
my @amounts = ();
foreach my $billpkgnum_setuprecur (@billpkgnum_setuprecurs) {
  my $amount = $cgi->param("billpkgnum$billpkgnum_setuprecur");
  my( $billpkgnum, $setuprecur ) = split('-', $billpkgnum_setuprecur);
  push @billpkgnums, $billpkgnum;
  push @setuprecurs, $setuprecur;
  push @amounts,     $amount;
}

my $error = FS::cust_credit->credit_lineitems(
  #the lineitems to credit
  'billpkgnums'       => \@billpkgnums,
  'setuprecurs'       => \@setuprecurs,
  'amounts'           => \@amounts,

  #the credit
  'newreasonnum'      => scalar($cgi->param('newreasonnum')),
  'newreasonnum_type' => scalar($cgi->param('newreasonnumT')),
  map { $_ => scalar($cgi->param($_)) }
    #fields('cust_credit')  
    qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum
);

</%init>