X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fselect-state.html;h=7606e25273223a2880fc1a526a8046838cb01740;hb=609e7cb967020e23f147f4e1b475fed97e37db30;hp=2d60fde0f0f031ae02201e58b3f5ec5883a7b4b5;hpb=b5c4237a34aef94976bc343c8d9e138664fc3984;p=freeside.git diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html index 2d60fde0f..7606e2527 100644 --- a/httemplate/elements/select-state.html +++ b/httemplate/elements/select-state.html @@ -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; + } + + } +} +