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::DateUtils qw( dt_from_string output_pref );
28 use Koha::BiblioFrameworks;
30 =head1 branchoverdues.pl
32 This view is used to display all overdue items to the librarian.
34 It is automatically filtered by branch and can optionally be filtered
40 my $dbh = C4::Context->dbh;
42 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
43 template_name => "circ/branchoverdues.tt",
46 flagsrequired => { circulate => "circulate_remaining_permissions" },
49 my $default = C4::Context->userenv->{'branch'};
51 # Deal with the vars recept from the template
52 my $borrowernumber = $input->param('borrowernumber');
53 my $itemnumber = $input->param('itemnumber');
54 my $method = $input->param('method');
55 my $overduelevel = $input->param('overduelevel');
56 my $location = $input->param('location');
58 # FIXME: better check that borrowernumber is defined and valid.
59 # FIXME: same for itemnumber and other variables passed in here.
62 my @getoverdues = GetOverduesForBranch( $default, $location );
63 # search for location authorised value
64 my ($tag,$subfield) = GetMarcFromKohaField( 'items.location' );
65 my $tagslib = &GetMarcStructure(1,'');
66 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
67 my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
68 for (@$values) { $_->{selected} = 1 if defined $location && $location eq $_->{authorised_value} }
69 $template->param(locationsloop => $values);
72 foreach my $num (@getoverdues) {
74 my $dt = dt_from_string($num->{date_due}, 'sql');
75 $overdueforbranch{'date_due'} = output_pref($dt);
76 $overdueforbranch{'title'} = $num->{'title'};
77 $overdueforbranch{'subtitle'} = $num->{'subtitle'};
78 $overdueforbranch{'medium'} = $num->{'medium'};
79 $overdueforbranch{'part_number'} = $num->{'part_number'};
80 $overdueforbranch{'part_name'} = $num->{'part_name'};
81 $overdueforbranch{'description'} = $num->{'description'};
82 $overdueforbranch{'barcode'} = $num->{'barcode'};
83 $overdueforbranch{'biblionumber'} = $num->{'biblionumber'};
84 $overdueforbranch{'author'} = $num->{'author'};
85 $overdueforbranch{'borrowersurname'} = $num->{'surname'};
86 $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
87 $overdueforbranch{'borrowerphone'} = $num->{'phone'};
88 $overdueforbranch{'borroweremail'} = $num->{'email'};
89 $overdueforbranch{'homebranch'} = $num->{'homebranch'};
90 $overdueforbranch{'itemcallnumber'} = $num->{'itemcallnumber'};
91 $overdueforbranch{'borrowernumber'} = $num->{'borrowernumber'};
92 $overdueforbranch{'itemnumber'} = $num->{'itemnumber'};
93 $overdueforbranch{'cardnumber'} = $num->{'cardnumber'};
95 push( @overduesloop, \%overdueforbranch );
98 # initiate the templates for the overdueloop
100 overduesloop => \@overduesloop,
101 location => $location,
104 # Checking if there is a Fast Cataloging Framework
105 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
107 output_html_with_http_headers $input, $cookie, $template->output;