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/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 ++++++++ 8 files changed, 433 insertions(+), 43 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 (limited to 'httemplate/elements') 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'}. '"' : ''; + + -- cgit v1.2.1