4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use C4
::Branch
; # GetBranches
35 my $dbh = C4
::Context
->dbh;
36 my $branches=GetBranches
();
40 push @select_branch,"";
41 $select_branches{""} = "";
42 foreach my $branch (keys %$branches) {
43 push @select_branch, $branch;
44 $select_branches{$branch} = $branches->{$branch}->{'branchname'};
46 my $CGIbranch=CGI
::scrolling_list
( -name
=> 'value',
48 -values => \
@select_branch,
49 -labels
=> \
%select_branches,
52 $template->param(CGIbranch
=> $CGIbranch);
56 my ($parameters) = @_;
58 my $branch = @
$parameters[0];
59 my $dbh = C4
::Context
->dbh;
62 if (C4
::Context
->preference('item-level_itypes')) {
63 $sth = $dbh->prepare("
64 SELECT description, items.itype as itemtype, COUNT(*) AS total
66 WHERE items.itype=itemtypes.itemtype
67 AND items.holdingbranch=?
68 GROUP BY items.itype");
72 $sth = $dbh->prepare("
73 SELECT description, biblioitems.itemtype, COUNT(*) AS total
74 FROM itemtypes, biblioitems, items
75 WHERE biblioitems.itemtype=itemtypes.itemtype
76 AND items.biblioitemnumber=biblioitems.biblioitemnumber
77 AND items.holdingbranch=?
78 GROUP BY biblioitems.itemtype");
80 $sth->execute($branch);
82 if (C4
::Context
->preference('item-level_itypes')) {
83 $sth = $dbh->prepare("
84 SELECT description,items.itype AS itemtype, COUNT(*) AS total
86 WHERE items.itype=itemtypes.itemtype
87 GROUP BY items.itype");
90 $sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
91 FROM itemtypes, biblioitems,items
92 WHERE biblioitems.itemtype=itemtypes.itemtype
93 AND biblioitems.biblioitemnumber = items.biblioitemnumber
94 GROUP BY biblioitems.itemtype");
98 my ($description,$biblioitems,$total);
101 while (($description,$biblioitems,$total) = $sth->fetchrow) {
108 $line{itemtype
} = $description;
109 $line{count
} = $total;
110 $grantotal += $total;
111 push @results,\
%line;
116 $globalline{loopitemtype
} = \
@results;
117 $globalline{total
} = $grantotal;
118 $globalline{branch
} = $branch;
119 push @mainloop,\
%globalline;