3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use C4::Auth qw( get_template_and_user );
24 use C4::Output qw( output_html_with_http_headers );
27 my $report_name = $input->param("report_name");
28 my $do_it = $input->param('do_it');
29 my $fullreportname = "reports/itemtypes.tt";
30 my @values = $input->multi_param("value");
31 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33 template_name => $fullreportname,
36 flagsrequired => { reports => '*' },
43 my $results = calculate( \@values );
44 $template->param( mainloop => $results );
46 output_html_with_http_headers $input, $cookie, $template->output;
49 my ($parameters) = @_;
51 my $branch = @$parameters[0];
52 my $dbh = C4::Context->dbh;
54 if ( C4::Context->preference('item-level_itypes') ) {
57 SELECT itemtypes.itemtype, description, COUNT(*) AS total
59 WHERE items.itype=itemtypes.itemtype
60 | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
61 GROUP BY itemtypes.itemtype, description, items.itype
62 ORDER BY itemtypes.description
68 SELECT itemtypes.itemtype, description, COUNT(*) AS total
69 FROM itemtypes, biblioitems, items
70 WHERE biblioitems.itemtype=itemtypes.itemtype
71 AND items.biblioitemnumber=biblioitems.biblioitemnumber
72 | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
73 GROUP BY itemtypes.itemtype, description
74 ORDER BY itemtypes.description
78 $sth->execute( $branch || () );
79 my ( $itemtype, $description, $total );
82 while ( ( $itemtype, $description, $total ) = $sth->fetchrow ) {
84 $line{itemtype} = $itemtype;
85 $line{count} = $total;
87 push @results, \%line;
92 $globalline{loopitemtype} = \@results;
93 $globalline{total} = $grantotal;
94 $globalline{branch} = $branch;
95 push @mainloop, \%globalline;