modifs in new acquisition option : the search is now managed through the standard...
authortipaul <tipaul>
Thu, 16 Sep 2004 09:21:05 +0000 (09:21 +0000)
committertipaul <tipaul>
Thu, 16 Sep 2004 09:21:05 +0000 (09:21 +0000)
opac-new.pl can be removed

C4/Search.pm
C4/SearchMarc.pm
koha-tmpl/opac-tmpl/css/en/opac-main.tmpl
koha-tmpl/opac-tmpl/css/en/opac-search.tmpl
koha-tmpl/opac-tmpl/css/en/opac-searchresults.tmpl
opac/opac-main.pl
opac/opac-new.pl [deleted file]

index e5dc3a4..2c12607 100755 (executable)
@@ -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<newsearch> 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);
index 87273a7..160bf85 100644 (file)
@@ -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;
index 541de16..0654bd5 100644 (file)
        </form>
 
        <h2>Recent acquisitions</h2>
-       <form action="/cgi-bin/koha/opac-new.pl">
+       <form action="/cgi-bin/koha/opac-search.pl">
                <p>
-               <!-- TMPL_VAR name="CGIitemtype" --> acquired in the last <b><input type="text" name="duration" value="30" size="3" /></b> days
-               <input type="submit" value="OK" class="button" />
+                       <!-- TMPL_VAR name="CGIitemtype" --> acquired recently (the most recent being first)
+                       <input type="hidden" name="marclist" value="biblioitems.itemtype" />
+                       <input type="hidden" name="and_or" value="and" />
+                       <input type="hidden" name="excluding" value="" />
+                       <input type="hidden" name="operator" value="=" />
+                       <input type="hidden" name="op" value="do_search" />
+                       <input type="hidden" name="type" value="opac" />
+                       <input type="hidden" name="orderby" value="biblio.timestamp desc">
+                       <input type="submit" value="OK" class="button" />
                </p>
        </form>
        <h2>Other options</h2>
index 5765f61..3510f50 100644 (file)
                                <option value="biblioitems.dewey">Dewey</option>
                                <option value="biblioitems.publicationyear">Publication Year</option>
                                <option value="biblioitems.publishercode">Publisher</option>
+                               <option value="biblio.timestamp desc">Acquisition date</option>
                        </select>
                </p>
                <p>&nbsp;</p>
index d352334..9985a70 100644 (file)
@@ -58,6 +58,7 @@
                                                <!-- TMPL_IF name="pages" --> - <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
                                                <!-- TMPL_IF name="notes" --> : <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
                                                <!-- TMPL_IF name="size" --> ; <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF -->
                                        </p>
                                </td>
                                <td align="center" <!-- TMPL_IF name="even" --> class="hilighted"<!-- /TMPL_IF -->>
index 50c7ebf..7ab5ab2 100755 (executable)
@@ -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 (executable)
index 4fbb8c2..0000000
+++ /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;