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 /httemplate/edit/process | |
parent | 2457752a82358108aa078f175a4e866f1786299a (diff) |
simple bulk provisioning of phone number ranges, RT#29800
Diffstat (limited to 'httemplate/edit/process')
-rw-r--r-- | httemplate/edit/process/bulk-svc_phone.html | 41 |
1 files changed, 41 insertions, 0 deletions
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> |