summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/reason.html32
-rw-r--r--httemplate/edit/payment_gateway.html1
-rw-r--r--httemplate/edit/reason.html33
-rwxr-xr-xhttemplate/elements/tr-select-reason.html84
-rw-r--r--httemplate/misc/cacti_graphs.html53
-rw-r--r--httemplate/misc/process/cacti_graphs.cgi6
-rw-r--r--httemplate/misc/process/elements/reason3
-rw-r--r--httemplate/misc/xmlhttp-reason-hint.html83
-rw-r--r--httemplate/view/svc_broadband.cgi14
9 files changed, 235 insertions, 74 deletions
diff --git a/httemplate/browse/reason.html b/httemplate/browse/reason.html
index 5bb6a3e0c..8af88a950 100644
--- a/httemplate/browse/reason.html
+++ b/httemplate/browse/reason.html
@@ -65,7 +65,7 @@ my $align = 'rll';
if ( $class eq 'S' ) {
push @header,
'Credit unused service',
- 'Unsuspension fee',
+ 'Suspension fee',
;
push @fields,
sub {
@@ -78,17 +78,29 @@ if ( $class eq 'S' ) {
},
sub {
my $reason = shift;
- my $pkgpart = $reason->unsuspend_pkgpart or return '';
- my $part_pkg = FS::part_pkg->by_key($pkgpart) or return '';
- my $text = $part_pkg->pkg_comment;
- my $href = $p."edit/part_pkg.cgi?$pkgpart";
- $text = qq!<A HREF="$href">! . encode_entities($text) . "</A>".
- "<FONT SIZE=-1>";
- if ( $reason->unsuspend_hold ) {
- $text .= ' (on next bill)'
+ my $feepart = $reason->feepart;
+ my ($href, $text, $detail);
+ if ( $feepart ) {
+ my $part_fee = FS::part_fee->by_key($feepart) or return '';
+ $text = $part_fee->itemdesc . ': ' . $part_fee->explanation;
+ $detail = $reason->fee_on_unsuspend ? 'unsuspension' : 'suspension';
+ if ( $reason->fee_hold ) {
+ $detail = "next bill after $detail";
+ }
+ $detail = "(on $detail)";
+ $href = $p."edit/part_fee.html?$feepart";
} else {
- $text .= ' (immediately)'
+ my $pkgpart = $reason->unsuspend_pkgpart;
+ my $part_pkg = FS::part_pkg->by_key($pkgpart) or return '';
+ $text = $part_pkg->pkg_comment;
+ $href = $p."edit/part_pkg.cgi?$pkgpart";
+ $detail = $reason->unsuspend_hold ?
+ '(on next bill after unsuspension)' : '(on unsuspension)';
}
+ return '' unless length($text);
+
+ $text = qq!<A HREF="$href">! . encode_entities($text) . "</A> ".
+ "<FONT SIZE=-1>$detail</FONT>";
$text .= '</FONT>';
}
;
diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html
index 97976dfef..156910f51 100644
--- a/httemplate/edit/payment_gateway.html
+++ b/httemplate/edit/payment_gateway.html
@@ -103,6 +103,7 @@ my %modules = (
'KeyBank',
'Paymentech',
'TD_EFT',
+ 'BillBuddy',
],
);
diff --git a/httemplate/edit/reason.html b/httemplate/edit/reason.html
index 3e6645ec8..30168d551 100644
--- a/httemplate/edit/reason.html
+++ b/httemplate/edit/reason.html
@@ -13,9 +13,12 @@
'reason' => $classname . ' Reason',
'disabled' => 'Disabled',
'class' => '',
- 'unsuspend_pkgpart' => 'Unsuspension fee',
- 'unsuspend_hold' => 'Delay until next bill',
+ 'feepart' => 'Charge a suspension fee',
+ 'fee_on_unsuspend' => 'When a package is',
+ 'fee_hold' => 'Delay fee until next bill',
'unused_credit' => 'Credit unused portion of service',
+ 'unsuspend_pkgpart' => 'Order an unsuspension package',
+ 'unsuspend_hold' => 'Delay package until next bill',
},
'fields' => \@fields,
&>
@@ -64,6 +67,28 @@ my @fields = (
if ( $class eq 'S' ) {
push @fields,
+ { 'field' => 'unused_credit',
+ 'type' => 'checkbox',
+ 'value' => 'Y',
+ },
+ { 'type' => 'tablebreak-tr-title' },
+ { 'field' => 'feepart',
+ 'type' => 'select-table',
+ 'table' => 'part_fee',
+ 'hashref' => { disabled => '' },
+ 'name_col' => 'itemdesc',
+ 'value_col' => 'feepart',
+ 'empty_label' => 'none',
+ },
+ { 'field' => 'fee_on_unsuspend',
+ 'type' => 'select',
+ 'options' => [ '', 'Y' ],
+ 'labels' => { '' => 'suspended', 'Y' => 'unsuspended' },
+ },
+ { 'field' => 'fee_hold',
+ 'type' => 'checkbox',
+ 'value' => 'Y',
+ },
{ 'field' => 'unsuspend_pkgpart',
'type' => 'select-part_pkg',
'hashref' => { 'disabled' => '',
@@ -73,10 +98,6 @@ if ( $class eq 'S' ) {
'type' => 'checkbox',
'value' => 'Y',
},
- { 'field' => 'unused_credit',
- 'type' => 'checkbox',
- 'value' => 'Y',
- },
;
}
diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html
index 356597553..125874694 100755
--- a/httemplate/elements/tr-select-reason.html
+++ b/httemplate/elements/tr-select-reason.html
@@ -35,13 +35,17 @@ Example:
% # - no redundant checking of ACLs or parameters
% # - form fields are grouped for easy management
% # - use the standard select-table widget instead of ad hoc crap
+<& /elements/xmlhttp.html,
+ url => $p . 'misc/xmlhttp-reason-hint.html',
+ subs => [ 'get_hint' ],
+&>
<SCRIPT TYPE="text/javascript">
function <% $id %>_changed() {
- var hints = <% encode_json(\%all_hints) %>;
var select_reason = document.getElementById('<% $id %>');
- document.getElementById('<% $id %>_hint').innerHTML =
- hints[select_reason.value] || '';
+ get_hint(select_reason.value, function(stuff) {
+ document.getElementById('<% $id %>_hint').innerHTML = stuff || '';
+ });
// toggle submit button state
var submit_button = document.getElementById(<% $opt{control_button} |js_string %>);
@@ -123,24 +127,45 @@ Example:
field => $id.'_new_unused_credit',
value => 'Y'
&>
- <& tr-select-part_pkg.html,
- label => 'Charge this fee when unsuspending',
- field => $id.'_new_unsuspend_pkgpart',
- hashref => { disabled => '', freq => '0' },
+ <& tr-select-table.html,
+ label => 'Charge a suspension fee',
+ field => $id.'_new_feepart',
+ table => 'part_fee',
+ hashref => { disabled => '' },
+ name_col => 'itemdesc',
+ value_col => 'feepart',
empty_label => 'none',
&>
+ <& tr-select.html,
+ label => 'When this package is',
+ field => $id.'_new_fee_on_unsuspend',
+ options => [ '', 'Y' ],
+ labels => { '' => 'suspended', 'Y' => 'unsuspended' },
+ &>
<& tr-checkbox.html,
- label => 'Hold unsuspension fee until the next bill',
- field => $id.'_new_unsuspend_hold',
- value => 'Y',
+ label => 'Delay fee until the next bill',
+ field => $id.'_new_fee_hold',
+ value => 'Y',
&>
+%# deprecated, but still accessible through the "Suspend Reasons" UI
+%# <& tr-select-part_pkg.html,
+%# label => 'Charge this fee when unsuspending',
+%# field => $id.'_new_unsuspend_pkgpart',
+%# hashref => { disabled => '', freq => '0' },
+%# empty_label => 'none',
+%# &>
+%# <& tr-checkbox.html,
+%# label => 'Hold unsuspension fee until the next bill',
+%# field => $id.'_new_unsuspend_hold',
+%# value => 'Y',
+%# &>
% }
</table>
</td>
</tr>
% } # if the current user can add a reason
-% # container for hints
+% # container for hints (hints themselves come from xmlhttp-reason-hint)
<TR>
<TD COLSPAN=2 ALIGN="center" id="<% $id %>_hint" style="font-size:small">
</TD>
@@ -188,43 +213,6 @@ my @reasons = qsearch({
'order_by' => ' ORDER BY type, reason',
});
-my %all_hints;
-if ( $class eq 'S' ) {
- my $conf = FS::Conf->new;
- %all_hints = ( 0 => '', -1 => '' );
- foreach my $reason (@reasons) {
- my @hints;
- if ( $reason->unsuspend_pkgpart ) {
- my $part_pkg = FS::part_pkg->by_key($reason->unsuspend_pkgpart);
- if ( $part_pkg ) {
- if ( $part_pkg->option('setup_fee',1) > 0 and
- $part_pkg->option('recur_fee',1) == 0 ) {
- # the usual case
- push @hints,
- mt('A [_1] unsuspension fee will apply.',
- ($conf->config('money_char') || '$') .
- sprintf('%.2f', $part_pkg->option('setup_fee'))
- );
- } else {
- # oddball cases--not really supported
- push @hints,
- mt('An unsuspension package will apply: [_1]',
- $part_pkg->price_info
- );
- }
- } else { #no $part_pkg
- push @hints,
- '<FONT COLOR="#ff0000">Unsuspend pkg #'.$reason->unsuspend_pkgpart.
- ' not found.</FONT>';
- }
- }
- if ( $reason->unused_credit ) {
- push @hints, mt('The customer will be credited for unused time.');
- }
- $all_hints{ $reason->reasonnum } = join('<BR>', @hints);
- }
-}
-
my @post_options;
if ( $curuser->access_right($add_access_right) ) {
@post_options = ( -1 => 'Add new reason' );
diff --git a/httemplate/misc/cacti_graphs.html b/httemplate/misc/cacti_graphs.html
new file mode 100644
index 000000000..9cc5e2494
--- /dev/null
+++ b/httemplate/misc/cacti_graphs.html
@@ -0,0 +1,53 @@
+<% include( '/elements/header.html', 'Cacti Graphs' ) %>
+
+% if ($load) {
+
+<FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+</FORM>
+<% include( '/elements/progress-init.html',
+ 'CactiGraphForm',
+ [ 'svcnum' ],
+ $p.'misc/process/cacti_graphs.cgi',
+ { url => 'javascript:window.location.replace("'.popurl(2).'misc/cacti_graphs.html?svcnum='.$svcnum.'")' },
+) %>
+<!--
+ note we use window.location.replace for the callback url above
+ so that this page gets removed from browser history after processing
+ so that process() doesn't get triggered by the back button
+-->
+<P>Loading graphs, please wait...</P>
+<SCRIPT TYPE="text/javascript">
+process();
+</SCRIPT>
+
+% } else {
+% if ($error) {
+
+<P><% $error %></P>
+
+% } else {
+
+<% slurp($htmlfile) %>
+
+% }
+% }
+
+<%init>
+use File::Slurp qw( slurp );
+
+my $svcnum = $cgi->param('svcnum') or die 'Illegal svcnum';
+my $load = $cgi->param('load');
+my $graphnum = $cgi->param('graphnum');
+
+my $htmlfile = $FS::UID::cache_dir
+ . '/cacti-graphs/'
+ . 'svc_'
+ . $svcnum;
+$htmlfile .= '_graph_' . $graphnum
+ if $graphnum;
+$htmlfile .= '.html';
+
+my $error = (-e $htmlfile) ? '' : 'File not found';
+</%init>
+
diff --git a/httemplate/misc/process/cacti_graphs.cgi b/httemplate/misc/process/cacti_graphs.cgi
new file mode 100644
index 000000000..160b1ad85
--- /dev/null
+++ b/httemplate/misc/process/cacti_graphs.cgi
@@ -0,0 +1,6 @@
+<% $server->process %>
+
+<%init>
+my $server = FS::UI::Web::JSRPC->new('FS::part_export::cacti::process_graphs', $cgi);
+</%init>
+
diff --git a/httemplate/misc/process/elements/reason b/httemplate/misc/process/elements/reason
index ae92a7528..f57f11ff5 100644
--- a/httemplate/misc/process/elements/reason
+++ b/httemplate/misc/process/elements/reason
@@ -8,7 +8,8 @@ my $error;
if ($reasonnum == -1) {
my $new_reason = FS::reason->new({
map { $_ => scalar( $cgi->param("reasonnum_new_$_") ) }
- qw( reason_type reason unsuspend_pkgpart unsuspend_hold unused_credit )
+ qw( reason_type reason unsuspend_pkgpart unsuspend_hold unused_credit
+ feepart fee_on_unsuspend fee_hold )
}); # not sanitizing them here, but check() will do it
$error = $new_reason->insert;
$reasonnum = $new_reason->reasonnum;
diff --git a/httemplate/misc/xmlhttp-reason-hint.html b/httemplate/misc/xmlhttp-reason-hint.html
new file mode 100644
index 000000000..5d54788a4
--- /dev/null
+++ b/httemplate/misc/xmlhttp-reason-hint.html
@@ -0,0 +1,83 @@
+<%doc>
+Example:
+
+<& /elements/xmlhttp.html,
+ url => $p . 'misc/xmlhttp-reason-hint.html',
+ subs => [ 'get_hint' ]
+&>
+<script>
+var reasonnum = 101;
+get_hint( reasonnum, function(stuff) { alert(stuff); } )
+</script>
+
+Currently will provide hints for:
+1. suspension events (new-style reconnection fees, notification)
+2. unsuspend_pkgpart package info (older reconnection fees)
+3. crediting for unused time
+</%doc>
+<%init>
+my $sub = $cgi->param('sub');
+my ($reasonnum) = $cgi->param('arg');
+# arg is a reasonnum
+my $conf = FS::Conf->new;
+my $error = '';
+my @hints;
+if ( $reasonnum =~ /^\d+$/ ) {
+ my $reason = FS::reason->by_key($reasonnum);
+ if ( $reason ) {
+ # 1.
+ if ( $reason->feepart ) { # XXX
+ my $part_fee = FS::part_fee->by_key($reason->feepart);
+ my $when = '';
+ if ( $reason->fee_hold ) {
+ $when = 'on the next bill after ';
+ } else {
+ $when = 'upon ';
+ }
+ if ( $reason->fee_on_unsuspend ) {
+ $when .= 'unsuspension';
+ } else {
+ $when .= 'suspension';
+ }
+
+ my $fee_amt = $part_fee->explanation;
+ push @hints, mt('A fee of [_1] will be charged [_2].',
+ $fee_amt, $when);
+ }
+ # 2.
+ if ( $reason->unsuspend_pkgpart ) {
+ my $part_pkg = FS::part_pkg->by_key($reason->unsuspend_pkgpart);
+ if ( $part_pkg ) {
+ if ( $part_pkg->option('setup_fee',1) > 0 and
+ $part_pkg->option('recur_fee',1) == 0 ) {
+ # the usual case
+ push @hints,
+ mt('A [_1] unsuspension fee will apply.',
+ ($conf->config('money_char') || '$') .
+ sprintf('%.2f', $part_pkg->option('setup_fee'))
+ );
+ } else {
+ # oddball cases--not really supported
+ push @hints,
+ mt('An unsuspension package will apply: [_1]',
+ $part_pkg->price_info
+ );
+ }
+ } else { #no $part_pkg
+ push @hints,
+ '<FONT COLOR="#ff0000">Unsuspend pkg #'.$reason->unsuspend_pkgpart.
+ ' not found.</FONT>';
+ }
+ }
+ # 3.
+ if ( $reason->unused_credit ) {
+ push @hints, mt('The customer will be credited for unused time.');
+ }
+ } else {
+ warn "reasonnum $reasonnum not found; returning no hints\n";
+ }
+} else {
+ warn "reason-hint arg '$reasonnum' not a valid reasonnum\n";
+}
+</%init>
+<% join('<BR>', @hints) %>
diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi
index 9fe10bd3a..4935a1096 100644
--- a/httemplate/view/svc_broadband.cgi
+++ b/httemplate/view/svc_broadband.cgi
@@ -72,15 +72,11 @@ sub ip_addr {
my $out = $ip_addr;
$out .= ' (' . include('/elements/popup_link-ping.html', ip => $ip_addr) . ')'
if $ip_addr;
- if ($svc->cacti_leaf_id) {
- # should only ever be one, but not sure if that is enforced
- my ($cacti) = $svc->cust_svc->part_svc->part_export('cacti');
- $out .= ' (<A HREF="'
- . $cacti->option('base_url')
- . 'graph_view.php?action=tree&tree_id='
- . $cacti->option('tree_id')
- . '&leaf_id='
- . $svc->cacti_leaf_id
+ if ($svc->cust_svc->part_svc->part_export('cacti')) {
+ $out .= ' (<A HREF="'
+ . popurl(2)
+ . 'misc/cacti_graphs.html?load=1&svcnum='
+ . $svc->svcnum
. '">cacti</A>)';
}
if ( my $addr_block = $svc->addr_block ) {