From 9c7dee35f91a386fcce14cb6c3e9d23ba3eee8af Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 28 Jun 2008 23:03:10 +0000 Subject: [PATCH] get DIDs from globalpops --- FS/FS/Record.pm | 5 +- FS/FS/part_export/globalpops_voip.pm | 175 ++++++++++++++++++++++++++++ FS/FS/part_svc.pm | 13 +++ httemplate/edit/cust_main/select-state.html | 24 +--- httemplate/edit/elements/svc_Common.html | 4 +- httemplate/edit/svc_phone.cgi | 8 +- httemplate/elements/input-text.html | 44 +++++++ httemplate/elements/select-areacode.html | 91 +++++++++++++++ httemplate/elements/select-did.html | 80 +++++++++++++ httemplate/elements/select-exchange.html | 86 ++++++++++++++ httemplate/elements/select-phonenum.html | 84 +++++++++++++ httemplate/elements/select-state.html | 24 ++++ httemplate/elements/tr-input-text.html | 44 +------ httemplate/elements/tr-select-did.html | 23 ++++ httemplate/images/wait-orange.gif | Bin 0 -> 1849 bytes httemplate/misc/areacodes.cgi | 24 ++++ httemplate/misc/exchanges.cgi | 24 ++++ httemplate/misc/phonenums.cgi | 29 +++++ 18 files changed, 713 insertions(+), 69 deletions(-) create mode 100644 httemplate/elements/input-text.html create mode 100644 httemplate/elements/select-areacode.html create mode 100644 httemplate/elements/select-did.html create mode 100644 httemplate/elements/select-exchange.html create mode 100644 httemplate/elements/select-phonenum.html create mode 100644 httemplate/elements/select-state.html create mode 100644 httemplate/elements/tr-select-did.html create mode 100644 httemplate/images/wait-orange.gif create mode 100644 httemplate/misc/areacodes.cgi create mode 100644 httemplate/misc/exchanges.cgi create mode 100644 httemplate/misc/phonenums.cgi diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index cc485a8f1..cd54b849f 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -6,6 +6,7 @@ use vars qw( $AUTOLOAD @ISA @EXPORT_OK $DEBUG %virtual_fields_cache $nowarn_identical $no_update_diff ); use Exporter; use Carp qw(carp cluck croak confess); +use Scalar::Util qw( blessed ); use File::CounterFile; use Locale::Country; use DBI qw(:sql_types); @@ -665,11 +666,11 @@ sub AUTOLOAD { $field =~ s/.*://; if ( defined($value) ) { confess "errant AUTOLOAD $field for $self (arg $value)" - unless ref($self) && $self->can('setfield'); + unless blessed($self) && $self->can('setfield'); $self->setfield($field,$value); } else { confess "errant AUTOLOAD $field for $self (no args)" - unless ref($self) && $self->can('getfield'); + unless blessed($self) && $self->can('getfield'); $self->getfield($field); } } diff --git a/FS/FS/part_export/globalpops_voip.pm b/FS/FS/part_export/globalpops_voip.pm index c641e0404..13c263b9a 100644 --- a/FS/FS/part_export/globalpops_voip.pm +++ b/FS/FS/part_export/globalpops_voip.pm @@ -24,6 +24,181 @@ END sub rebless { shift; } +sub get_dids { + my $self = shift; + my %opt = ref($_[0]) ? %{$_[0]} : @_; + + my %search = (); + # 'orderby' => 'npa', #but it doesn't seem to work :/ + + if ( $opt{'areacode'} && $opt{'exchange'} ) { #return numbers + %getdids = ( 'npa' => $opt{'areacode'}, + 'nxx' => $opt{'exchange'}, + ); + } elsif ( $opt{'areacode'} ) { #return city (npa-nxx-XXXX) + %getdids = ( 'npa' => $opt{'areacode'} ); + } elsif ( $opt{'state'} ) { + %getdids = ( 'state' => $opt{'state'} ); + } + + my $dids = $self->gp_command('getDIDs', %getdids); + + #use Data::Dumper; + #warn Dumper($dids); + + my $search = $dids->{'search'}; + + #warn Dumper($search); + + if ( $search->{'statuscode'} == 302200 ) { + return []; + } elsif ( $search->{'statuscode'} != 100 ) { + die "Error running globalpop getDIDs: ". + $search->{'statuscode'}. ': '. $search->{'status'}; #die?? + } + + my @return = (); + + #my $latas = $search->{state}{lata}; + + my %latas; + if ( grep $search->{state}{lata}{$_}, qw(name rate_center) ) { + %latas = map $search->{state}{lata}{$_}, + qw(name rate_center); + } else { + %latas = %{ $search->{state}{lata} }; + } + + foreach my $lata ( keys %latas ) { + + #warn "LATA $lata"; + + #my $l = $latas{$lata}; + #$l = $l->{rate_center} if exists $l->{rate_center}; + + my $lata_dids = $self->gp_command('getDIDs', %getdids, 'lata'=>$lata); + my $lata_search = $lata_dids->{'search'}; + unless ( $lata_search->{'statuscode'} == 100 ) { + die "Error running globalpop getDIDs: ". $lata_search->{'status'}; #die?? + } + + my $l = $lata_search->{state}{lata}{'rate_center'}; + + #use Data::Dumper; + #warn Dumper($l); + + my %rate_center; + if ( grep $l->{$_}, qw(name friendlyname) ) { + %rate_center = map $l->{$_}, + qw(name friendlyname); + } else { + %rate_center = %$l; + } + + foreach my $rate_center ( keys %rate_center ) { + + #warn "rate center $rate_center"; + + my $rc = $rate_center{$rate_center}; + $rc = $rc->{friendlyname} if exists $rc->{friendlyname}; + + my @r = (); + if ( exists($rc->{npa}) ) { + @r = ($rc); + } else { + @r = map { { 'name'=>$_, %{ $rc->{$_} } }; } keys %$rc + } + + foreach my $r (@r) { + + my @npa = (); + if ( exists($r->{npa}{name}) ) { + @npa = ($r->{npa}) + } else { + @npa = map { { 'name'=>$_, %{ $r->{npa}{$_} } } } keys %{ $r->{npa} }; + } + + foreach my $npa (@npa) { + + if ( $opt{'areacode'} && $opt{'exchange'} ) { #return numbers + + #warn Dumper($npa); + + my $tn = $npa->{nxx}{tn} || $npa->{nxx}{$opt{'exchange'}}{tn}; + + my @tn = ref($tn) ? @$tn : ($tn); + #push @return, @tn; + push @return, map { + if ( /^\s*(\d{3})(\d{3})(\d{4})\s*$/ ) { + "$1-$2-$3"; + } else { + $_; + } + } + @tn; + + } elsif ( $opt{'areacode'} ) { #return city (npa-nxx-XXXX) + + if ( $npa->{nxx}{name} ) { + @nxx = ( $npa->{nxx}{name} ); + } else { + @nxx = keys %{ $npa->{nxx} }; + } + + push @return, map { $r->{name}. ' ('. $npa->{name}. "-$_-XXXX)"; } + @nxx; + + } elsif ( $opt{'state'} ) { #and not other things, then return areacode + #my $ac = $npa->{name}; + #use Data::Dumper; + #warn Dumper($r) unless length($ac) == 3; + + push @return, $npa->{name} + unless grep { $_ eq $npa->{name} } @return; + + } else { + warn "WARNING: returning nothing for get_dids without known options"; #? + } + + } #foreach my $npa + + } #foreach my $r + + } #foreach my $rate_center + + } #foreach my $lata + + if ( $opt{'areacode'} && $opt{'exchange'} ) { #return numbers + @return = sort { $a cmp $b } @return; #string comparison actually dwiw + } elsif ( $opt{'areacode'} ) { #return city (npa-nxx-XXXX) + @return = sort { lc($a) cmp lc($b) } @return; + } elsif ( $opt{'state'} ) { #and not other things, then return areacode + #@return = sort { (split(' ', $a))[0] <=> (split(' ', $b))[0] } @return; + @return = sort { $a <=> $b } @return; + } else { + warn "WARNING: returning nothing for get_dids without known options"; #? + } + + \@return; + +} + +sub gp_command { + my( $self, $command, @args ) = @_; + + eval "use Net::GlobalPOPs::MediaServicesAPI;"; + die $@ if $@; + + my $gp = Net::GlobalPOPs::MediaServicesAPI->new( + 'login' => $self->option('login'), + 'password' => $self->option('password'), + #'debug' => $debug, + ); + + $gp->$command(@args); +} + + sub _export_insert { my( $self, $svc_phone ) = (shift, shift); #we want to provision and catch errors now, not queue diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 4fae457e2..580038be2 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -425,6 +425,19 @@ sub part_export_usage { grep $_->can('usage_sessions'), $self->part_export; } +=item part_export_did + +Returns a list of any exports (see L) for this service that +are capable of returing available DID (phone number) information. + +=cut + +sub part_export_did { + my $self = shift; + grep $_->can('get_dids'), $self->part_export; +} + + =item cust_svc [ PKGPART ] Returns a list of associated customer services (FS::cust_svc records). diff --git a/httemplate/edit/cust_main/select-state.html b/httemplate/edit/cust_main/select-state.html index 4f1c056b5..ce08443e4 100644 --- a/httemplate/edit/cust_main/select-state.html +++ b/httemplate/edit/cust_main/select-state.html @@ -1,24 +1,4 @@ - - +<% include('/elements/select-state.html', @_) %> <%init> -my %opt = @_; -foreach my $opt (qw( county state country prefix onchange disabled empty )) { - $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); -} - -tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); +warn "cust_main/select-state.html depreated; use /elements/select-state.html instead"; - diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html index b6737c14a..4355cb4cd 100644 --- a/httemplate/edit/elements/svc_Common.html +++ b/httemplate/edit/elements/svc_Common.html @@ -28,6 +28,8 @@ $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart }); die "No part_svc entry!" unless $part_svc; + + $svc_x->setfield('svcpart', $svcpart); }, 'edit_callback' => sub { @@ -43,7 +45,7 @@ die "No part_svc entry!" unless $part_svc; }, - 'new_hash_callback' => sub { + 'new_hashref_callback' => sub { #my( $cgi, $svc_x ) = @_; { svcpart => $svcpart }; diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index 958558b46..109fba228 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -1,7 +1,13 @@ <% include( 'elements/svc_Common.html', 'name' => 'Phone number', 'table' => 'svc_phone', - 'fields' => [qw( countrycode phonenum pin )], + 'fields' => [ 'countrycode', + { field => 'phonenum', + type => 'select-did', + label => 'Phone number', + }, + 'pin', + ], 'labels' => { 'countrycode' => 'Country code', 'phonenum' => 'Phone number', diff --git a/httemplate/elements/input-text.html b/httemplate/elements/input-text.html new file mode 100644 index 000000000..9db064348 --- /dev/null +++ b/httemplate/elements/input-text.html @@ -0,0 +1,44 @@ +<% $opt{'prefix'} %> + <% $maxlength %> + <% $style %> + <% $opt{disabled} %> + <% $onchange %> + ><% $opt{'postfix'} %> +<%init> + +my %opt = @_; + +my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value}; + +my $onchange = $opt{'onchange'} + ? 'onChange="'. $opt{'onchange'}. '(this)"' + : ''; + +my $size = $opt{'size'} + ? 'SIZE="'. $opt{'size'}. '"' + : ''; + +my $maxlength = $opt{'maxlength'} + ? 'MAXLENGTH="'. $opt{'maxlength'}. '"' + : ''; + +$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt ) + if ref($opt{'disabled'}) eq 'CODE'; +$opt{'disabled'} = 'DISABLED' + if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah? + +my @style = (); + +push @style, 'text-align: '. $opt{'text-align'} + if $opt{'text-align'}; + +push @style, 'background-color: #dddddd' + if $opt{'disabled'}; + +my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : ''; + + diff --git a/httemplate/elements/select-areacode.html b/httemplate/elements/select-areacode.html new file mode 100644 index 000000000..aa2d73b65 --- /dev/null +++ b/httemplate/elements/select-areacode.html @@ -0,0 +1,91 @@ +<% include('/elements/xmlhttp.html', + 'url' => $p.'misc/areacodes.cgi', + 'subs' => [ $opt{'prefix'}. 'get_areacodes' ], + ) +%> + + + + + + + + + +<%init> + +my %opt = @_; + +$opt{disabled} = 'disabled' unless exists $opt{disabled}; + + diff --git a/httemplate/elements/select-did.html b/httemplate/elements/select-did.html new file mode 100644 index 000000000..999274fea --- /dev/null +++ b/httemplate/elements/select-did.html @@ -0,0 +1,80 @@ +<%doc> + +Example: + + include('/elements/select-did.html', + 'field' => 'phonenum', + 'svcpart' => 5, + ); + + +% if ( $use_selector ) { + + + + + + + + + + + + + + + + + +
+ <% include('/elements/select-state.html', + 'country' => $country, + 'empty' => 'Select state', + ) + %> + + <% include('/elements/select-areacode.html', + 'svcpart' => $svcpart, + 'empty' => 'Select area code', + ) + %> + + <% include('/elements/select-exchange.html', + 'svcpart' => $svcpart, + 'empty' => 'Select exchange', + ) + %> + + <% include('/elements/select-phonenum.html', + 'svcpart' => $svcpart, + 'empty' => 'Select phone number', + ) + %> +
StateArea codeCity / ExchangePhone number
+ +% } else { + + <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %> + +% } +<%init> + +my %opt = @_; + +my $conf = new FS::Conf; +my $country = $conf->config('countrydefault') || 'US'; + +#XXX make sure this comes through on errors too +my $svcpart = $opt{'object'}->svcpart; + +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"; +} + +my $use_selector = scalar(@exports) ? 1 : 0; + + diff --git a/httemplate/elements/select-exchange.html b/httemplate/elements/select-exchange.html new file mode 100644 index 000000000..012e7c6b7 --- /dev/null +++ b/httemplate/elements/select-exchange.html @@ -0,0 +1,86 @@ +<% include('/elements/xmlhttp.html', + 'url' => $p.'misc/exchanges.cgi', + 'subs' => [ $opt{'prefix'}. 'get_exchanges' ], + ) +%> + + + + + + + + + +<%init> + +my %opt = @_; + +$opt{disabled} = 'disabled' unless exists $opt{disabled}; + + diff --git a/httemplate/elements/select-phonenum.html b/httemplate/elements/select-phonenum.html new file mode 100644 index 000000000..99ddafc42 --- /dev/null +++ b/httemplate/elements/select-phonenum.html @@ -0,0 +1,84 @@ +<% include('/elements/xmlhttp.html', + 'url' => $p.'misc/phonenums.cgi', + 'subs' => [ $opt{'prefix'}. 'get_phonenums' ], + ) +%> + + + + + + + + + +<%init> + +my %opt = @_; + +$opt{disabled} = 'disabled' unless exists $opt{disabled}; + + diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html new file mode 100644 index 000000000..4f1c056b5 --- /dev/null +++ b/httemplate/elements/select-state.html @@ -0,0 +1,24 @@ + + +<%init> +my %opt = @_; +foreach my $opt (qw( county state country prefix onchange disabled empty )) { + $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_}); +} + +tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); + + diff --git a/httemplate/elements/tr-input-text.html b/httemplate/elements/tr-input-text.html index f71f2f7fb..14f1425df 100644 --- a/httemplate/elements/tr-input-text.html +++ b/httemplate/elements/tr-input-text.html @@ -1,19 +1,6 @@ <% include('tr-td-label.html', @_ ) %> - > - - <% $opt{'prefix'} %> - <% $maxlength %> - <% $style %> - <% $opt{disabled} %> - <% $onchange %> - ><% $opt{'postfix'} %> - - + ><% include('input-text.html', @_ ) %> @@ -21,35 +8,6 @@ my %opt = @_; -my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value}; - -my $onchange = $opt{'onchange'} - ? 'onChange="'. $opt{'onchange'}. '(this)"' - : ''; - -my $size = $opt{'size'} - ? 'SIZE="'. $opt{'size'}. '"' - : ''; - -my $maxlength = $opt{'maxlength'} - ? 'MAXLENGTH="'. $opt{'maxlength'}. '"' - : ''; - -$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt ) - if ref($opt{'disabled'}) eq 'CODE'; -$opt{'disabled'} = 'DISABLED' - if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah? - -my @style = (); - -push @style, 'text-align: '. $opt{'text-align'} - if $opt{'text-align'}; - -push @style, 'background-color: #dddddd' - if $opt{'disabled'}; - -my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : ''; - my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; diff --git a/httemplate/elements/tr-select-did.html b/httemplate/elements/tr-select-did.html new file mode 100644 index 000000000..29c5bb7dd --- /dev/null +++ b/httemplate/elements/tr-select-did.html @@ -0,0 +1,23 @@ +<% include('tr-td-label.html', @_ ) %> + +% if ( $opt{'curr_value'} ne '' ) { + + ><% $opt{'formatted_value'} || $opt{'curr_value'} || $opt{'value'} |h %> + +% } else { + + > + <% include('/elements/select-did.html', %opt ) %> + + +% } + + + +<%init> + +my %opt = @_; + +my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; + + diff --git a/httemplate/images/wait-orange.gif b/httemplate/images/wait-orange.gif new file mode 100644 index 0000000000000000000000000000000000000000..92c7f347649c40ae07f14370515a3f43211475cb GIT binary patch literal 1849 zcmb8wX;4#F8wc>~z31lM+$A|gq#;r#grG@COxQvcYi|Mw0;PZoElWwnP(wij6`?I6 zSrCG(O0`(6+ENQ5EsHwch#2W;TWw|P^nJU{s}6lfTiZfc?Q~1{&`;@yJ|EAVGv_z| z=R9-L*RM0IvOokPKO)HG%a{M`M?SbTb#r3d%sUfvCk$VXTKp?_hSvRjG~)BO+W+f) z?$^Wcf3NTQy&wDGrI_0z8<2lfk$=)TX&X1B7<1F&R_d@t{Ga@|KFZoW1 zCeB+%u@k9IAN)Tjee7(g@%AHkdvXW3`PXHeT+WHSDENvS%C&mFv-l&cTLYiWMvn&cFc?i1&G$#UH{6QK0WFk#lBZFCX1}rwtx~ePHNWN=? z9pmlO^HYKl?Qpo+zEv*nOtD0BQoQ5hZF|NLNgjct4U_9ohp%pfCltCCHAJ=GEC9Zh z=e}_7c{H@5D+FYtWikw>>{PtTRp>*?r}C{)jE=lwZSn9 zxqOn~$G9WOjCtAnDpB`R`f6UcmUE4@X#`N@NN9!tzc6Hn34)INm|x!3h=`-N&e%uD zORtz`auo;kr0d49Ba*pI+TWynl2)mKTL~~ljJ8x(^>B-JkIMK&@9zEWbXH$Sd#SNW zuRo>_noHF}i^PFkWaP#9WqwNQQkt3cBADi5gDwMzoMX)oDbE03xSo}QJ10B)|($}@l-TL?eiSa z_wA1g3TO%d-cb7iP8sQ%mrSduJ;{tce7s~q;17TQSCdWlA zJ9pptGonz5Huk&?OMq=Y^JKw@!~-zXO>Y4ZvUR)MvT}mJEjczVLzEJXQrW2?NF>`@ zwVO}S)wW#-AlPbaaZFIsQvuR?=qLGPE`r&Yc|SyI}S18xVGu25tzzh zvNe*Ie()}qkV&>&4_dJTMZFjTs?OFT1dFJ_t@C`Vcsi?XJ-_A z5pij9^nNLzNnSLy79&^^rx_|v1qdP9j`D;y70uV;_-fc6Bge3v!8LV(SF@n0Dn2Q{ zL5*j^n&OvyHB5ZJIj{JxAaSwd?&@$s`?GUk{UedOsaj*ILCmD=9PW8H6#qOUx55_U zowXr(eW2TA%;oG$VG56pPDR*U9t6U?1U-ZMF|4iJhC(u@QdiHqmBB~q?=G!mYP^G# zIvu57&4fs;;y0rK&-yA7DFK~nPLt3IcwB3)&keWZWO{&9!fn|4tfu+U~8U`Q(Qok9QcS9 F>MwO18Eyao literal 0 HcmV?d00001 diff --git a/httemplate/misc/areacodes.cgi b/httemplate/misc/areacodes.cgi new file mode 100644 index 000000000..69c9573c3 --- /dev/null +++ b/httemplate/misc/areacodes.cgi @@ -0,0 +1,24 @@ +%# [ <% join(', ', map { qq("$_") } @areacodes) %> ] +<% objToJson(\@areacodes) %> +<%init> + +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 $something = $export->get_dids('state'=>$state); + +#warn Dumper($something); + +my @areacodes = @{ $something }; + + diff --git a/httemplate/misc/exchanges.cgi b/httemplate/misc/exchanges.cgi new file mode 100644 index 000000000..f5860cff2 --- /dev/null +++ b/httemplate/misc/exchanges.cgi @@ -0,0 +1,24 @@ +%# [ <% join(', ', map { qq("$_") } @exchanges) %> ] +<% objToJson(\@exchanges) %> +<%init> + +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 $something = $export->get_dids('areacode'=>$areacode); + +#warn Dumper($something); + +my @exchanges = @{ $something }; + + diff --git a/httemplate/misc/phonenums.cgi b/httemplate/misc/phonenums.cgi new file mode 100644 index 000000000..2ed0f617d --- /dev/null +++ b/httemplate/misc/phonenums.cgi @@ -0,0 +1,29 @@ +%# [ <% join(', ', map { qq("$_") } @exchanges) %> ] +<% objToJson(\@exchanges) %> +<%init> + +my( $exchangestring, $svcpart ) = $cgi->param('arg'); + +$exchangestring =~ /\((\d{3})-(\d{3})-XXXX\)\s*$/i + or die "unparsable exchange: $exchangestring"; +my( $areacode, $exchange ) = ( $1, $2 ); +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 $something = $export->get_dids('areacode'=>$areacode, + 'exchange'=>$exchange, + ); + +#warn Dumper($something); + +my @exchanges = @{ $something }; + + -- 2.11.0