From 4d364d506c717b1b73858dd287413d3788ec586d Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 12 Dec 2014 20:56:22 -0800 Subject: [PATCH] simple bulk provisioning of phone number ranges, RT#29800 --- FS/FS/Conf.pm | 9 +++- httemplate/edit/bulk-svc_phone.html | 52 ++++++++++++++++++++++++ httemplate/edit/process/bulk-svc_phone.html | 41 +++++++++++++++++++ httemplate/view/cust_main/packages/section.html | 1 + httemplate/view/cust_main/packages/services.html | 13 ++++++ 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 httemplate/edit/bulk-svc_phone.html create mode 100644 httemplate/edit/process/bulk-svc_phone.html diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 97659bc8c..c88d3e7a4 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -4950,8 +4950,15 @@ and customer address. Include units.', }, { + 'key' => 'svc_phone-bulk_provision_simple', + 'section' => 'telephony', + 'description' => 'Bulk provision phone numbers with a simple number range instead of from DID vendor orders', + 'type' => 'checkbox', + }, + + { 'key' => 'default_phone_countrycode', - 'section' => '', + 'section' => 'telephony', 'description' => 'Default countrycode', 'type' => 'text', }, diff --git a/httemplate/edit/bulk-svc_phone.html b/httemplate/edit/bulk-svc_phone.html new file mode 100644 index 000000000..fb7183612 --- /dev/null +++ b/httemplate/edit/bulk-svc_phone.html @@ -0,0 +1,52 @@ +<& /elements/header.html, mt('Bulk add [_1]',$svc) &> + +<& /elements/error.html &> + +% if ( $cust_main ) { + + <& /elements/small_custview.html, $cust_main, '', 1, + popurl(2) . "view/cust_main.cgi" &> +
+% } + +
+ + + + +<% ntable("#cccccc",2) %> + + + <% mt('Phone number range') |h %> + + + + + +
+ + +
+ +<& /elements/footer.html &> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk provision customer service'); + +$cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum'; +my $pkgnum = $1; +my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum }) + or die 'unknown pkgnum'; +my $cust_main = $cust_pkg->cust_main; + +$cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart'; +my $svcpart = $1; + +my $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); +die "No part_svc entry!" unless $part_svc; + +my $svc = $part_svc->getfield('svc'); + + diff --git a/httemplate/edit/process/bulk-svc_phone.html b/httemplate/edit/process/bulk-svc_phone.html new file mode 100644 index 000000000..5a1fbc647 --- /dev/null +++ b/httemplate/edit/process/bulk-svc_phone.html @@ -0,0 +1,41 @@ +<% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum;show=packages#cust_pkg$pkgnum") %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk provision customer service'); + +$cgi->param('phonenum') =~ /^\s*(\d+)\s*\-\s*(\d+)\s*$/ + or errorpage('Enter a phone number range, with dash as the separator'); +my($start, $end) = ($1, $2); + +$cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum'; +my $pkgnum = $1; +my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum }) + or die 'unknown pkgnum'; +my $custnum = $cust_pkg->custnum; + +if ( length($end) < length($start) ) { + $end = substr($start, 0, length($start) - length($end) ). $end; +} + +errorpage("$end is smaller than $start") if $end < $start; + +$cgi->param('num_avail') =~ /^(\d+)$/ or die 'illegal num_avail'; +my $num_avail = $1; +errorpage("There are only $num_avail available") + if $end - $start + 1 > $num_avail; + +foreach my $phonenum ( $start .. $end ) { + + my $svc_phone = new FS::svc_phone { + 'phonenum' => $phonenum, + 'pkgnum' => $pkgnum, + 'svcpart' => scalar($cgi->param('svcpart')), + }; + $svc_phone->set_default_and_fixed; + + my $error = $svc_phone->insert; + errorpage($error) if $error; +} + + diff --git a/httemplate/view/cust_main/packages/section.html b/httemplate/view/cust_main/packages/section.html index 217e8c556..e888c94ac 100755 --- a/httemplate/view/cust_main/packages/section.html +++ b/httemplate/view/cust_main/packages/section.html @@ -128,6 +128,7 @@ my %conf_opt = ( #for services.html 'svc_external-skip_manual' => $conf->exists('svc_external-skip_manual'), + 'svc_phone-bulk_provision_simple' => $conf->exists('svc_phone-bulk_provision_simple'), 'legacy_link' => $conf->exists('legacy_link'), 'manage_link' => scalar($conf->config('svc_broadband-manage_link')), 'manage_link_text' => scalar($conf->config('svc_broadband-manage_link_text')), diff --git a/httemplate/view/cust_main/packages/services.html b/httemplate/view/cust_main/packages/services.html index bb676e8ab..5fe41a38c 100644 --- a/httemplate/view/cust_main/packages/services.html +++ b/httemplate/view/cust_main/packages/services.html @@ -93,6 +93,8 @@ function clearhint_search_cust_svc(obj, str) { % { % if ( $part_svc->num_avail > 5 ) { % local $opt{'bulk'} = 1; +% local $opt{'svc_phone_bulk_provision_simple'} = $svc_phone_bulk_provision_simple; +% local $opt{'num_avail'} = $part_svc->num_avail;
<% svc_provision_link($cust_pkg, $part_svc, \%opt, $curuser) %> % } % #XXX if there's orders for this customer { @@ -116,6 +118,8 @@ my %opt = @_; my $bgcolor = $opt{'bgcolor'}; my $cust_pkg = $opt{'cust_pkg'}; my $part_pkg = $opt{'part_pkg'}; +my $svc_phone_bulk_provision_simple = $opt{'svc_phone-bulk_provision_simple'}; + my $curuser = $FS::CurrentUser::CurrentUser; sub svc_provision_link { @@ -133,6 +137,12 @@ sub svc_provision_link { && $opt->{'svc_external-skip_manual'} ) { $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$query"; + } elsif ( $part_svc->svcdb eq 'svc_phone' && $opt->{bulk} + && $opt->{svc_phone_bulk_provision_simple} + ) + { + $query .= ';num_avail='. $opt->{num_avail}; + $url = "${p}edit/bulk-svc_phone.html?$query"; } else { $url = svc_url( 'm' => $m, @@ -146,14 +156,17 @@ sub svc_provision_link { my $link = qq!!. emt("$action [_1] ([_2])",$svc_nbsp,$num_avail).''; + if ( $opt->{'legacy_link'} && $curuser->access_right('View/link unlinked services') + && ! $opt{bulk} ) { $link .= '
'. qq!!. emt("Link to legacy [_1] ([_2])",$svc_nbsp,$num_avail).''; } + $link; } -- 2.11.0