RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / bulk-svc_phone.html
1 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum;show=packages#cust_pkg$pkgnum") %>
2 <%init>
3
4 die "access denied"
5   unless $FS::CurrentUser::CurrentUser->access_right('Bulk provision customer service');
6
7 $cgi->param('phonenum') =~ /^\s*(\d+)\s*\-\s*(\d+)\s*$/
8   or errorpage('Enter a phone number range, with dash as the separator');
9 my($start, $end) = ($1, $2);
10
11 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum';
12 my $pkgnum = $1;
13 my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum })
14   or die 'unknown pkgnum';
15 my $custnum = $cust_pkg->custnum;
16
17 if ( length($end) < length($start) ) {
18   $end = substr($start, 0, length($start) - length($end) ). $end;
19 }
20
21 errorpage("$end is smaller than $start") if $end < $start;
22
23 $cgi->param('num_avail') =~ /^(\d+)$/ or die 'illegal num_avail';
24 my $num_avail = $1;
25 errorpage("There are only $num_avail available")
26   if $end - $start + 1 > $num_avail;
27
28 foreach my $phonenum ( "$start" .. "$end" ) {
29
30   my $svc_phone = new FS::svc_phone {
31     'phonenum' => $phonenum,
32     'pkgnum'   => $pkgnum,
33     'svcpart'  => scalar($cgi->param('svcpart')),
34   };
35   $svc_phone->set_default_and_fixed;
36
37   my $error = $svc_phone->insert;
38   errorpage($error) if $error;
39 }
40
41 </%init>