# 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
# 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
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;
}
=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