From 214c37b371fd6a468476bb9f5d5609f4bfd54380 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 16 Sep 2004 09:21:05 +0000 Subject: [PATCH] modifs in new acquisition option : the search is now managed through the standard search API, with an "order by timestamp" order. opac-new.pl can be removed --- C4/Search.pm | 87 ------------------- C4/SearchMarc.pm | 3 + koha-tmpl/opac-tmpl/css/en/opac-main.tmpl | 13 ++- koha-tmpl/opac-tmpl/css/en/opac-search.tmpl | 1 + .../opac-tmpl/css/en/opac-searchresults.tmpl | 1 + opac/opac-main.pl | 2 +- opac/opac-new.pl | 81 ----------------- 7 files changed, 16 insertions(+), 172 deletions(-) delete mode 100755 opac/opac-new.pl diff --git a/C4/Search.pm b/C4/Search.pm index e5dc3a4bf0..2c12607c64 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -57,7 +57,6 @@ on what is passed to it, it calls the appropriate search function. @ISA = qw(Exporter); @EXPORT = qw( -&newsearch &CatSearch &BornameSearch &ItemInfo &KeywordSearch &subsearch &itemdata &bibdata &GetItems &borrdata &itemnodata &itemcount &borrdata2 &NewBorrowerNumber &bibitemdata &borrissues @@ -68,92 +67,6 @@ on what is passed to it, it calls the appropriate search function. # make all your functions, whether exported or not; -=item newsearch - my (@results) = newsearch($itemtype,$duration,$number_of_results,$startfrom); -c find biblio acquired recently (last 30 days) -=cut -sub newsearch { - my ($itemtype,$duration,$num,$offset)=@_; - - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("SELECT to_days( now( ) ) - to_days( dateaccessioned ) AS duration, biblio.biblionumber, barcode, title, author, classification, itemtype, dewey, dateaccessioned, price, replacementprice - FROM items, biblio, biblioitems - WHERE biblio.biblionumber = biblioitems.biblionumber AND - items.biblionumber = biblio.biblionumber AND - to_days( now( ) ) - to_days( dateaccessioned ) < ? and itemtype=? - ORDER BY duration ASC "); - $sth->execute($duration,$itemtype); - my $i=0; - my @result; - while (my $data = $sth->fetchrow_hashref) { - if ($i>=$offset && $i<$num+$offset) { - my ($counts) = itemcount2("", $data->{'biblionumber'}, 'intra'); - my $subject2=$data->{'subject'}; - $subject2=~ s/ /%20/g; - $data->{'itemcount'}=$counts->{'total'}; - my $totalitemcounts=0; - foreach my $key (keys %$counts){ - if ($key ne 'total'){ # FIXME - Should ignore 'order', too. - #$data->{'location'}.="$key $counts->{$key} "; - $totalitemcounts+=$counts->{$key}; - $data->{'locationhash'}->{$key}=$counts->{$key}; - } - } - my $locationtext=''; - my $locationtextonly=''; - my $notavailabletext=''; - foreach (sort keys %{$data->{'locationhash'}}) { - if ($_ eq 'notavailable') { - $notavailabletext="Not available"; - my $c=$data->{'locationhash'}->{$_}; - $data->{'not-available-p'}=$totalitemcounts; - if ($totalitemcounts>1) { - $notavailabletext.=" ($c)"; - $data->{'not-available-plural-p'}=1; - } - } else { - $locationtext.="$_ "; - my $c=$data->{'locationhash'}->{$_}; - if ($_ eq 'Item Lost') { - $data->{'lost-p'}=$totalitemcounts; - $data->{'lost-plural-p'}=1 - if $totalitemcounts > 1; - } elsif ($_ eq 'Withdrawn') { - $data->{'withdrawn-p'}=$totalitemcounts; - $data->{'withdrawn-plural-p'}=1 - if $totalitemcounts > 1; - } elsif ($_ eq 'On Loan') { - $data->{'on-loan-p'}=$totalitemcounts; - $data->{'on-loan-plural-p'}=1 - if $totalitemcounts > 1; - } else { - $locationtextonly.=$_; - $locationtextonly.=" ($c), " - if $totalitemcounts>1; - } - if ($totalitemcounts>1) { - $locationtext.=" ($c), "; - } - } - } - if ($notavailabletext) { - $locationtext.=$notavailabletext; - } else { - $locationtext=~s/, $//; - } - $data->{'location'}=$locationtext; - $data->{'location-only'}=$locationtextonly; - $data->{'subject2'}=$subject2; - $data->{'use-location-flags-p'}=1; # XXX - - push @result,$data; - } - $i++ - } - return($i,@result); - -} - =item findguarantees ($num_children, $children_arrayref) = &findguarantees($parent_borrno); diff --git a/C4/SearchMarc.pm b/C4/SearchMarc.pm index 87273a70fc..160bf85a72 100644 --- a/C4/SearchMarc.pm +++ b/C4/SearchMarc.pm @@ -22,6 +22,8 @@ require Exporter; use DBI; use C4::Context; use C4::Biblio; +use C4::Date; +use Date::Manip; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -283,6 +285,7 @@ sub catalogsearch { $newline{CN} = \@CNresults2; $newline{'even'} = 1 if $#finalresult % 2 == 0; $newline{'odd'} = 1 if $#finalresult % 2 == 1; + $newline{'timestamp'} = format_date($newline{timestamp}); @CNresults = (); push @finalresult, \%newline; $totalitems=0; diff --git a/koha-tmpl/opac-tmpl/css/en/opac-main.tmpl b/koha-tmpl/opac-tmpl/css/en/opac-main.tmpl index 541de16745..0654bd59cf 100644 --- a/koha-tmpl/opac-tmpl/css/en/opac-main.tmpl +++ b/koha-tmpl/opac-tmpl/css/en/opac-main.tmpl @@ -31,10 +31,17 @@

Recent acquisitions

-
+

- acquired in the last days - + acquired recently (the most recent being first) + + + + + + + +

Other options

diff --git a/koha-tmpl/opac-tmpl/css/en/opac-search.tmpl b/koha-tmpl/opac-tmpl/css/en/opac-search.tmpl index 5765f61904..3510f50597 100644 --- a/koha-tmpl/opac-tmpl/css/en/opac-search.tmpl +++ b/koha-tmpl/opac-tmpl/css/en/opac-search.tmpl @@ -108,6 +108,7 @@ +

 

diff --git a/koha-tmpl/opac-tmpl/css/en/opac-searchresults.tmpl b/koha-tmpl/opac-tmpl/css/en/opac-searchresults.tmpl index d3523343cc..9985a70e58 100644 --- a/koha-tmpl/opac-tmpl/css/en/opac-searchresults.tmpl +++ b/koha-tmpl/opac-tmpl/css/en/opac-searchresults.tmpl @@ -58,6 +58,7 @@ - : ; + (modified on )

class="hilighted"> diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 50c7ebf94c..7ab5ab2f64 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -21,7 +21,7 @@ while (my ($value,$lib) = $sth->fetchrow_array) { $itemtypes{$value}=$lib; } -my $CGIitemtype=CGI::scrolling_list( -name => 'itemtype', +my $CGIitemtype=CGI::scrolling_list( -name => 'value', -values => \@itemtype, -labels => \%itemtypes, -size => 1, diff --git a/opac/opac-new.pl b/opac/opac-new.pl deleted file mode 100755 index 4fbb8c2a3b..0000000000 --- a/opac/opac-new.pl +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/perl -use strict; -require Exporter; -use CGI; -use C4::Search; -use C4::Auth; -use C4::Interface::CGI::Output; -use HTML::Template; - -my $query=new CGI; -my ($template, $borrowernumber, $cookie) - = get_template_and_user({template_name => "opac-searchresults.tmpl", - query => $query, - type => "opac", - authnotrequired => 1, - flagsrequired => {borrow => 1}, - }); - - - - -my $itemtype=$query->param('itemtype'); -my $duration =$query->param('duration'); -my $number_of_results = 20; - -my $startfrom = $query->param('startfrom'); -($startfrom) || ($startfrom=0); -my $subjectitems=$query->param('subjectitems'); -my (@results) = newsearch($itemtype,$duration,$number_of_results,$startfrom); -my $count= $#results+1; -my $num = 1; -foreach my $res (@results) { - my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra"); - my $norequests = 1; - foreach my $itm (@items) { - $norequests = 0 unless $itm->{'notforloan'}; - } - $res->{'norequests'} = $norequests; - # set up the even odd elements.... - $res->{'even'} = 1 if $num % 2 == 0; - $res->{'odd'} = 1 if $num % 2 == 1; - $num++; -} - -my $resultsarray=\@results; -($resultsarray) || (@$resultsarray=()); - -# sorting out which results to display. -$template->param(startfrom => $startfrom+1); -($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count)); -$template->param(numrecords => $count); -my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1); -my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$number_of_results) : (-1); -my $displaynext=($nextstartfrom==-1) ? 0 : 1; -my $displayprev=($prevstartfrom==-1) ? 0 : 1; -$template->param(nextstartfrom => $nextstartfrom, - displaynext => $displaynext, - displayprev => $displayprev, - prevstartfrom => $prevstartfrom, - searchnew => 1, - itemtype => ItemType($itemtype), - duration => $duration); - -$template->param(SEARCH_RESULTS => $resultsarray, - LibraryName => C4::Context->preference("LibraryName"), -); - -my $numbers; -@$numbers = (); -if ($count>$number_of_results) { - for (my $i=1; $i<$count/$number_of_results+1; $i++) { - my $highlight=0; - my $themelang = $template->param('themelang'); - ($startfrom==($i-1)*$number_of_results+1) && ($highlight=1); - push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*$number_of_results+1 }; - } -} - -$template->param(numbers => $numbers); - -output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.2