Bug 7317: Interlibrary loans framework for Koha.
[koha.git] / Koha / Illrequests.pm
1 package Koha::Illrequests;
2
3 # Copyright PTFS Europe 2016
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 Koha::Database;
23 use Koha::Illrequest;
24 use Koha::Illrequest::Config;
25
26 use base qw(Koha::Objects);
27
28 =head1 NAME
29
30 Koha::Illrequests - Koha Illrequests Object class
31
32 =head1 API
33
34 =head2 Class Methods
35
36 =cut
37
38 =head3 type
39
40 =cut
41
42 sub _type {
43     return 'Illrequest';
44 }
45
46 sub object_class {
47     return 'Koha::Illrequest';
48 }
49
50 ##### To be implemented Facade
51
52 =head3 new
53
54     my $illRequests = Koha::Illrequests->new();
55
56 Create an ILLREQUESTS object, a singleton through which we can interact with
57 ILLREQUEST objects stored in the database or search for ILL candidates at API
58 backends.
59
60 =cut
61
62 sub new {
63     my ( $class, $attributes ) = @_;
64
65     my $self = $class->SUPER::new($class, $attributes);
66
67     my $config = Koha::Illrequest::Config->new; # <- Necessary
68     $self->{_config} = $config;                 # <- Necessary
69
70     return $self;
71 }
72
73 =head3 search_incomplete
74
75     my $requests = $illRequests->search_incomplete;
76
77 A specialised version of `search`, returning all requests currently
78 not considered completed.
79
80 =cut
81
82 sub search_incomplete {
83     my ( $self ) = @_;
84     $self->search( {
85         status => [
86             -and => { '!=', 'COMP' }, { '!=', 'GENCOMP' }
87         ]
88     } );
89 }
90
91 =head1 AUTHOR
92
93 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
94
95 =cut
96
97 1;