diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/process/recharge_svc.html | 46 | ||||
-rwxr-xr-x | httemplate/misc/recharge_svc.html | 48 |
2 files changed, 94 insertions, 0 deletions
diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html new file mode 100755 index 000000000..ae526689e --- /dev/null +++ b/httemplate/misc/process/recharge_svc.html @@ -0,0 +1,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) = (0, 0, 0, 0); +%$error = $cust_main->get_prepay($prepaid, \$amount, \$seconds, \$up, \$down) +% || $svc_acct->increment_seconds($seconds) +% || $svc_acct->increment_upbytes($up) +% || $svc_acct->increment_downbytes($down) +% || $svc_acct->increment_totalbytes($up + $down) +% || $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> + diff --git a/httemplate/misc/recharge_svc.html b/httemplate/misc/recharge_svc.html new file mode 100755 index 000000000..61f738455 --- /dev/null +++ b/httemplate/misc/recharge_svc.html @@ -0,0 +1,48 @@ +<% include('/elements/header-popup.html', 'Recharge Service' ) %> + +% if ( $cgi->param('error') ) { + <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT> + <BR><BR> +% } + +<FORM NAME="recharge_popup" ACTION="<% popurl(1) %>process/recharge_svc.html" METHOD=POST> +<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>"> + +<BR><BR> +<% "Recharge $svcnum: $label - $value" %> +<% ntable("#cccccc", 2) %> + +<TR> + <TD>Enter prepaid card: </TD> + <TD><INPUT TYPE="text" NAME="prepaid" VALUE="<% $prepaid %>"></TD> +</TR> + +</TABLE> + +<BR> +<INPUT TYPE="submit" NAME="submit" VALUE="Recharge"> + +</FORM> +</BODY> +</HTML> + +<%init> +my($svcnum, $cust_svc, $label, $value, $prepaid); +if ( $cgi->param('error') ) { + $svcnum = $cgi->param('svcnum'); + $prepaid = $cgi->param('prepaid'); +} elsif ( $cgi->param('svcnum') =~ /^(\d+)$/ ) { + $svcnum = $1; +} else { + die "illegal query ". $cgi->keywords; +} + +my $title = 'Recharge Service'; + +$cust_svc = qsearchs('cust_svc', {'svcnum' => $svcnum}); +die "No such service: $svcnum" unless $cust_svc; + +($label, $value) = $cust_svc->label; + +</%init> + |