416aa2bbe5f49559b620eaa500f7437105c87693
[koha.git] / Koha / Biblios.pm
1 package Koha::Biblios;
2
3 # Copyright ByWater Solutions 2015
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21
22
23 use Koha::Database;
24
25 use Koha::Biblio;
26 use Koha::Libraries;
27
28 use base qw(Koha::Objects);
29
30 =head1 NAME
31
32 Koha::Biblios - Koha Biblio object set class
33
34 =head1 API
35
36 =head2 Class methods
37
38 =head3 pickup_locations
39
40     my $biblios = Koha::Biblios->search(...);
41     my $pickup_locations = $biblios->pickup_locations({ patron => $patron });
42
43 For a given resultset, it returns all the pickup locations
44
45 =cut
46
47 sub pickup_locations {
48     my ( $self, $params ) = @_;
49
50     my $patron = $params->{patron};
51
52     my @pickup_locations;
53     foreach my $biblio ( $self->as_list ) {
54         push @pickup_locations,
55           $biblio->pickup_locations( { patron => $patron } )
56           ->_resultset->get_column('branchcode')->all;
57     }
58
59     return Koha::Libraries->search(
60         {
61             branchcode => \@pickup_locations
62         },
63         { order_by => ['branchname'] }
64     );
65 }
66
67 =head2 Internal methods
68
69 =head3 type
70
71 =cut
72
73 sub _type {
74     return 'Biblio';
75 }
76
77 =head3 object_class
78
79 =cut
80
81 sub object_class {
82     return 'Koha::Biblio';
83 }
84
85 =head1 AUTHOR
86
87 Kyle M Hall <kyle@bywatersolutions.com>
88
89 =cut
90
91 1;