Bug 14632: Add Copyright for the Koha Dev Team
[koha.git] / Koha / Hold.pm
blob881c4e4cf625d9e59ff25be2ffba1ff48e0f98b3
1 package Koha::Hold;
3 # Copyright ByWater Solutions 2014
5 # This file is part of Koha.
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.
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.
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.
20 use Modern::Perl;
22 use Carp;
24 use C4::Context qw(preference);
25 use Koha::Branches;
26 use Koha::Biblios;
27 use Koha::Items;
28 use Koha::DateUtils qw(dt_from_string);
30 use base qw(Koha::Object);
32 =head1 NAME
34 Koha::Hold - Koha Hold object class
36 =head1 API
38 =head2 Class Methods
40 =cut
42 =head3 waiting_expires_on
44 Returns a DateTime for the date a waiting holds expires on.
45 Returns undef if the system peference ReservesMaxPickUpDelay is not set.
46 Returns undef if the hold is not waiting ( found = 'W' ).
48 =cut
50 sub waiting_expires_on {
51 my ($self) = @_;
53 my $found = $self->found;
54 return unless $found && $found eq 'W';
56 my $ReservesMaxPickUpDelay = C4::Context->preference('ReservesMaxPickUpDelay');
57 return unless $ReservesMaxPickUpDelay;
59 my $dt = dt_from_string( $self->waitingdate() );
61 $dt->add( days => $ReservesMaxPickUpDelay );
63 return $dt;
66 =head3 is_waiting
68 Returns true if hold is a waiting hold
70 =cut
72 sub is_waiting {
73 my ($self) = @_;
75 my $found = $self->found;
76 return $found && $found eq 'W';
79 =head3 biblio
81 Returns the related Koha::Biblio object for this hold
83 =cut
85 sub biblio {
86 my ($self) = @_;
88 $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() );
90 return $self->{_biblio};
93 =head3 item
95 Returns the related Koha::Item object for this Hold
97 =cut
99 sub item {
100 my ($self) = @_;
102 $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
104 return $self->{_item};
107 =head3 branch
109 Returns the related Koha::Branch object for this Hold
111 =cut
113 sub branch {
114 my ($self) = @_;
116 $self->{_branch} ||= Koha::Branches->find( $self->branchcode() );
118 return $self->{_branch};
121 =head3 type
123 =cut
125 sub _type {
126 return 'Reserve';
129 =head1 AUTHOR
131 Kyle M Hall <kyle@bywatersolutions.com>
133 =cut