summaryrefslogtreecommitdiff
path: root/httemplate/misc/phonenums.cgi
diff options
context:
space:
mode:
authorivan <ivan>2011-08-10 05:22:32 +0000
committerivan <ivan>2011-08-10 05:22:32 +0000
commit424ae31847c4fd44e6ed55ec275c8e668c7d2b51 (patch)
tree96455a553e39b85eda278a78f29d0042da26e7c5 /httemplate/misc/phonenums.cgi
parent9694a17150af02e8fa3e61f732b776c5f7389874 (diff)
multiple DID provisioning, RT#13721
Diffstat (limited to 'httemplate/misc/phonenums.cgi')
-rw-r--r--httemplate/misc/phonenums.cgi56
1 files changed, 31 insertions, 25 deletions
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 };
+
+}
</%init>