Bug 24986: DBRev 19.05.12.001
[koha.git] / circ / branchoverdues.pl
blob7f6218525e78ae0a748b7a011c2805917106c839
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 $record = GetMarcBiblio({ biblionumber => $num->{biblionumber} });
80 if ($record){
81 $overdueforbranch{'subtitle'} = GetRecordValue('subtitle',$record,'')->[0]->{subfield};
83 my $dt = dt_from_string($num->{date_due}, 'sql');
84 $overdueforbranch{'date_due'} = output_pref($dt);
85 $overdueforbranch{'title'} = $num->{'title'};
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;