ba905ff2edbe2679176775d05d311252f40d441b
[koha.git] / Koha / StockRotationRotas.pm
1 package Koha::StockRotationRotas;
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::StockRotationRota;
24
25 use base qw(Koha::Objects);
26
27 =head1 NAME
28
29 StockRotationRotas - Koha StockRotationRotas Object class
30
31 =head1 SYNOPSIS
32
33 StockRotationRotas class used primarily by stockrotation .pls and the stock
34 rotation cron script.
35
36 =head1 DESCRIPTION
37
38 Standard Koha::Objects definitions, and additional methods.
39
40 =head1 API
41
42 =head2 Class Methods
43
44 =cut
45
46 =head3 investigate
47
48   my $report = $rotas->investigate;
49
50 Return a report detailing the current status and required actions for all
51 relevant items spread over rotas.
52
53 See Koha::StockRotationRota->investigate for details.
54
55 =cut
56
57 sub investigate {
58     my ( $self ) = @_;
59
60     my $report = {
61         actionable     => 0,
62         advanceable    => 0,
63         initiable      => 0,
64         items_inactive => 0,
65         repatriable    => 0,
66         rotas_active   => 0,
67         rotas_inactive => 0,
68         stationary     => 0,
69         sum_items      => 0,
70         sum_rotas      => $self->count,
71         branched       => {},
72         rotas          => [],
73         items          => [],
74     };
75
76     while ( my $rota = $self->next ) {
77         $report = $rota->investigate($report)
78     }
79
80     return $report;
81 }
82
83 =head3 _type
84
85 =cut
86
87 sub _type {
88     return 'Stockrotationrota';
89 }
90
91 =head3 object_class
92
93 =cut
94
95 sub object_class {
96     return 'Koha::StockRotationRota';
97 }
98
99 1;
100
101 =head1 AUTHOR
102
103 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
104
105 =cut