3 # Copyright 2020 Aleisha Amohia <aleisha@catalyst.net.nz>
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.
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.
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>.
21 use C4::Auth qw( get_template_and_user );
22 use C4::Output qw( output_html_with_http_headers );
24 use Koha::BiblioFrameworks;
25 use Koha::DateUtils qw( dt_from_string );
29 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
31 template_name => "recalls/recalls_waiting.tt",
34 flagsrequired => { recalls => "manage_recalls" },
39 my $op = $query->param('op') || 'list';
41 if ( $op eq 'modify' ) {
42 my $expire = $query->param('expire') || '';
43 my $revert = $query->param('revert') || '';
44 my $recall_id = $query->param('recall_id');
46 Koha::Recalls->find( $recall_id )->set_expired({ interface => 'INTRANET' });
48 Koha::Recalls->find( $recall_id )->revert_waiting;
53 if ( $op eq 'list' ) {
54 my @recalls = Koha::Recalls->search({ status => 'waiting' })->as_list;
55 my $borrower = Koha::Patrons->find( $loggedinuser );
57 my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7;
58 my $today = dt_from_string();
59 foreach my $r ( @recalls ){
60 my $lastwaitingday = dt_from_string( $r->waiting_date )->add( days => $maxdelay );
61 if ( $today > $lastwaitingday ){
71 # Checking if there is a Fast Cataloging Framework
72 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
74 # writing the template
75 output_html_with_http_headers $query, $cookie, $template->output;