Lines 169-174
sub generate_subfield_form {
Link Here
|
169 |
if ( $subfield->{authorised_value} ) { |
169 |
if ( $subfield->{authorised_value} ) { |
170 |
my @authorised_values; |
170 |
my @authorised_values; |
171 |
my %authorised_lib; |
171 |
my %authorised_lib; |
|
|
172 |
my %restricted_values; |
172 |
|
173 |
|
173 |
# builds list, depending on authorised value... |
174 |
# builds list, depending on authorised value... |
174 |
if ( $subfield->{authorised_value} eq "LOST" ) { |
175 |
if ( $subfield->{authorised_value} eq "LOST" ) { |
Lines 202-217
sub generate_subfield_form {
Link Here
|
202 |
} |
203 |
} |
203 |
} elsif ( $subfield->{authorised_value} eq "itemtypes" ) { |
204 |
} elsif ( $subfield->{authorised_value} eq "itemtypes" ) { |
204 |
push @authorised_values, ""; |
205 |
push @authorised_values, ""; |
205 |
my $itemtypes; |
206 |
my $all_itemtypes = Koha::ItemTypes->search_with_localization; |
|
|
207 |
my $filtered_itemtypes; |
206 |
if ($branch_limit) { |
208 |
if ($branch_limit) { |
207 |
$itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } ); |
209 |
$filtered_itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } ); |
208 |
} else { |
210 |
} else { |
209 |
$itemtypes = Koha::ItemTypes->search_with_localization; |
211 |
$filtered_itemtypes = $all_itemtypes; |
210 |
} |
212 |
} |
211 |
while ( my $itemtype = $itemtypes->next ) { |
213 |
while (my $itemtype = $filtered_itemtypes->next) { |
212 |
push @authorised_values, $itemtype->itemtype; |
214 |
push @authorised_values, $itemtype->itemtype; |
213 |
$authorised_lib{ $itemtype->itemtype } = $itemtype->translated_description; |
215 |
$authorised_lib{ $itemtype->itemtype } = $itemtype->translated_description; |
214 |
} |
216 |
} |
|
|
217 |
while (my $itemtype = $all_itemtypes->next) { |
218 |
if (!grep { $_ eq $itemtype->itemtype } @authorised_values) { |
219 |
$restricted_values{ $itemtype->itemtype } = $itemtype->translated_description; |
220 |
} |
221 |
} |
215 |
|
222 |
|
216 |
if ( !$value && $biblionumber ) { |
223 |
if ( !$value && $biblionumber ) { |
217 |
my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
224 |
my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
Lines 245-254
sub generate_subfield_form {
Link Here
|
245 |
#---- "true" authorised value |
252 |
#---- "true" authorised value |
246 |
} else { |
253 |
} else { |
247 |
push @authorised_values, qq{}; |
254 |
push @authorised_values, qq{}; |
248 |
my $av = GetAuthorisedValues( $subfield->{authorised_value} ); |
255 |
my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } ); |
249 |
for my $r (@$av) { |
256 |
for my $r (@$av) { |
250 |
push @authorised_values, $r->{authorised_value}; |
257 |
push @authorised_values, $r->{authorised_value}; |
251 |
$authorised_lib{ $r->{authorised_value} } = $r->{lib}; |
258 |
$authorised_lib{ $r->{authorised_value} } = $r->{lib}; |
|
|
259 |
$restricted_values{ $r->{authorised_value} } = $r->{restricted}; |
252 |
} |
260 |
} |
253 |
} |
261 |
} |
254 |
|
262 |
|
Lines 266-276
sub generate_subfield_form {
Link Here
|
266 |
}; |
274 |
}; |
267 |
} else { |
275 |
} else { |
268 |
$subfield_data{marc_value} = { |
276 |
$subfield_data{marc_value} = { |
269 |
type => 'select', |
277 |
type => 'select', |
270 |
id => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield, |
278 |
id => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield, |
271 |
values => \@authorised_values, |
279 |
values => \@authorised_values, |
272 |
labels => \%authorised_lib, |
280 |
labels => \%authorised_lib, |
273 |
default => $value, |
281 |
restricted => \%restricted_values, |
|
|
282 |
default => $value, |
274 |
( |
283 |
( |
275 |
( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) ) |
284 |
( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) ) |
276 |
? () |
285 |
? () |
Lines 278-283
sub generate_subfield_form {
Link Here
|
278 |
), |
287 |
), |
279 |
}; |
288 |
}; |
280 |
} |
289 |
} |
|
|
290 |
|
281 |
} |
291 |
} |
282 |
|
292 |
|
283 |
# it's a thesaurus / authority field |
293 |
# it's a thesaurus / authority field |