summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/prepay_credit.cgi41
-rw-r--r--httemplate/edit/process/prepay_credit.cgi8
-rwxr-xr-xhttemplate/misc/process/recharge_svc.html46
-rwxr-xr-xhttemplate/misc/recharge_svc.html48
-rw-r--r--httemplate/search/prepay_credit.html11
-rwxr-xr-xhttemplate/view/cust_main/packages.html34
6 files changed, 174 insertions, 14 deletions
diff --git a/httemplate/edit/prepay_credit.cgi b/httemplate/edit/prepay_credit.cgi
index f563e253b..7ce44c087 100644
--- a/httemplate/edit/prepay_credit.cgi
+++ b/httemplate/edit/prepay_credit.cgi
@@ -11,7 +11,16 @@
% 3600 => 'hours',
%;
%
-%$cgi->param('multiplier', '60') unless $cgi->param('multiplier');
+%tie my %bytemultiplier, 'Tie::IxHash',
+% 1 => 'bytes',
+% 1000 => 'Kbytes',
+% 1000000 => 'Mbytes',
+% 1000000000 => 'Gbytes',
+%;
+%
+%$cgi->param('multiplier', '60') unless $cgi->param('multiplier');
+%$cgi->param('upmultiplier', '1000000') unless $cgi->param('upmultiplier');
+%$cgi->param('downmultiplier', '1000000') unless $cgi->param('downmultiplier');
%
%
@@ -46,9 +55,11 @@ Generate
</SELECT>
-<BR>Value:
+<TABLE>
+<TR><TD>Value:
$<INPUT TYPE="text" NAME="amount" SIZE=8 MAXLENGTH=7 VALUE="<% $cgi->param('amount') %>">
-and/or
+</TD>
+<TD>and/or
<INPUT TYPE="text" NAME="seconds" SIZE=6 MAXLENGTH=5 VALUE="<% $cgi->param('seconds') %>">
<SELECT NAME="multiplier">
% foreach my $multiplier ( keys %multiplier ) {
@@ -57,6 +68,30 @@ and/or
% }
</SELECT>
+</TD></TR>
+<TR><TD></TD>
+<TD>and/or
+<INPUT TYPE="text" NAME="upbytes" SIZE=6 MAXLENGTH=5 VALUE="<% $cgi->param('upbytes') %>">
+<SELECT NAME="upmultiplier">
+% foreach my $multiplier ( keys %bytemultiplier ) {
+
+ <OPTION VALUE="<% $multiplier %>"<% $cgi->param('upmultiplier') eq $multiplier ? ' SELECTED' : '' %>><% $bytemultiplier{$multiplier} %>
+% }
+
+</SELECT> upload
+</TD></TR>
+<TR><TD></TD>
+<TD>and/or
+<INPUT TYPE="text" NAME="downbytes" SIZE=6 MAXLENGTH=5 VALUE="<% $cgi->param('downbytes') %>">
+<SELECT NAME="downmultiplier">
+% foreach my $multiplier ( keys %bytemultiplier ) {
+
+ <OPTION VALUE="<% $multiplier %>"<% $cgi->param('downmultiplier') eq $multiplier ? ' SELECTED' : '' %>><% $bytemultiplier{$multiplier} %>
+% }
+
+</SELECT> download
+</TD></TR>
+</TABLE>
<BR><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Generate" onSubmit="this.disabled = true">
diff --git a/httemplate/edit/process/prepay_credit.cgi b/httemplate/edit/process/prepay_credit.cgi
index fb15fd8e4..ba4296900 100644
--- a/httemplate/edit/process/prepay_credit.cgi
+++ b/httemplate/edit/process/prepay_credit.cgi
@@ -15,8 +15,10 @@
% $error = 'Illegal number of prepaid cards: '. $cgi->param('num');
%}
%
-%$hashref->{amount} = $cgi->param('amount');
-%$hashref->{seconds} = $cgi->param('seconds') * $cgi->param('multiplier');
+%$hashref->{amount} = $cgi->param('amount');
+%$hashref->{seconds} = $cgi->param('seconds') * $cgi->param('multiplier');
+%$hashref->{upbytes} = $cgi->param('upbytes') * $cgi->param('upmultiplier');
+%$hashref->{downbytes} = $cgi->param('downbytes') * $cgi->param('downmultiplier');
%
%$error ||= FS::prepay_credit::generate( $num,
% scalar($cgi->param('type')),
@@ -46,6 +48,8 @@
<% $hashref->{amount} ? sprintf('$%.2f', $hashref->{amount} ) : '' %>
<% $hashref->{amount} && $hashref->{seconds} ? 'and' : '' %>
<% $hashref->{seconds} ? duration_exact($hashref->{seconds}) : '' %>
+ <% $hashref->{upbytes} ? FS::UI::Web::bytecount_unexact($hashref->{upbytes}) : '' %>
+ <% $hashref->{downbytes} ? FS::UI::Web::bytecount_unexact($hashref->{downbytes}) : '' %>
<br>
% }
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>
+
diff --git a/httemplate/search/prepay_credit.html b/httemplate/search/prepay_credit.html
index dff8a3d9a..fecb12f2a 100644
--- a/httemplate/search/prepay_credit.html
+++ b/httemplate/search/prepay_credit.html
@@ -9,7 +9,6 @@
%my $count_query = 'SELECT COUNT(*) FROM prepay_credit';
%$count_query .= ' WHERE agentnum = '. $agent->agentnum if $agent;
%
-%
<% include( 'elements/search.html',
'title' => 'Unused Prepaid Cards'.
($agent ? ' for '. $agent->agent : ''),
@@ -23,11 +22,17 @@
},
'count_query' => $count_query,
#'redirect' => $link,
- 'header' => [ '#', qw(Amount Time Agent) ],
+ 'header' => [ '#', qw(Amount Time Upload Download Agent) ],
'fields' => [
'identifier',
sub { sprintf('$%.2f', shift->amount ) },
sub { my $c = shift; $c ? duration_exact($c->seconds) : '' },
+ sub { my $c = shift;
+ $c ? FS::UI::Web::bytecount_unexact($c->upbytes) : ''
+ },
+ sub { my $c = shift;
+ $c ? FS::UI::Web::bytecount_unexact($c->downbytes) : ''
+ },
sub { my $agent = shift->agent;
$agent ? $agent->agent : '';
},
@@ -36,6 +41,8 @@
'',
'',
'',
+ '',
+ '',
sub { my $agent = shift->agent;
$agent ? [ "${p}view/agent.cgi?", 'agentnum' ] : '';
},
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html
index f93a0764b..0a386f265 100755
--- a/httemplate/view/cust_main/packages.html
+++ b/httemplate/view/cust_main/packages.html
@@ -343,17 +343,31 @@ Current packages
% foreach my $service (@{$svcpart->{services}}) {
<TR>
- <TD ALIGN="right" VALIGN="top" ROWSPAN=2><%svc_link($svcpart,$service)%></TD>
+ <TD ALIGN="right" VALIGN="top"><%svc_link($svcpart,$service)%></TD>
<TD STYLE="padding-bottom:0px"><B><%svc_label_link($svcpart,$service)%></B></TD>
</TR>
-% if ( $curuser->access_right('Unprovision customer service') ) {
-
<TR>
- <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">(&nbsp;<%svc_unprovision_link($service)%>&nbsp;)</FONT></TD>
- </TR>
+ <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
-% }
+% if ( $curuser->access_right('Recharge customer service')
+% && ($svcpart->{'svcdb'} eq 'svc_acct')
+% && ($service->{seconds} ne ''
+% || $service->{upbytes} ne ''
+% || $service->{downbytes} ne ''
+% || $service->{totalbytes} ne '' )
+% ) {
+ (&nbsp;<%svc_recharge_link($service)%>&nbsp;)
+% }
+ </FONT></TD>
+
+ <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2">
+
+% if ( $curuser->access_right('Unprovision customer service') ) {
+ (&nbsp;<%svc_unprovision_link($service)%>&nbsp;)
+% }
+ </FONT></TD>
+ </TR>
% }
% if ( ! $pkg->{'cancel'}
@@ -371,7 +385,6 @@ Current packages
% }
-
</TABLE>
</TD>
% } #end display packages
@@ -440,6 +453,7 @@ Current packages
% my $svc = {
% 'svcnum' => $cust_svc->svcnum,
% 'label' => ($cust_svc->label)[1],
+% $cust_svc->svc_x->hash,
% };
%
% #false laziness with above, to catch extraneous services. whole
@@ -516,6 +530,12 @@ Current packages
% qq!'Permanently unprovision and delete this service?')">Unprovision</A>!;
%}
%
+%sub svc_recharge_link {
+% my $svc = shift or return '';
+%
+% qq!<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('${p}misc/recharge_svc.html?svcnum=$svc->{svcnum}', 392, 336, 'recharge_svc_popup' ), CAPTION, 'Recharge service $svc->{svcnum}', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;">Recharge</A>!;
+%}
+%
%# This should be generalized to use config options to determine order.
%sub pkgsort_pkgnum_cancel {
% if ($a->{cancel} and $b->{cancel}) {