Lines 443-453
Returns the related Koha::Items object for this biblio
Link Here
|
443 |
=cut |
443 |
=cut |
444 |
|
444 |
|
445 |
sub items { |
445 |
sub items { |
446 |
my ($self) = @_; |
446 |
my ($self,$params) = @_; |
447 |
|
447 |
|
448 |
my $items_rs = $self->_result->items; |
448 |
my $items_rs = $self->_result->items; |
449 |
|
449 |
|
450 |
return Koha::Items->_new_from_dbic( $items_rs ); |
450 |
return Koha::Items->_new_from_dbic( $items_rs ) unless $params->{host_items}; |
|
|
451 |
|
452 |
my $host_itemnumbers = $self->_host_itemnumbers(); |
453 |
my $params = { -or => [biblionumber => $self->id] }; |
454 |
push @{$params->{'-or'}}, itemnumber => { -in => $host_itemnumbers } if $host_itemnumbers; |
455 |
|
456 |
return Koha::Items->search($params); |
451 |
} |
457 |
} |
452 |
|
458 |
|
453 |
=head3 host_items |
459 |
=head3 host_items |
Lines 464-475
sub host_items {
Link Here
|
464 |
return Koha::Items->new->empty |
470 |
return Koha::Items->new->empty |
465 |
unless C4::Context->preference('EasyAnalyticalRecords'); |
471 |
unless C4::Context->preference('EasyAnalyticalRecords'); |
466 |
|
472 |
|
|
|
473 |
my $host_itemnumbers = $self->_host_itemnumbers; |
474 |
|
475 |
return Koha::Items->search( { itemnumber => { -in => $host_itemnumbers } } ); |
476 |
} |
477 |
|
478 |
=head3 _host_itemnumbers |
479 |
|
480 |
my $host_itemnumber = $biblio->_host_itemnumbers(); |
481 |
|
482 |
Return the itemnumbers for analytical items on this record |
483 |
|
484 |
=cut |
485 |
|
486 |
sub _host_itemnumbers { |
487 |
my ($self) = @_; |
488 |
|
467 |
my $marcflavour = C4::Context->preference("marcflavour"); |
489 |
my $marcflavour = C4::Context->preference("marcflavour"); |
468 |
my $analyticfield = '773'; |
490 |
my $analyticfield = '773'; |
469 |
if ( $marcflavour eq 'MARC21' ) { |
491 |
if ( $marcflavour eq 'UNIMARC' ) { |
470 |
$analyticfield = '773'; |
|
|
471 |
} |
472 |
elsif ( $marcflavour eq 'UNIMARC' ) { |
473 |
$analyticfield = '461'; |
492 |
$analyticfield = '461'; |
474 |
} |
493 |
} |
475 |
my $marc_record = $self->metadata->record; |
494 |
my $marc_record = $self->metadata->record; |
Lines 477-486
sub host_items {
Link Here
|
477 |
foreach my $field ( $marc_record->field($analyticfield) ) { |
496 |
foreach my $field ( $marc_record->field($analyticfield) ) { |
478 |
push @itemnumbers, $field->subfield('9'); |
497 |
push @itemnumbers, $field->subfield('9'); |
479 |
} |
498 |
} |
480 |
|
499 |
return \@itemnumbers; |
481 |
return Koha::Items->search( { itemnumber => { -in => \@itemnumbers } } ); |
|
|
482 |
} |
500 |
} |
483 |
|
501 |
|
|
|
502 |
|
484 |
=head3 itemtype |
503 |
=head3 itemtype |
485 |
|
504 |
|
486 |
my $itemtype = $biblio->itemtype(); |
505 |
my $itemtype = $biblio->itemtype(); |