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
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>.
28 use C4
::Branch
; # GetBranches
36 if (C4
::Context
->userenv && C4
::Context
->userenv->{'branch'}) {
37 $userbranch = C4
::Context
->userenv->{'branch'};
39 $template->param( branchloop
=> GetBranchesLoop
($userbranch) );
44 my ($parameters) = @_;
46 my $branch = @
$parameters[0];
47 my $dbh = C4
::Context
->dbh;
50 if (C4
::Context
->preference('item-level_itypes')) {
51 $sth = $dbh->prepare("
52 SELECT description, items.itype as itemtype, COUNT(*) AS total
54 WHERE items.itype=itemtypes.itemtype
55 AND items.holdingbranch=?
57 ORDER BY itemtypes.description");
61 $sth = $dbh->prepare("
62 SELECT description, biblioitems.itemtype, COUNT(*) AS total
63 FROM itemtypes, biblioitems, items
64 WHERE biblioitems.itemtype=itemtypes.itemtype
65 AND items.biblioitemnumber=biblioitems.biblioitemnumber
66 AND items.holdingbranch=?
67 GROUP BY biblioitems.itemtype
68 ORDER BY itemtypes.description");
70 $sth->execute($branch);
72 if (C4
::Context
->preference('item-level_itypes')) {
73 $sth = $dbh->prepare("
74 SELECT description,items.itype AS itemtype, COUNT(*) AS total
76 WHERE items.itype=itemtypes.itemtype
78 ORDER BY itemtypes.description");
81 $sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
82 FROM itemtypes, biblioitems,items
83 WHERE biblioitems.itemtype=itemtypes.itemtype
84 AND biblioitems.biblioitemnumber = items.biblioitemnumber
85 GROUP BY biblioitems.itemtype
86 ORDER BY itemtypes.description");
90 my ($description,$biblioitems,$total);
93 while (($description,$biblioitems,$total) = $sth->fetchrow) {
100 $line{itemtype
} = $description;
101 $line{count
} = $total;
102 $grantotal += $total;
103 push @results,\
%line;
108 $globalline{loopitemtype
} = \
@results;
109 $globalline{total
} = $grantotal;
110 $globalline{branch
} = $branch;
111 $globalline{branchname
} = GetBranchName
($branch);
112 push @mainloop,\
%globalline;