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
();
41 push @select_branch,"";
42 $select_branches{""} = "";
43 for my $branch (sort { $branches->{$a}->{branchname
} cmp $branches->{$b}->{branchname
} } keys %$branches) {
44 push @select_branch, $branch;
45 $select_branches{$branch} = $branches->{$branch}->{'branchname'};
46 $default = C4
::Context
->userenv->{'branch'} if (C4
::Context
->userenv && C4
::Context
->userenv->{'branch'});
48 my $CGIbranch=CGI
::scrolling_list
( -name
=> 'value',
50 -values => \
@select_branch,
51 -labels
=> \
%select_branches,
54 -default => $default, );
55 $template->param(CGIbranch
=> $CGIbranch);
59 my ($parameters) = @_;
61 my $branch = @
$parameters[0];
62 my $dbh = C4
::Context
->dbh;
65 if (C4
::Context
->preference('item-level_itypes')) {
66 $sth = $dbh->prepare("
67 SELECT description, items.itype as itemtype, COUNT(*) AS total
69 WHERE items.itype=itemtypes.itemtype
70 AND items.holdingbranch=?
72 ORDER BY itemtypes.description");
76 $sth = $dbh->prepare("
77 SELECT description, biblioitems.itemtype, COUNT(*) AS total
78 FROM itemtypes, biblioitems, items
79 WHERE biblioitems.itemtype=itemtypes.itemtype
80 AND items.biblioitemnumber=biblioitems.biblioitemnumber
81 AND items.holdingbranch=?
82 GROUP BY biblioitems.itemtype
83 ORDER BY itemtypes.description");
85 $sth->execute($branch);
87 if (C4
::Context
->preference('item-level_itypes')) {
88 $sth = $dbh->prepare("
89 SELECT description,items.itype AS itemtype, COUNT(*) AS total
91 WHERE items.itype=itemtypes.itemtype
93 ORDER BY itemtypes.description");
96 $sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
97 FROM itemtypes, biblioitems,items
98 WHERE biblioitems.itemtype=itemtypes.itemtype
99 AND biblioitems.biblioitemnumber = items.biblioitemnumber
100 GROUP BY biblioitems.itemtype
101 ORDER BY itemtypes.description");
105 my ($description,$biblioitems,$total);
108 while (($description,$biblioitems,$total) = $sth->fetchrow) {
115 $line{itemtype
} = $description;
116 $line{count
} = $total;
117 $grantotal += $total;
118 push @results,\
%line;
123 $globalline{loopitemtype
} = \
@results;
124 $globalline{total
} = $grantotal;
125 $globalline{branch
} = $branch;
126 $globalline{branchname
} = GetBranchName
($branch);
127 push @mainloop,\
%globalline;