From 9c7dee35f91a386fcce14cb6c3e9d23ba3eee8af Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 28 Jun 2008 23:03:10 +0000 Subject: get DIDs from globalpops --- 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 +++++++++ 15 files changed, 522 insertions(+), 67 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 (limited to 'httemplate') 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 000000000..92c7f3476 Binary files /dev/null and b/httemplate/images/wait-orange.gif differ 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 }; + + -- cgit v1.2.1