Bug 30650: Koha classes
[koha.git] / Koha / CurbsidePickup.pm
1 package Koha::CurbsidePickup;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 use Modern::Perl;
19
20 use Carp;
21
22 use Koha::Database;
23
24 use base qw(Koha::Object);
25
26 use Koha::Patron;
27 use Koha::Library;
28 use Koha::CurbsidePickupIssues;
29
30 =head1 NAME
31
32 Koha::CurbsidePickup - Koha Curbside Pickup Object class
33
34 =head1 API
35
36 =head2 Class methods
37
38 =head3 checkouts
39
40 Return the checkouts linked to this pickup
41
42 =cut
43
44 sub checkouts {
45     my ( $self ) = @_;
46
47     my @pi = Koha::CurbsidePickupIssues->search({ curbside_pickup_id => $self->id })->as_list;
48
49     my @checkouts = map { $_->checkout } @pi;
50     @checkouts = grep { defined $_ } @checkouts;
51
52     return @checkouts;
53 }
54
55 =head3 patron
56
57 Return the patron linked to this pickup
58
59 =cut
60
61 sub patron {
62     my ( $self ) = @_;
63     my $rs = $self->_result->borrowernumber;
64     return unless $rs;
65     return Koha::Patron->_new_from_dbic( $rs );
66 }
67
68 =head3 staged_by_staff
69
70 Return the staff member that staged this pickup
71
72 =cut
73
74 sub staged_by_staff {
75     my ( $self ) = @_;
76     my $rs = $self->_result->staged_by;
77     return unless $rs;
78     return Koha::Patron->_new_from_dbic( $rs );
79 }
80
81 =head3 library
82
83 Return the branch associated with this pickup
84
85 =cut
86
87 sub library {
88     my ( $self ) = @_;
89     my $rs = $self->_result->branchcode;
90     return unless $rs;
91     return Koha::Library->_new_from_dbic( $rs );
92 }
93
94 =head2 Internal methods
95
96 =head3 _type
97
98 =cut
99
100 sub _type {
101     return 'CurbsidePickup';
102 }
103
104 1;