From: ivan Date: Wed, 10 Aug 2011 05:22:34 +0000 (+0000) Subject: multiple DID provisioning, RT#13721 X-Git-Tag: freeside_2_3_1~345 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8737dc99be5a9874c40f36d1420447253ee12c31 multiple DID provisioning, RT#13721 --- diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index f7558e8ff..24064f942 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -78,6 +78,9 @@ Example: 'agent_virt' => 1, 'agent_null_right' => 'Access Right Name', + #special bulk insert mode + 'bulk' => 'field', + &> @@ -85,6 +88,9 @@ Example: % % my $edit_ext = $opt{'edit_ext'} || 'html'; % my $url = $opt{'error_redirect'} || popurl(2)."$table.$edit_ext"; + +% #my $query = $m->scomp('/elements/create_uri_query'); +% #$cgi->redirect("$url?$query"); % if ( length($cgi->query_string) > 1920 ) { #stupid IE 2083 URL limit % % my $session = int(rand(4294967296)); #XXX @@ -128,7 +134,7 @@ Example: % % if ( $opt{'redirect'} ) { % -<% $cgi->redirect( $opt{'redirect'}. $pkeyvalue ) %> +<% $cgi->redirect( $opt{'redirect'}. $new_pkey) %> % % } else { % @@ -163,13 +169,13 @@ my $fields = $opt{'fields'} #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; || [ fields($table) ]; -my $pkeyvalue = $cgi->param($pkey); +my $old_pkey = $cgi->param($pkey); my $old = ''; -if ( $pkeyvalue ) { +if ( $old_pkey ) { $old = qsearchs({ 'table' => $table, - 'hashref' => { $pkey => $pkeyvalue }, + 'hashref' => { $pkey => $old_pkey }, 'extra_sql' => ( $opt{'agent_virt'} ? ' AND '. $curuser->agentnums_sql( 'null_right' => $opt{'agent_null_right'} @@ -179,145 +185,163 @@ if ( $pkeyvalue ) { }); } +my $bfield = $opt{'bulk'}; + my %hash = map { my @entry = ( $_ => scalar($cgi->param($_)) ); $opt{'value_callback'} ? ( $_ => &{ $opt{'value_callback'} }( @entry )) : ( @entry ) - } @$fields; + } grep { $_ ne $bfield } @$fields; + +my @values = ( 1 ); +if ( $bfield ) { + @values = $cgi->param($bfield); + warn join(',', @values); +} + +my $new; +my $new_pkey = ''; +foreach my $value ( @values ) { -my $new = $class->new( \%hash ); + $new = $class->new( \%hash ); -if ($old && exists($opt{'copy_on_empty'})) { - foreach my $field (@{$opt{'copy_on_empty'}}) { - $new->set($field, $old->get($field)) - unless scalar($cgi->param($field)); + $new->$bfield($value) if $bfield; + + if ($old && exists($opt{'copy_on_empty'})) { + foreach my $field (@{$opt{'copy_on_empty'}}) { + $new->set($field, $old->get($field)) + unless scalar($cgi->param($field)); + } } -} -if ( $opt{'agent_virt'} ) { + if ( $opt{'agent_virt'} ) { - if ( ! $new->agentnum - && ( ! $opt{'agent_null_right'} - || ! $curuser->access_right($opt{'agent_null_right'}) - ) - ) - { + if ( ! $new->agentnum + && ( ! $opt{'agent_null_right'} + || ! $curuser->access_right($opt{'agent_null_right'}) + ) + ) + { - $error ||= 'Select an agent'; + $error ||= 'Select an agent'; - } else { + } else { - die "illegal agentnum" - unless $curuser->agentnums_href->{$new->agentnum} - or $curuser->access_right('View customers of all agents') - or $opt{'agent_null_right'} - && ! $new->agentnum - && $curuser->access_right($opt{'agent_null_right'}); + die "illegal agentnum" + unless $curuser->agentnums_href->{$new->agentnum} + or $curuser->access_right('View customers of all agents') + or $opt{'agent_null_right'} + && ! $new->agentnum + && $curuser->access_right($opt{'agent_null_right'}); - } + } -} + } -$error ||= $new->check; + $error ||= $new->check; -my @args = (); -if ( !$error && $opt{'args_callback'} ) { - @args = &{ $opt{'args_callback'} }( $cgi, $new ); -} + my @args = (); + if ( !$error && $opt{'args_callback'} ) { + @args = &{ $opt{'args_callback'} }( $cgi, $new ); + } -if ( !$error && $opt{'debug'} ) { - warn "$me updating record in $table table using $class class\n"; - warn Dumper(\%hash); - warn "with args: \n". Dumper(\@args) if @args; -} + if ( !$error && $opt{'debug'} ) { + warn "$me updating record in $table table using $class class\n"; + warn Dumper(\%hash); + warn "with args: \n". Dumper(\@args) if @args; + } -if ( !$error ) { - if ( $pkeyvalue ) { - $error = $new->replace($old, @args); - } else { - $error = $new->insert(@args); - $pkeyvalue = $new->getfield($pkey); + if ( !$error ) { + if ( $old_pkey ) { + $error = $new->replace($old, @args); + } else { + $error = $new->insert(@args); + $new_pkey = $new->getfield($pkey); + } } -} -if ( !$error && $opt{'process_m2m'} ) { + if ( !$error && $opt{'process_m2m'} ) { + + my @process_m2m = ref($opt{'process_m2m'}) eq 'ARRAY' + ? @{ $opt{'process_m2m'} } + : ( $opt{'process_m2m'} ); - my @process_m2m = ref($opt{'process_m2m'}) eq 'ARRAY' - ? @{ $opt{'process_m2m'} } - : ( $opt{'process_m2m'} ); + foreach my $process_m2m (@process_m2m) { - foreach my $process_m2m (@process_m2m) { + $process_m2m->{'params'} ||= scalar($cgi->Vars); - $process_m2m->{'params'} ||= scalar($cgi->Vars); + warn "$me processing m2m:\n". Dumper( %$process_m2m ) + if $opt{'debug'}; - warn "$me processing m2m:\n". Dumper( %$process_m2m ) - if $opt{'debug'}; + $error = $new->process_m2m( %$process_m2m ); + } - $error = $new->process_m2m( %$process_m2m ); } -} + if ( !$error && $opt{'process_m2name'} ) { -if ( !$error && $opt{'process_m2name'} ) { + my @process_m2name = ref($opt{'process_m2name'}) eq 'ARRAY' + ? @{ $opt{'process_m2name'} } + : ( $opt{'process_m2name'} ); - my @process_m2name = ref($opt{'process_m2name'}) eq 'ARRAY' - ? @{ $opt{'process_m2name'} } - : ( $opt{'process_m2name'} ); + foreach my $process_m2name (@process_m2name) { - foreach my $process_m2name (@process_m2name) { + if ( $opt{'debug'} ) { + warn "$me processing m2name:\n". Dumper( %{ $process_m2name }, + 'params' => scalar($cgi->Vars), + ); + } - if ( $opt{'debug'} ) { - warn "$me processing m2name:\n". Dumper( %{ $process_m2name }, - 'params' => scalar($cgi->Vars), - ); + $error = $new->process_m2name( %{ $process_m2name }, + 'params' => scalar($cgi->Vars), + ); } - $error = $new->process_m2name( %{ $process_m2name }, - 'params' => scalar($cgi->Vars), - ); } -} + if ( !$error && $opt{'process_o2m'} ) { -if ( !$error && $opt{'process_o2m'} ) { + my @process_o2m = ref($opt{'process_o2m'}) eq 'ARRAY' + ? @{ $opt{'process_o2m'} } + : ( $opt{'process_o2m'} ); - my @process_o2m = ref($opt{'process_o2m'}) eq 'ARRAY' - ? @{ $opt{'process_o2m'} } - : ( $opt{'process_o2m'} ); + foreach my $process_o2m (@process_o2m) { - foreach my $process_o2m (@process_o2m) { + if ( $opt{'debug'} ) { + warn "$me processing o2m:\n". Dumper( %{ $process_o2m }, + 'params' => scalar($cgi->Vars), + ); + } - if ( $opt{'debug'} ) { - warn "$me processing o2m:\n". Dumper( %{ $process_o2m }, - 'params' => scalar($cgi->Vars), - ); + $error = $new->process_o2m( %{ $process_o2m }, + 'params' => scalar($cgi->Vars), + ); } - $error = $new->process_o2m( %{ $process_o2m }, - 'params' => scalar($cgi->Vars), - ); } -} - -if ( $error ) { + if ( $error ) { - $cgi->param('error', $error); - if ( $opt{'clear_on_error'} && scalar(@{$opt{'clear_on_error'}}) ) { - foreach my $field (@{$opt{'clear_on_error'}}) { - $cgi->param($field, '') + $cgi->param('error', $error); + if ( $opt{'clear_on_error'} && scalar(@{$opt{'clear_on_error'}}) ) { + foreach my $field (@{$opt{'clear_on_error'}}) { + $cgi->param($field, '') + } } - } -} else { + } else { + + if ( $opt{'noerror_callback'} ) { + &{ $opt{'noerror_callback'} }( $cgi, $new ); + } - if ( $opt{'noerror_callback'} ) { - &{ $opt{'noerror_callback'} }( $cgi, $new ); } + last if $error; + } diff --git a/httemplate/edit/process/svc_phone.html b/httemplate/edit/process/svc_phone.html index 9dd1226cc..7a3b43d32 100644 --- a/httemplate/edit/process/svc_phone.html +++ b/httemplate/edit/process/svc_phone.html @@ -1,13 +1,32 @@ -<% include( 'elements/svc_Common.html', - 'table' => 'svc_phone', - 'args_callback' => $args_callback, +<& elements/svc_Common.html, + 'table' => 'svc_phone', + 'args_callback' => $args_callback, 'value_callback' => $value_callback, - ) -%> + %opt, +&> <%init> +my %opt = (); +if ( $cgi->param('bulk') ) { + $opt{'bulk'} = 'phonenum'; + + my $cust_pkg = qsearchs('cust_pkg', { pkgnum=>scalar($cgi->param('pkgnum')) }) + or die "unknown pkgnum"; + my $custnum = $cust_pkg->custnum; + + my $show = + $FS::CurrentUser::CurrentUser->default_customer_view =~ /^(jumbo|packages)$/ + ? '' + : ';show=packages'; + #my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment + $opt{'redirect'}= popurl(3)."view/cust_main.cgi?custnum=$custnum$show;dummy="; +} + +my $right = $opt{'bulk'} ? 'Bulk provision customer service' + : 'Provision customer service'; + die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + unless $FS::CurrentUser::CurrentUser->access_right($right); my $tollfreephonenum = $cgi->param('tollfreephonenum'); $cgi->param('phonenum',$tollfreephonenum) if $tollfreephonenum =~ /^\d+$/; diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index 2c19d2cd9..9647b6887 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -1,36 +1,56 @@ -<% include( 'elements/svc_Common.html', - 'table' => 'svc_phone', - 'fields' => \@fields, - 'svc_new_callback' => sub { - my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_; - $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg; - }, - ) -%> +<& elements/svc_Common.html, + 'table' => 'svc_phone', + 'fields' => [], + 'begin_callback' => $begin_callback, + 'svc_new_callback' => sub { + my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_; + $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg; + }, +&> <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? +my $begin_callback = sub { + my( $cgi, $fields, $opt ) = @_; -my $conf = new FS::Conf; + my $bulk = $cgi->param('bulk') ? 1 : 0; -my @fields = ( 'countrycode', - { field => 'phonenum', - type => 'select-did', - label => 'Phone number', - }, - ); + my $right = $bulk ? 'Bulk provision customer service' + : 'Provision customer service'; -push @fields, { field => 'domsvc', - type => 'select-svc-domain', - label => 'Domain', - } - if $conf->exists('svc_phone-domain'); + die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right($right); -push @fields, { field => 'pbxsvc', - type => 'select-svc_pbx', - label => 'PBX', - }, + my $conf = new FS::Conf; + + push @$fields, + 'countrycode', + { field => 'phonenum', + type => 'select-did', + label => 'Phone number', + multiple => $bulk, + }; + + push @$fields, { field => 'domsvc', + type => 'select-svc-domain', + label => 'Domain', + } + if $conf->exists('svc_phone-domain'); + + push @$fields, { field => 'pbxsvc', + type => 'select-svc_pbx', + label => 'PBX', + }; + + if ( $bulk ) { + + push @$fields, { field => 'bulk', + type => 'hidden', + value => '1', + }; + + } else { + + push @$fields, 'sip_password', 'pin', { field => 'phone_name', @@ -62,10 +82,11 @@ push @fields, { field => 'pbxsvc', }, }, { field => 'custnum', type=> 'hidden' }, #for new cust_locations -; + ; + } -if ( $conf->exists('svc_phone-lnp') ) { - push @fields, + if ( $conf->exists('svc_phone-lnp') && !$bulk ) { + push @$fields, { value => 'Number Portability', type => 'tablebreak-tr-title', colspan => 8, @@ -87,7 +108,9 @@ if ( $conf->exists('svc_phone-lnp') ) { }, 'lnp_other_provider', 'lnp_other_provider_account', -; -} + ; + } + +}; diff --git a/httemplate/elements/select-areacode.html b/httemplate/elements/select-areacode.html index 453205c02..a302befc2 100644 --- a/httemplate/elements/select-areacode.html +++ b/httemplate/elements/select-areacode.html @@ -38,7 +38,9 @@ // blank the current phonenum too for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- ) what.form.<% $opt{'prefix'} %>phonenum.options[i] = null; - opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number'); + if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) { + opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number'); + } % if ($opt{empty}) { opt(what.form.<% $opt{'prefix'} %>areacode, '', '<% $opt{empty} %>'); diff --git a/httemplate/elements/select-did.html b/httemplate/elements/select-did.html index 8e981fde1..a69450c2a 100644 --- a/httemplate/elements/select-did.html +++ b/httemplate/elements/select-did.html @@ -18,47 +18,46 @@ Example: - - - - - - - - - - -
+ <% include('/elements/select-state.html', 'prefix' => 'phonenum_', #$field.'_', 'country' => $country, + 'svcpart' => $svcpart, 'disable_empty' => 0, 'empty_label' => 'Select state', ) %> +
State
+ <% include('/elements/select-areacode.html', 'state_prefix' => 'phonenum_', #$field.'_', 'svcpart' => $svcpart, 'empty' => 'Select area code', ) %> +
Area code
+ <% include('/elements/select-exchange.html', 'svcpart' => $svcpart, 'empty' => 'Select exchange', ) %> +
City / Exchange
+ <% include('/elements/select-phonenum.html', - 'svcpart' => $svcpart, - 'empty' => 'Select phone number', - 'bulknum' => $bulknum, + 'svcpart' => $svcpart, + 'empty' => 'Select phone number', + 'bulknum' => $bulknum, + 'multiple' => $multiple, ) %> +
Phone number
StateArea codeCity / ExchangePhone number
% } @@ -118,7 +117,8 @@ $export = $exports[0] if scalar(@exports); my $use_selector = scalar(@exports) ? 1 : 0; -my $bulknum = $opt{'bulknum'} || 0; +my $bulknum = $opt{'bulknum'} || 0; #Bulk DID orders via ordering system, vs. +my $multiple = $opt{'multiple'} || 0; #just selecting a bunch at a time my $country = ( $export && $export->option('country') ) || $conf->config('countrydefault') diff --git a/httemplate/elements/select-exchange.html b/httemplate/elements/select-exchange.html index 012e7c6b7..9e4b5ce97 100644 --- a/httemplate/elements/select-exchange.html +++ b/httemplate/elements/select-exchange.html @@ -33,7 +33,9 @@ // blank the current phonenum too for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- ) what.form.<% $opt{'prefix'} %>phonenum.options[i] = null; - opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number'); + if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) { + opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number'); + } % if ($opt{empty}) { opt(what.form.<% $opt{'prefix'} %>exchange, '', '<% $opt{empty} %>'); diff --git a/httemplate/elements/select-phonenum.html b/httemplate/elements/select-phonenum.html index 25a885a39..d555bf4b6 100644 --- a/httemplate/elements/select-phonenum.html +++ b/httemplate/elements/select-phonenum.html @@ -30,7 +30,9 @@ what.form.<% $opt{'prefix'} %>phonenum.options[i] = null; % if ($opt{empty}) { - opt(what.form.<% $opt{'prefix'} %>phonenum, '', '<% $opt{empty} %>'); + if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ){ + opt(what.form.<% $opt{'prefix'} %>phonenum, '', '<% $opt{empty} %>'); + } % } // add the new phonenums @@ -127,10 +129,15 @@ % } - + ID = "<% $opt{'prefix'} %>phonenum" + NAME = "<% $opt{'prefix'} %>phonenum" + <% $opt{'disabled'} %> +%# notonChange="<% $opt{'prefix'} %>phonenum_changed(this); <% $opt{'onchange'} %>" +> +% unless ( $opt{multiple} ) { + +% } <%init> diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html index 2d60fde0f..785b2ec24 100644 --- a/httemplate/elements/select-state.html +++ b/httemplate/elements/select-state.html @@ -42,7 +42,9 @@ Example: <%init> my %opt = @_; -foreach my $opt (qw( state country prefix onchange disabled empty_label )) { +foreach my $opt (qw( + state country prefix onchange disabled empty_label svcpart +)) { $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt}); } @@ -62,5 +64,16 @@ my $style = tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); +if ( $opt{'svcpart'} ) { + + my $sth = dbh->prepare( + 'SELECT DISTINCT state FROM phone_avail WHERE svcnum IS NULL' + ) or die dbh->errstr; + $sth->execute or die $sth->errstr; + my %avail_states = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref }; + + delete $states{$_} foreach grep ! $avail_states{$_}, keys %states; +} + diff --git a/httemplate/misc/areacodes.cgi b/httemplate/misc/areacodes.cgi index 69c9573c3..9d32a3baf 100644 --- a/httemplate/misc/areacodes.cgi +++ b/httemplate/misc/areacodes.cgi @@ -1,4 +1,3 @@ -%# [ <% join(', ', map { qq("$_") } @areacodes) %> ] <% objToJson(\@areacodes) %> <%init> @@ -7,18 +6,21 @@ my( $state, $svcpart ) = $cgi->param('arg'); my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } ); die "unknown svcpart $svcpart" unless $part_svc; -my @exports = $part_svc->part_export_did; -if ( scalar(@exports) > 1 ) { - die "more than one DID-providing export attached to svcpart $svcpart"; -} elsif ( ! @exports ) { - die "no DID providing export attached to svcpart $svcpart"; -} -my $export = $exports[0]; +my @areacodes = (); +if ( $state ) { + + my @exports = $part_svc->part_export_did; + if ( scalar(@exports) > 1 ) { + die "more than one DID-providing export attached to svcpart $svcpart"; + } elsif ( ! @exports ) { + die "no DID providing export attached to svcpart $svcpart"; + } + my $export = $exports[0]; -my $something = $export->get_dids('state'=>$state); + my $something = $export->get_dids('state'=>$state); -#warn Dumper($something); + @areacodes = @{ $something }; -my @areacodes = @{ $something }; +} diff --git a/httemplate/misc/exchanges.cgi b/httemplate/misc/exchanges.cgi index f5860cff2..8a67f7bab 100644 --- a/httemplate/misc/exchanges.cgi +++ b/httemplate/misc/exchanges.cgi @@ -1,4 +1,3 @@ -%# [ <% join(', ', map { qq("$_") } @exchanges) %> ] <% objToJson(\@exchanges) %> <%init> @@ -7,18 +6,21 @@ my( $areacode, $svcpart ) = $cgi->param('arg'); my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } ); die "unknown svcpart $svcpart" unless $part_svc; -my @exports = $part_svc->part_export_did; -if ( scalar(@exports) > 1 ) { - die "more than one DID-providing export attached to svcpart $svcpart"; -} elsif ( ! @exports ) { - die "no DID providing export attached to svcpart $svcpart"; -} -my $export = $exports[0]; +my @exchanges = (); +if ( $areacode ) { + + my @exports = $part_svc->part_export_did; + if ( scalar(@exports) > 1 ) { + die "more than one DID-providing export attached to svcpart $svcpart"; + } elsif ( ! @exports ) { + die "no DID providing export attached to svcpart $svcpart"; + } + my $export = $exports[0]; -my $something = $export->get_dids('areacode'=>$areacode); + my $something = $export->get_dids('areacode'=>$areacode); -#warn Dumper($something); + @exchanges = @{ $something }; -my @exchanges = @{ $something }; +} diff --git a/httemplate/misc/phonenums.cgi b/httemplate/misc/phonenums.cgi index 108a5f7cd..784a19016 100644 --- a/httemplate/misc/phonenums.cgi +++ b/httemplate/misc/phonenums.cgi @@ -1,4 +1,4 @@ -<% objToJson(\@exchanges) %> +<% objToJson(\@phonenums) %> <%init> my( $exchangestring, $svcpart ) = $cgi->param('arg'); @@ -6,31 +6,37 @@ my( $exchangestring, $svcpart ) = $cgi->param('arg'); my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } ); die "unknown svcpart $svcpart" unless $part_svc; -my @exports = $part_svc->part_export_did; -if ( scalar(@exports) > 1 ) { - die "more than one DID-providing export attached to svcpart $svcpart"; -} elsif ( ! @exports ) { - die "no DID providing export attached to svcpart $svcpart"; -} -my $export = $exports[0]; +my @phonenums = (); + +if ( $exchangestring ) { + + my @exports = $part_svc->part_export_did; + if ( scalar(@exports) > 1 ) { + die "more than one DID-providing export attached to svcpart $svcpart"; + } elsif ( ! @exports ) { + die "no DID providing export attached to svcpart $svcpart"; + } + my $export = $exports[0]; -my %opts = (); -if ( $exchangestring eq 'tollfree' ) { - $opts{'tollfree'} = 1; -} -elsif ( $exchangestring =~ /^([\w\s]+), ([A-Z][A-Z])$/ ) { - $opts{'ratecenter'} = $1; - $opts{'state'} = $2; -} -else { - $exchangestring =~ /\((\d{3})-(\d{3})-XXXX\)\s*$/i - or die "unparsable exchange: $exchangestring"; - my( $areacode, $exchange ) = ( $1, $2 ); - $opts{'areacode'} = $areacode; - $opts{'exchange'} = $exchange; -} + my %opts = (); + if ( $exchangestring eq 'tollfree' ) { + $opts{'tollfree'} = 1; + } + elsif ( $exchangestring =~ /^([\w\s]+), ([A-Z][A-Z])$/ ) { + $opts{'ratecenter'} = $1; + $opts{'state'} = $2; + } + else { + $exchangestring =~ /\((\d{3})-(\d{3})-XXXX\)\s*$/i + or die "unparsable exchange: $exchangestring"; + my( $areacode, $exchange ) = ( $1, $2 ); + $opts{'areacode'} = $areacode; + $opts{'exchange'} = $exchange; + } -my $something = $export->get_dids(%opts); -my @exchanges = @{ $something }; + my $something = $export->get_dids(%opts); + @phonenums = @{ $something }; + +} diff --git a/httemplate/view/cust_main/packages/services.html b/httemplate/view/cust_main/packages/services.html index 0c18f584e..8f3a028dd 100644 --- a/httemplate/view/cust_main/packages/services.html +++ b/httemplate/view/cust_main/packages/services.html @@ -73,7 +73,13 @@ function clearhint_search_cust_svc(obj, str) { <% svc_provision_link($cust_pkg, $part_svc, \%opt, $curuser) %> % if ( $curuser->access_right('Bulk provision customer service') % && $part_svc->svcdb eq 'svc_phone' ) { -
<% mt('Browse Received DID Inventory') |h %> +% if ( $part_svc->num_avail > 5 ) { +% $opt{'bulk'} = 1; +
<% svc_provision_link($cust_pkg, $part_svc, \%opt, $curuser) %> +% } +% #XXX if there's orders for this customer { +
<% mt('Browse Received DID Inventory') |h %> +% #} % } @@ -98,33 +104,38 @@ my $conf = new FS::Conf; sub svc_provision_link { my ($cust_pkg, $part_svc, $opt, $curuser) = @_; + ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g; my $num_avail = $part_svc->num_avail; - my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'. - "svcpart=". $part_svc->svcpart; + + my $query = "pkgnum=". $cust_pkg->pkgnum. ';'. + "svcpart=". $part_svc->svcpart; + $query .= ';bulk=1' if $opt->{bulk}; + my $url; if ( $part_svc->svcdb eq 'svc_external' #could be generalized && $opt->{'svc_external-skip_manual'} ) { - $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart"; + $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$query"; } else { $url = svc_url( 'm' => $m, 'action' => 'edit', 'part_svc' => $part_svc, - 'query' => $pkgnum_svcpart, + 'query' => $query, ); } + my $action = $opt->{bulk} ? 'Bulk provision' : 'Provision'; + my $link = qq!!. - emt("Provision [_1] ([_2])",$svc_nbsp,$num_avail).''; + emt("$action [_1] ([_2])",$svc_nbsp,$num_avail).''; if ( $opt->{'legacy_link'} && $curuser->access_right('View/link unlinked services') ) { $link .= '
'. - qq!!. + qq!!. emt("Link to legacy [_1] ([_2])",$svc_nbsp,$num_avail).''; } $link;