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 $userbranch = C4::Context->userenv->{'branch'};
36 $template->param( branchloop => GetBranchesLoop($userbranch) );
41 my ($parameters) = @_;
43 my $branch = @$parameters[0];
44 my $dbh = C4::Context->dbh;
47 if (C4::Context->preference('item-level_itypes')) {
48 $sth = $dbh->prepare("
49 SELECT description, items.itype as itemtype, COUNT(*) AS total
51 WHERE items.itype=itemtypes.itemtype
52 AND items.holdingbranch=?
54 ORDER BY itemtypes.description");
58 $sth = $dbh->prepare("
59 SELECT description, biblioitems.itemtype, COUNT(*) AS total
60 FROM itemtypes, biblioitems, items
61 WHERE biblioitems.itemtype=itemtypes.itemtype
62 AND items.biblioitemnumber=biblioitems.biblioitemnumber
63 AND items.holdingbranch=?
64 GROUP BY biblioitems.itemtype
65 ORDER BY itemtypes.description");
67 $sth->execute($branch);
69 if (C4::Context->preference('item-level_itypes')) {
70 $sth = $dbh->prepare("
71 SELECT description,items.itype AS itemtype, COUNT(*) AS total
73 WHERE items.itype=itemtypes.itemtype
75 ORDER BY itemtypes.description");
78 $sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
79 FROM itemtypes, biblioitems,items
80 WHERE biblioitems.itemtype=itemtypes.itemtype
81 AND biblioitems.biblioitemnumber = items.biblioitemnumber
82 GROUP BY biblioitems.itemtype
83 ORDER BY itemtypes.description");
87 my ($description,$biblioitems,$total);
90 while (($description,$biblioitems,$total) = $sth->fetchrow) {
97 $line{itemtype} = $description;
98 $line{count} = $total;
100 push @results,\%line;
105 $globalline{loopitemtype} = \@results;
106 $globalline{total} = $grantotal;
107 $globalline{branch} = $branch;
108 $globalline{branchname} = GetBranchName($branch);
109 push @mainloop,\%globalline;