Bug 25716: (QA follow-up) Move additional options to etc/z3950/config.xml
[koha.git] / circ / branchoverdues.pl
1 #!/usr/bin/perl
2
3 #
4 # This file is part of Koha.
5 #
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 C4::Context;
21 use CGI qw ( -utf8 );
22 use C4::Output qw( output_html_with_http_headers );
23 use C4::Auth qw( get_template_and_user );
24 use C4::Overdues qw( GetOverduesForBranch );
25 use C4::Biblio qw( GetMarcFromKohaField GetMarcStructure );
26 use C4::Koha qw( GetAuthorisedValues );
27 use Koha::BiblioFrameworks;
28
29 =head1 branchoverdues.pl
30
31 This view is used to display all overdue items to the librarian.
32
33 It is automatically filtered by branch and can optionally be filtered
34 by item location.
35
36 =cut
37
38 my $input       = CGI->new;
39 my $dbh = C4::Context->dbh;
40
41 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
42         template_name   => "circ/branchoverdues.tt",
43         query           => $input,
44         type            => "intranet",
45         flagsrequired   => { circulate => "circulate_remaining_permissions" },
46 });
47
48 my $default = C4::Context->userenv->{'branch'};
49
50 # Deal with the vars recept from the template
51 my $borrowernumber = $input->param('borrowernumber');
52 my $itemnumber     = $input->param('itemnumber');
53 my $method         = $input->param('method');
54 my $overduelevel   = $input->param('overduelevel');
55 my $location       = $input->param('location');
56
57 # FIXME: better check that borrowernumber is defined and valid.
58 # FIXME: same for itemnumber and other variables passed in here.
59
60 my @overduesloop;
61 my @getoverdues = GetOverduesForBranch( $default, $location );
62 # search for location authorised value
63 my ($tag,$subfield) = GetMarcFromKohaField( 'items.location' );
64 my $tagslib = &GetMarcStructure(1,'');
65 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
66     my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
67     for (@$values) { $_->{selected} = 1 if defined $location && $location eq $_->{authorised_value} }
68     $template->param(locationsloop => $values);
69 }
70 # now display infos
71 foreach my $num (@getoverdues) {
72     my %overdueforbranch;
73     $overdueforbranch{'date_due'}          = $num->{date_due};
74     $overdueforbranch{'title'}             = $num->{'title'};
75     $overdueforbranch{'subtitle'}          = $num->{'subtitle'};
76     $overdueforbranch{'medium'}            = $num->{'medium'};
77     $overdueforbranch{'part_number'}       = $num->{'part_number'};
78     $overdueforbranch{'part_name'}         = $num->{'part_name'};
79     $overdueforbranch{'description'}       = $num->{'description'};
80     $overdueforbranch{'barcode'}           = $num->{'barcode'};
81     $overdueforbranch{'biblionumber'}      = $num->{'biblionumber'};
82     $overdueforbranch{'author'}            = $num->{'author'};
83     $overdueforbranch{'borrowersurname'}   = $num->{'surname'};
84     $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
85     $overdueforbranch{'borrowerphone'}     = $num->{'phone'};
86     $overdueforbranch{'borroweremail'}     = $num->{'email'};
87     $overdueforbranch{'homebranch'}        = $num->{'homebranch'};
88     $overdueforbranch{'itemcallnumber'}    = $num->{'itemcallnumber'};
89     $overdueforbranch{'borrowernumber'}    = $num->{'borrowernumber'};
90     $overdueforbranch{'itemnumber'}        = $num->{'itemnumber'};
91     $overdueforbranch{'cardnumber'}        = $num->{'cardnumber'};
92
93     push( @overduesloop, \%overdueforbranch );
94 }
95
96 # initiate the templates for the overdueloop
97 $template->param(
98     overduesloop => \@overduesloop,
99     location     => $location,
100 );
101
102 # Checking if there is a Fast Cataloging Framework
103 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
104
105 output_html_with_http_headers $input, $cookie, $template->output;