From b7270536e42ced349fdbf72d63c795f4d4eb6384 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 19 Nov 2009 23:47:50 +0100 Subject: [PATCH] MT 2309, Follow-up : Display item location codes in item adding Conflicts solved cataloguing/additem.pl --- cataloguing/additem.pl | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 20007dae13..d61892db73 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -355,7 +355,6 @@ foreach my $subfield_code (sort keys(%witness)) { # now, build the item form for entering a new item my @loop_data =(); my $i=0; -my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib"); my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later. my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); @@ -461,15 +460,28 @@ foreach my $tag (sort keys %{$tagslib}) { } else { push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); - $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} ); + + # Are we dealing with item location ? + my $item_location = ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) ? 1 : 0; + + # If so, we sort by authorised_value, else by libelle + my $orderby = $item_location ? 'authorised_value' : 'lib'; + + my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY $orderby"); + + $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value}); + + while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { - push @authorised_values, $value; - - if ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) { - $authorised_lib{$value} = $value . " - " . $lib; - } else { - $authorised_lib{$value} = $lib; - } + push @authorised_values, $value; + if ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) { + $authorised_lib{$value} = $value . " - " . $lib; + } else { + $authorised_lib{$value} = $lib; + } + + # For item location, we show the code and the libelle + $authorised_lib{$value} = ($item_location) ? $value . " - " . $lib : $lib; } } $subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list -- 2.39.5