summaryrefslogtreecommitdiff
path: root/httemplate/misc/process/recharge_svc.html
blob: d9fa2070e76f5dc9aeb870c55466271c17f5b311 (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
%
%
%#untaint svcnum
%my $svcnum = $cgi->param('svcnum');
%$svcnum =~ /^(\d+)$/ || die "Illegal svcnum";
%$svcnum = $1;
%
%#untaint prepaid
%my $prepaid = $cgi->param('prepaid');
%$prepaid =~ /^(\w*)$/;
%$prepaid = $1;
%
%my $error = '';
%my $svc_acct = qsearchs( 'svc_acct', {'svcnum'=>$svcnum} );
%$error = "Can't recharge service $svcnum. " unless $svc_acct;
%
%my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main;
%
%my $oldAutoCommit = $FS::UID::AutoCommit;
%local $FS::UID::AutoCommit = 0;
%my $dbh = dbh;
%
%
%unless ($error) {
%
%my ($amount, $seconds, $up, $down, $total) = (0, 0, 0, 0, 0);
%$error = $cust_main->get_prepay($prepaid, \$amount, \$seconds, \$up, \$down, \$total)
%      || $svc_acct->increment_seconds($seconds)
%      || $svc_acct->increment_upbytes($up)
%      || $svc_acct->increment_downbytes($down)
%      || $svc_acct->increment_totalbytes($total)
%      || $cust_main->insert_cust_pay_prepay( $amount, $prepaid );
%}
%
%if ($error) {
%  $cgi->param('error', $error);
%  $dbh->rollback if $oldAutoCommit;
%  print $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string );
%}
%
<% header("Package recharged") %>
  <SCRIPT TYPE="text/javascript">
    window.top.location.reload();
  </SCRIPT>
  </BODY></HTML>