Bug 34886: (QA follow-up) chmod, remove POD
[koha.git] / circ / transfers_to_send.pl
1 #!/usr/bin/perl
2
3 # Copyright 2019 PTFS-Europe Ltd.
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 # Display items which have been triggered for transfer, but not yet sent.
21 # CAVEAT: Currently limited to transfers prompted by stockrotation only.
22 # See also bug 22569.
23
24 use Modern::Perl;
25 use CGI qw ( -utf8 );
26 use C4::Context;
27 use C4::Auth qw( get_template_and_user );
28 use C4::Output qw( output_html_with_http_headers );
29
30 use Koha::DateUtils qw( dt_from_string );
31
32 my $input      = CGI->new;
33 my $itemnumber = $input->param('itemnumber');
34
35 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
36     {
37         template_name => "circ/transfers_to_send.tt",
38         query         => $input,
39         type          => "intranet",
40         flagsrequired => { circulate => "circulate_remaining_permissions" },
41     }
42 );
43
44 # set the userenv branch
45 my $branchcode = C4::Context->userenv->{'branch'};
46
47 # transfers requested but not yet sent
48 my $transfers = Koha::Libraries->search(
49     {
50         'branchtransfers_tobranches.frombranch'    => $branchcode,
51         'branchtransfers_tobranches.daterequested' => { '!=' => undef },
52         'branchtransfers_tobranches.datesent'      => undef,
53         'branchtransfers_tobranches.datearrived'   => undef,
54         'branchtransfers_tobranches.datecancelled' => undef,
55     },
56     {
57         prefetch => 'branchtransfers_tobranches',
58         order_by => 'branchtransfers_tobranches.tobranch'
59     }
60 );
61
62 $template->param(
63     libraries => $transfers,
64     show_date => dt_from_string
65 );
66
67 output_html_with_http_headers $input, $cookie, $template->output;