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;
29 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
31 template_name => "recalls/recalls_waiting.tt",
35 flagsrequired => { recalls => "manage_recalls" },
40 my $op = $query->param('op') || 'list';
42 if ( $op eq 'modify' ) {
43 my $expire = $query->param('expire') || '';
44 my $revert = $query->param('revert') || '';
45 my $recall_id = $query->param('recall_id');
47 Koha::Recalls->find( $recall_id )->set_expired({ interface => 'INTRANET' });
49 Koha::Recalls->find( $recall_id )->revert_waiting;
54 if ( $op eq 'list' ) {
55 my @recalls = Koha::Recalls->search({ status => 'W' });
56 my $borrower = Koha::Patrons->find( $loggedinuser );
58 my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7;
59 my $today = dt_from_string();
60 foreach my $r ( @recalls ){
61 my $lastwaitingday = dt_from_string( $r->waitingdate )->add( days => $maxdelay );
62 if ( $today > $lastwaitingday ){
72 # Checking if there is a Fast Cataloging Framework
73 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
75 # writing the template
76 output_html_with_http_headers $query, $cookie, $template->output;