koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/opac opac-new.pl,NONE,1.1 opac-main.pl,1.7,1.8


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/opac opac-new.pl,NONE,1.1 opac-main.pl,1.7,1.8
Date: Mon, 08 Dec 2003 08:27:29 -0800

Update of /cvsroot/koha/koha/opac
In directory sc8-pr-cvs1:/tmp/cvs-serv4869/opac

Modified Files:
        opac-main.pl 
Added Files:
        opac-new.pl 
Log Message:
new feature : recent acquisition in opac.

--- NEW FILE ---
#!/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 address@hidden;
($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);

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;

Index: opac-main.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-main.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** opac-main.pl        2 Feb 2003 07:18:38 -0000       1.7
--- opac-main.pl        8 Dec 2003 16:27:27 -0000       1.8
***************
*** 8,20 ****
  use C4::Interface::CGI::Output;
  
! my $query = new CGI;
  
! my ($template, $borrowernumber, $cookie) 
      = get_template_and_user({template_name => "opac-main.tmpl",
-                            query => $query,
                             type => "opac",
                             authnotrequired => 1,
                             flagsrequired => {borrow => 1},
                         });
  
! output_html_with_http_headers $query, $cookie, $template->output;
--- 8,37 ----
  use C4::Interface::CGI::Output;
  
! my $input = new CGI;
! my $dbh = C4::Context->dbh;
! my $query="Select itemtype,description from itemtypes order by description";
! my $sth=$dbh->prepare($query);
! $sth->execute;
! my  @itemtype;
! my %itemtypes;
! while (my ($value,$lib) = $sth->fetchrow_array) {
!       push @itemtype, $value;
!       $itemtypes{$value}=$lib;
! }
  
! my $CGIitemtype=CGI::scrolling_list( -name     => 'itemtype',
!                       -values   => address@hidden,
!                       -labels   => \%itemtypes,
!                       -size     => 1,
!                       -multiple => 0 );
! $sth->finish;
! my ($template, $borrowernumber, $cookie)
      = get_template_and_user({template_name => "opac-main.tmpl",
                             type => "opac",
+                            query => $input,
                             authnotrequired => 1,
                             flagsrequired => {borrow => 1},
                         });
  
! $template->param(CGIitemtype => $CGIitemtype);
! output_html_with_http_headers $input, $cookie, $template->output;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]