X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fselect-state.html;h=8db157b9295426cbe39a87597163e6a0a0af1044;hp=9b358e24d206bf85812e9b8e98be3282c9bf29f2;hb=7b0bbc4117a7959b9f7b7b2cf999b8188ba34160;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html index 9b358e24d..8db157b92 100644 --- a/httemplate/elements/select-state.html +++ b/httemplate/elements/select-state.html @@ -2,7 +2,7 @@ Example: - include( '/elements/select-state.html', + <& /elements/select-state.html, #recommended country => $current_country, state => $current_state, @@ -15,7 +15,7 @@ Example: empty_label => 'all', #label for empty option disable_countyupdate => 0, #bool - disabled update of the select-state.html style => [ 'attribute:value', 'another:value' ], - ); + &> @@ -27,22 +27,21 @@ Example: > % unless ( $opt{'disable_empty'} ) { - % } % foreach my $state ( keys %states ) { - - % } - <%init> my %opt = @_; -foreach my $opt (qw( state country prefix onchange disabled empty_label )) { +foreach my $opt (qw( + state country prefix onchange disabled empty_label svcpart +)) { $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt}); } @@ -62,5 +61,23 @@ my $style = tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); +if ( $opt{'svcpart'} ) { + + my $part_svc = qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} } ); + if ( $part_svc && $part_svc->exporttype eq 'internal_diddb' ) { + + my $sth = dbh->prepare( + 'SELECT DISTINCT state FROM phone_avail WHERE svcnum IS NULL' + ) or die dbh->errstr; + $sth->execute or die $sth->errstr; + my %avail_states = map { $_->[0] => 1 } @{ $sth->fetchall_arrayref }; + + if ( %avail_states ) { + delete $states{$_} foreach grep ! $avail_states{$_}, keys %states; + } + + } +} +