5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
34 plugin that shows a stats on borrowers
44 my $branches = GetBranches();
45 my $itemtypes = GetItemTypes();
47 my ($template, $borrowernumber, $cookie)
48 = get_template_and_user({template_name => 'opac-topissues.tmpl',
54 my $dbh = C4::Context->dbh;
56 my $limit = $input->param('limit') || 10;
57 my $branch = $input->param('branch');
58 my $itemtype = $input->param('itemtype');
59 my $timeLimit = $input->param('timeLimit') || 3;
61 $whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch);
62 $whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype;
63 $whereclause .= 'TO_DAYS(NOW()) - TO_DAYS(biblio.timestamp) <= '.$timeLimit*30 if $timeLimit;
64 $whereclause =~ s/ AND $//;
65 $whereclause = " WHERE ".$whereclause if $whereclause;
66 my $query = "SELECT biblio.timestamp, biblio.biblionumber, title,
67 author, sum( items.issues ) AS tot, biblioitems.itemtype,
68 biblioitems.publishercode,biblioitems.publicationyear,
71 LEFT JOIN items USING (biblionumber)
72 LEFT JOIN biblioitems USING (biblionumber)
73 LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
75 GROUP BY biblio.biblionumber
80 my $sth = $dbh->prepare($query);
83 while (my $line= $sth->fetchrow_hashref) {
87 $template->param(do_it => 1,
89 branch => $branches->{$branch}->{branchname},
90 itemtype => $itemtypes->{$itemtype}->{description},
91 timeLimit => $timeLimit,
92 results_loop => \@results,
95 my $branches = GetBranches;
97 foreach my $thisbranch (keys %$branches) {
98 my %row =(value => $thisbranch,
99 branchname => $branches->{$thisbranch}->{'branchname'},
101 push @branchloop, \%row;
105 my $itemtypes = GetItemTypes;
107 foreach my $thisitemtype (keys %$itemtypes) {
108 my %row =(value => $thisitemtype,
109 description => $itemtypes->{$thisitemtype}->{'description'},
111 push @itemtypeloop, \%row;
115 branchloop =>\@branchloop,
116 itemtypeloop =>\@itemtypeloop,
118 output_html_with_http_headers $input, $cookie, $template->output;