Bug 28959: Add virtualshelves.public as a boolean
[koha.git] / Koha / Old / Checkouts.pm
1 package Koha::Old::Checkouts;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Koha::Database;
21 use Koha::DateUtils qw( dt_from_string );
22 use Koha::Old::Checkout;
23
24 use base qw(Koha::Objects);
25
26 sub filter_by_todays_checkins {
27     my ( $self ) = @_;
28
29     my $dtf = Koha::Database->new->schema->storage->datetime_parser;
30     my $today = dt_from_string;
31     my $today_start = $today->clone->set( hour =>  0, minute =>  0, second =>  0 );
32     my $today_end   = $today->clone->set( hour => 23, minute => 59, second => 59 );
33     $today_start = $dtf->format_datetime( $today_start );
34     $today_end   = $dtf->format_datetime( $today_end );
35     return $self->search({
36         returndate => {
37             '>=' => $today_start,
38             '<=' => $today_end,
39         },
40     });
41 }
42
43 sub _type {
44     return 'OldIssue';
45 }
46
47 sub object_class {
48     return 'Koha::Old::Checkout';
49 }
50
51 1;