From 99037cf94d9d6b5d7c1e512a6dca842706851710 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 12 Mar 2008 16:24:34 +0000 Subject: [PATCH] allow exports to add links to customer view (#1407) --- FS/FS/UI/Web.pm | 8 ++++++++ FS/FS/cust_svc.pm | 14 ++++++++++++++ FS/FS/part_export.pm | 8 ++++++++ FS/FS/part_export/prizm.pm | 8 ++++++++ FS/FS/svc_Common.pm | 13 +++++++++++++ eg/export_template.pm | 9 ++++++++- httemplate/view/cust_main/packages.html | 5 +++-- 7 files changed, 62 insertions(+), 3 deletions(-) diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm index 6a97f96dd..e4a9ac1b8 100644 --- a/FS/FS/UI/Web.pm +++ b/FS/FS/UI/Web.pm @@ -149,6 +149,14 @@ sub svc_X_link { "$ahref$x"; } +sub svc_export_links { + my ($m, $part_svc, $cust_svc) = @_ or return ''; + + my $ahref = $cust_svc->export_links; + + join('', @$ahref); +} + sub parse_lt_gt { my($cgi, $field) = @_; diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 8eecda3ad..51fc18688 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -392,6 +392,20 @@ sub _svc_label { } +=item export_links + +Returns a list of html elements associated with this services exports. + +=cut + +sub export_links { + my $self = shift; + my $svc_x = $self->svc_x + or return "can't find ". $self->part_svc->svcdb. '.svcnum '. $self->svcnum; + + $svc_x->export_links; +} + =item svc_x Returns the FS::svc_XXX object for this service (i.e. an FS::svc_acct object or diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 6adcab94d..983e0b012 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -359,6 +359,14 @@ sub _export_unsuspend { $self->_export_replace( $svc_x, $old ); } +=item export_links SVC_OBJECT ARRAYREF + +Adds a list of web elements to ARRAYREF specific to this export and SVC_OBJECT. +The elements are displayed in the UI to lead the the operator to external +configuration, monitoring, and similar tools. + +=cut + =back =head1 SUBROUTINES diff --git a/FS/FS/part_export/prizm.pm b/FS/FS/part_export/prizm.pm index 3ba1b2762..754d428cd 100644 --- a/FS/FS/part_export/prizm.pm +++ b/FS/FS/part_export/prizm.pm @@ -463,6 +463,14 @@ sub _export_unsuspend { ''; } +sub export_links { + my( $self, $svc, $arrayref ) = ( shift, shift, shift ); + + push @$arrayref, 'SM'; + + ''; +} + sub queue_statuschange { my( $self, $method, $jobs, $svc, @args ) = @_; diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm index 787acee22..d830f2fad 100644 --- a/FS/FS/svc_Common.pm +++ b/FS/FS/svc_Common.pm @@ -708,6 +708,19 @@ sub unsuspend { $self->export('unsuspend', @$export_args); } +=item export_links + +Runs export_links callbacks and returns the links. + +=cut + +sub export_links { + my $self = shift; + my $return = []; + $self->export('links', $return); + $return; +} + =item export HOOK [ EXPORT_ARGS ] Runs the provided export hook (i.e. "suspend", "unsuspend") for this service. diff --git a/eg/export_template.pm b/eg/export_template.pm index 2830ce337..22eb36a42 100644 --- a/eg/export_template.pm +++ b/eg/export_template.pm @@ -56,7 +56,7 @@ sub _export_delete { ref($err_or_queue) ? '' : $err_or_queue; } -#these two are optional +#these three are optional # fallback for svc_acct will change and restore password sub _export_suspend { my( $self, $svc_something ) = (shift, shift); @@ -72,6 +72,13 @@ sub _export_unsuspend { ref($err_or_queue) ? '' : $err_or_queue; } +sub export_links { + my($self, $svc_something, $arrayref) = (shift, shift, shift); + #push @$arrayref, qq!!. $svc_something->username. qq!!; + ''; +} + ### #a good idea to queue anything that could fail or take any time diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 167c625eb..891fa3009 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -299,10 +299,11 @@ Current packages <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %> <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %> + <% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %> - + <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($conf->exists('cust_pkg-display_times') ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %> @@ -338,7 +339,7 @@ Current packages % ) { - + <% svc_provision_link($cust_pkg, $part_svc, $conf, $curuser) %> -- 2.11.0