diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 20:56:22 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-12-12 20:56:22 -0800 |
commit | 4d364d506c717b1b73858dd287413d3788ec586d (patch) | |
tree | 3cf788cf112a2497492dba7fb0973da23c3bbafd | |
parent | 2457752a82358108aa078f175a4e866f1786299a (diff) |
simple bulk provisioning of phone number ranges, RT#29800
-rw-r--r-- | FS/FS/Conf.pm | 9 | ||||
-rw-r--r-- | httemplate/edit/bulk-svc_phone.html | 52 | ||||
-rw-r--r-- | httemplate/edit/process/bulk-svc_phone.html | 41 | ||||
-rwxr-xr-x | httemplate/view/cust_main/packages/section.html | 1 | ||||
-rw-r--r-- | httemplate/view/cust_main/packages/services.html | 13 |
5 files changed, 115 insertions, 1 deletions
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" &> + <BR> +% } + +<FORM NAME="OneTrueForm" ACTION="<% popurl(1) %>process/bulk-svc_phone.html" METHOD=POST> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>"> +<INPUT TYPE="hidden" NAME="num_avail" VALUE="<% scalar($cgi->param('num_avail')) |h %>"> + +<% ntable("#cccccc",2) %> + +<TR> + <TD ALIGN="right"><% mt('Phone number range') |h %></TD> + <TD><INPUT TYPE="text" NAME="phonenum" VALUE=""></TD> +</TR> + +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Submit"> + +</FORM> + +<& /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'); + +</%init> 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; +} + +</%init> 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; <BR><% 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!<A CLASS="provision" HREF="$url">!. emt("$action [_1] ([_2])",$svc_nbsp,$num_avail).'</A>'; + if ( $opt->{'legacy_link'} && $curuser->access_right('View/link unlinked services') + && ! $opt{bulk} ) { $link .= '<BR>'. qq!<A CLASS="provision" HREF="${p}misc/link.cgi?$query">!. emt("Link to legacy [_1] ([_2])",$svc_nbsp,$num_avail).'</A>'; } + $link; } |