5 include( '/elements/select-state.html',
7 country => $current_country,
8 state => $current_state,
11 prefix => $optional_unique_prefix,
12 onchange => $javascript,
14 disable_empty => 1, #defaults to 1, disable the empty option
15 empty_label => 'all', #label for empty option
16 disable_countyupdate => 0, #bool - disabled update of the select-state.html
17 style => [ 'attribute:value', 'another:value' ],
22 <SELECT NAME = "<% $pre %>state"
23 ID = "<% $pre %>state"
24 onChange = "<% $onchange %>"
25 <% $opt{'disabled'} %>
29 % unless ( $opt{'disable_empty'} ) {
30 <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %>
33 % foreach my $state ( keys %states ) {
35 <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %>
46 state country prefix onchange disabled empty_label svcpart
48 $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt});
51 $opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'});
53 my $pre = $opt{'prefix'};
56 ( $opt{'disable_countyupdate'} ? '' : $pre.'state_changed(this); ' ).
61 scalar(@{$opt{style}})
62 ? 'STYLE="'. join(';', @{$opt{style}}). '"'
65 tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} );
67 if ( $opt{'svcpart'} ) {
69 my $part_svc = qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} } );
70 if ( $part_svc && $part_svc->exporttype eq 'internal_diddb' ) {
72 my $sth = dbh->prepare(
73 'SELECT DISTINCT state FROM phone_avail WHERE svcnum IS NULL'
75 $sth->execute or die $sth->errstr;
76 my %avail_states = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref };
78 if ( %avail_states ) {
79 delete $states{$_} foreach grep ! $avail_states{$_}, keys %states;