f6db6cfa43d267cdd92038ec189fdf31ca2f1abe
[koha.git] / recalls / recalls_overdue.pl
1 #!/usr/bin/perl
2
3 # Copyright 2020 Aleisha Amohia <aleisha@catalyst.net.nz>
4 #
5 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18
19 use Modern::Perl;
20 use CGI qw ( -utf8 );
21 use C4::Auth qw( get_template_and_user );
22 use C4::Output qw( output_html_with_http_headers );
23 use Koha::BiblioFrameworks;
24 use Koha::DateUtils;
25
26 my $query = CGI->new;
27 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
28     {
29        template_name   => "recalls/recalls_overdue.tt",
30        query           => $query,
31        type            => "intranet",
32        flagsrequired   => { recalls => "manage_recalls" },
33        debug           => 1,
34     }
35 );
36
37 my $op = $query->param('op') || 'list';
38 my @recall_ids = $query->multi_param('recall_ids');
39
40 if ( $op eq 'cancel_multiple_recalls' ) {
41     foreach my $id ( @recall_ids ) {
42         Koha::Recalls->find( $id )->set_cancelled;
43     }
44     $op = 'list'
45 }
46
47 if ( $op eq 'list' ) {
48     my $recalls = Koha::Recalls->search({ status => 'overdue' });
49     # will be set as Overdue by the misc/cronjobs/recall/overdue_recalls.pl cronjob
50     $template->param(
51         recalls => $recalls,
52         checkboxes => 1,
53     );
54 }
55
56 # Checking if there is a Fast Cataloging Framework
57 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
58
59 # writing the template
60 output_html_with_http_headers $query, $cookie, $template->output;