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