Bug 7533: Add the template_cache_dir entry to koha-conf.xml
[koha.git] / reports / itemslost.pl
blob00f2b99d9d80c8c2aed7cf6b8a187dfa0ce13267
1 #!/usr/bin/perl
3 # Copyright Liblime 2007
4 # Copyright Biblibre 2009
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 =head1 itemslost
24 This script displays lost items.
26 =cut
28 use strict;
29 use warnings;
31 use CGI qw ( -utf8 );
32 use C4::Auth;
33 use C4::Output;
34 use C4::Biblio;
35 use C4::Items;
36 use C4::Koha; # GetItemTypes
37 use Koha::DateUtils;
39 my $query = new CGI;
40 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42 template_name => "reports/itemslost.tt",
43 query => $query,
44 type => "intranet",
45 authnotrequired => 0,
46 flagsrequired => { reports => '*' },
47 debug => 1,
51 my $params = $query->Vars;
52 my $get_items = $params->{'get_items'};
54 if ( $get_items ) {
55 my $branchfilter = $params->{'branchfilter'} || undef;
56 my $barcodefilter = $params->{'barcodefilter'} || undef;
57 my $itemtypesfilter = $params->{'itemtypesfilter'} || undef;
58 my $loststatusfilter = $params->{'loststatusfilter'} || undef;
60 my %where;
61 $where{'homebranch'} = $branchfilter if defined $branchfilter;
62 $where{'barcode'} = $barcodefilter if defined $barcodefilter;
63 $where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
65 my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
66 $where{$itype} = $itemtypesfilter if defined $itemtypesfilter;
68 my $items = GetLostItems( \%where );
69 foreach my $it (@$items) {
70 $it->{'datelastseen'} = eval { output_pref( { dt => dt_from_string( $it->{'datelastseen'} ), dateonly => 1 }); }
71 if ( $it->{'datelastseen'} );
74 $template->param(
75 total => scalar @$items,
76 itemsloop => $items,
77 get_items => $get_items,
78 itype_level => C4::Context->preference('item-level_itypes'),
82 # getting all itemtypes
83 my $itemtypes = &GetItemTypes();
84 my @itemtypesloop;
85 foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes ) {
86 my %row = (
87 value => $thisitemtype,
88 description => $itemtypes->{$thisitemtype}->{'translated_description'},
90 push @itemtypesloop, \%row;
93 # get lost statuses
94 my $lost_status_loop = C4::Koha::GetAuthorisedValues( 'LOST' );
96 $template->param(
97 itemtypeloop => \@itemtypesloop,
98 loststatusloop => $lost_status_loop,
101 # writing the template
102 output_html_with_http_headers $query, $cookie, $template->output;