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
43 my $branches = GetBranches();
44 my $itemtypes = GetItemTypes();
46 my ($template, $borrowernumber, $cookie)
47 = get_template_and_user({template_name => 'opac-topissues.tmpl',
53 my $dbh = C4::Context->dbh;
55 my $limit = $input->param('limit') || 10;
56 my $branch = $input->param('branch');
57 my $itemtype = $input->param('itemtype');
58 my $timeLimit = $input->param('timeLimit') || 3;
60 $whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch);
61 $whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype;
62 $whereclause .= 'TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.$timeLimit*30 if $timeLimit < 999;
63 $whereclause =~ s/ AND $//;
64 $whereclause = " WHERE ".$whereclause if $whereclause;
66 my $query = "SELECT datecreated, 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
81 my $sth = $dbh->prepare($query);
84 while (my $line= $sth->fetchrow_hashref) {
88 $template->param(do_it => 1,
90 branch => $branches->{$branch}->{branchname},
91 itemtype => $itemtypes->{$itemtype}->{description},
92 timeLimit => $timeLimit,
93 results_loop => \@results,
97 my $branches = GetBranches();
99 for my $branch_hash ( keys %$branches ) {
100 my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst'));
103 value => "branch: $branch_hash",
104 branchname => $branches->{$branch_hash}->{'branchname'},
105 selected => $selected
108 $template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
111 my $itemtypes = GetItemTypes;
113 foreach my $thisitemtype (keys %$itemtypes) {
114 my %row =(value => $thisitemtype,
115 description => $itemtypes->{$thisitemtype}->{'description'},
117 push @itemtypeloop, \%row;
121 itemtypeloop =>\@itemtypeloop,
123 output_html_with_http_headers $input, $cookie, $template->output;