>
% unless ( $opt{'disable_empty'} ) {
- <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %>
+ <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %></OPTION>
% }
% foreach my $state ( keys %states ) {
-
- <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %>
-
+ <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %></OPTION>
% }
-
</SELECT>
<%init>
if ( $opt{'svcpart'} ) {
- 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 };
+ 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;
+ }
- delete $states{$_} foreach grep ! $avail_states{$_}, keys %states;
+ }
}
</%init>