adding endnote export and 'related items'
[koha_fer] / opac / opac-topissues.pl
index 6f48365..b77c0ab 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -57,12 +56,13 @@ my $branch = $input->param('branch');
 my $itemtype = $input->param('itemtype');
 my $timeLimit = $input->param('timeLimit') || 3;
 my $whereclause;
-$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch); 
+$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch);
 $whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype;
-$whereclause .= 'TO_DAYS(NOW()) - TO_DAYS(biblio.timestamp) <= '.$timeLimit*30 if $timeLimit;
+$whereclause .= ' TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30).' AND ' if $timeLimit < 999;
 $whereclause =~ s/ AND $//;
 $whereclause = " WHERE ".$whereclause if $whereclause;
-my $query = "SELECT biblio.timestamp, biblio.biblionumber, title, 
+
+my $query = "SELECT datecreated, biblio.biblionumber, title, 
                 author, sum( items.issues ) AS tot, biblioitems.itemtype,
                 biblioitems.publishercode,biblioitems.publicationyear,
                 itemtypes.description
@@ -72,6 +72,7 @@ my $query = "SELECT biblio.timestamp, biblio.biblionumber, title,
                 LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
                 $whereclause
                 GROUP BY biblio.biblionumber
+                HAVING tot >0
                 ORDER BY tot DESC
                 LIMIT $limit
                 ";
@@ -94,11 +95,11 @@ $template->param(do_it => 1,
 # load the branches
 my $branches = GetBranches();
 my @branch_loop;
-for my $branch_hash ( keys %$branches ) {
+for my $branch_hash (sort keys %$branches ) {
     my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst'));
     push @branch_loop,
       {
-        value      => "branch: $branch_hash",
+        value      => "$branch_hash",
         branchname => $branches->{$branch_hash}->{'branchname'},
         selected => $selected
       };