X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FItems.pm;h=676c91b37ef3b2c6139d1bc2070c1b4b344c83bb;hb=adb3777e2e4940a842e0d33a22121b1db762aeba;hp=1107db9e15a9cbfeda63ff2ea6c773a6e9c69a14;hpb=5baff558a53fabb7b719bf627064cf2c1680f246;p=koha_gimpoz diff --git a/C4/Items.pm b/C4/Items.pm index 1107db9e15..676c91b37e 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -653,7 +653,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 +663,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 +1185,15 @@ sub GetItemsInfo { items.notforloan as itemnotforloan, itemtypes.description, itemtypes.notforloan as notforloan_per_itemtype, - branchurl + holding.branchurl 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 +2492,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