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>.
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;
29 =head1 branchoverdues.pl
31 This view is used to display all overdue items to the librarian.
33 It is automatically filtered by branch and can optionally be filtered
39 my $dbh = C4::Context->dbh;
41 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
42 template_name => "circ/branchoverdues.tt",
45 flagsrequired => { circulate => "overdues_report" },
48 my $default = C4::Context->userenv->{'branch'};
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');
57 # FIXME: better check that borrowernumber is defined and valid.
58 # FIXME: same for itemnumber and other variables passed in here.
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);
71 foreach my $num (@getoverdues) {
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'};
93 push( @overduesloop, \%overdueforbranch );
96 # initiate the templates for the overdueloop
98 overduesloop => \@overduesloop,
99 location => $location,
102 # Checking if there is a Fast Cataloging Framework
103 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
105 output_html_with_http_headers $input, $cookie, $template->output;