X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FItems.pm;h=365c1b365165978046a4b9301f413c424a0d1c41;hb=843aabf5c1ec7e02add37f4b801ec880de2a5f43;hp=1107db9e15a9cbfeda63ff2ea6c773a6e9c69a14;hpb=df5405c56e0f89dee44ed1cf1a3a761cf31efe3c;p=koha_gimpoz diff --git a/C4/Items.pm b/C4/Items.pm index 1107db9e15..365c1b3651 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -26,6 +26,7 @@ use C4::Context; use C4::Koha; use C4::Biblio; use C4::Dates qw/format_date format_date_in_iso/; +use C4::Search qw/SimpleSearch/; use MARC::Record; use C4::ClassSource; use C4::Log; @@ -653,7 +654,7 @@ sub CheckItemPreSave { # check for valid home branch if (exists $item_ref->{'homebranch'} and defined $item_ref->{'homebranch'}) { - my $branch_name = GetBranchName($item_ref->{'homebranch'}); + my $branch_name = C4::Branch::GetBranchName($item_ref->{'homebranch'}); unless (defined $branch_name) { # relies on fact that branches.branchname is a non-NULL column, # so GetBranchName returns undef only if branch does not exist @@ -663,7 +664,7 @@ sub CheckItemPreSave { # check for valid holding branch if (exists $item_ref->{'holdingbranch'} and defined $item_ref->{'holdingbranch'}) { - my $branch_name = GetBranchName($item_ref->{'holdingbranch'}); + my $branch_name = C4::Branch::GetBranchName($item_ref->{'holdingbranch'}); unless (defined $branch_name) { # relies on fact that branches.branchname is a non-NULL column, # so GetBranchName returns undef only if branch does not exist @@ -1185,14 +1186,17 @@ sub GetItemsInfo { items.notforloan as itemnotforloan, itemtypes.description, itemtypes.notforloan as notforloan_per_itemtype, - branchurl + holding.branchurl, + holding.branchname, + holding.opac_info as branch_opac_info FROM items - LEFT JOIN branches ON items.holdingbranch = branches.branchcode + LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode + LEFT JOIN branches AS home ON items.homebranch=home.branchcode LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); - $query .= " WHERE items.biblionumber = ? ORDER BY branches.branchname,items.dateaccessioned desc" ; + $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname,items.dateaccessioned desc" ; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); my $i = 0; @@ -2491,6 +2495,45 @@ sub GetItemHolds { } =head1 OTHER FUNCTIONS +=head2 _find_value + + ($indicators, $value) = _find_value($tag, $subfield, $record,$encoding); + +Find the given $subfield in the given $tag in the given +MARC::Record $record. If the subfield is found, returns +the (indicators, value) pair; otherwise, (undef, undef) is +returned. + +PROPOSITION : +Such a function is used in addbiblio AND additem and serial-edit and maybe could be used in Authorities. +I suggest we export it from this module. + +=cut + +sub _find_value { + my ( $tagfield, $insubfield, $record, $encoding ) = @_; + my @result; + my $indicator; + if ( $tagfield < 10 ) { + if ( $record->field($tagfield) ) { + push @result, $record->field($tagfield)->data(); + } else { + push @result, ""; + } + } else { + foreach my $field ( $record->field($tagfield) ) { + my @subfields = $field->subfields(); + foreach my $subfield (@subfields) { + if ( @$subfield[0] eq $insubfield ) { + push @result, @$subfield[1]; + $indicator = $field->indicator(1) . $field->indicator(2); + } + } + } + } + return ( $indicator, @result ); +} + =head2 PrepareItemrecordDisplay