From 40f2c04772472b966eb9bbc7ea4ebc20269698b7 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 12 Dec 2014 20:56:22 -0800 Subject: simple bulk provisioning of phone number ranges, RT#29800 --- httemplate/edit/bulk-svc_phone.html | 52 +++++++++++++++++++++++++++++ httemplate/edit/process/bulk-svc_phone.html | 41 +++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 httemplate/edit/bulk-svc_phone.html create mode 100644 httemplate/edit/process/bulk-svc_phone.html (limited to 'httemplate/edit') 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; +} + + -- cgit v1.2.1