Bug 16686: Fix "Item in transit from since" in Holds tab
[koha.git] / Koha / Biblio.pm
1 package Koha::Biblio;
2
3 # Copyright ByWater Solutions 2014
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 use Modern::Perl;
21
22 use Carp;
23
24 use C4::Biblio qw( GetRecordValue GetMarcBiblio GetFrameworkCode );
25
26 use Koha::Database;
27
28 use base qw(Koha::Object);
29
30 =head1 NAME
31
32 Koha::Biblio - Koha Biblio Object class
33
34 =head1 API
35
36 =head2 Class Methods
37
38 =cut
39
40 =head3 subtitles
41
42 my @subtitles = $biblio->subtitles();
43
44 Returns list of subtitles for a record.
45
46 Keyword to MARC mapping for subtitle must be set for this method to return any possible values.
47
48 =cut
49
50 sub subtitles {
51     my ( $self ) = @_;
52
53     return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
54 }
55
56 =head3 items
57
58 Returns the related Koha::Items object for this biblio in scalar context,
59 or list of Koha::Item objects in list context.
60
61 =cut
62
63 sub items {
64     my ($self) = @_;
65
66     $self->{_items} ||= Koha::Items->search( { biblionumber => $self->biblionumber() } );
67
68     return wantarray ? $self->{_items}->as_list : $self->{_items};
69 }
70
71 =head3 type
72
73 =cut
74
75 sub _type {
76     return 'Biblio';
77 }
78
79 =head1 AUTHOR
80
81 Kyle M Hall <kyle@bywatersolutions.com>
82
83 =cut
84
85 1;