#!/usr/bin/perl
-# $Id$
# Copyright 2000-2002 Katipo Communications
#
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
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
$whereclause
GROUP BY biblio.biblionumber
+ HAVING tot >0
ORDER BY tot DESC
LIMIT $limit
";
push @results, $line;
}
+if($timeLimit eq 999){ $timeLimit = 0 };
+
$template->param(do_it => 1,
limit => $limit,
branch => $branches->{$branch}->{branchname},
results_loop => \@results,
);
-# load the branches
-my $branches = GetBranches();
+# load the branches ## again??
+$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
};
$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
#doctype
-my $itemtypes = GetItemTypes;
+$itemtypes = GetItemTypes;
my @itemtypeloop;
foreach my $thisitemtype (keys %$itemtypes) {
my %row =(value => $thisitemtype,
$template->param(
itemtypeloop =>\@itemtypeloop,
+ dateformat => C4::Context->preference("dateformat"),
);
output_html_with_http_headers $input, $cookie, $template->output;