7 use C4::Interface::CGI::Output;
11 my ($template, $borrowernumber, $cookie)
12 = get_template_and_user({template_name => "opac-searchresults.tmpl",
16 flagsrequired => {borrow => 1},
22 my $itemtype=$query->param('itemtype');
23 my $duration =$query->param('duration');
24 my $number_of_results = 20;
26 my $startfrom = $query->param('startfrom');
27 ($startfrom) || ($startfrom=0);
28 my $subjectitems=$query->param('subjectitems');
29 my (@results) = newsearch($itemtype,$duration,$number_of_results,$startfrom);
30 my $count= $#results+1;
32 foreach my $res (@results) {
33 my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra");
35 foreach my $itm (@items) {
36 $norequests = 0 unless $itm->{'notforloan'};
38 $res->{'norequests'} = $norequests;
39 # set up the even odd elements....
40 $res->{'even'} = 1 if $num % 2 == 0;
41 $res->{'odd'} = 1 if $num % 2 == 1;
45 my $resultsarray=\@results;
46 ($resultsarray) || (@$resultsarray=());
48 # sorting out which results to display.
49 $template->param(startfrom => $startfrom+1);
50 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
51 $template->param(numrecords => $count);
52 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
53 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$number_of_results) : (-1);
54 my $displaynext=($nextstartfrom==-1) ? 0 : 1;
55 my $displayprev=($prevstartfrom==-1) ? 0 : 1;
56 $template->param(nextstartfrom => $nextstartfrom,
57 displaynext => $displaynext,
58 displayprev => $displayprev,
59 prevstartfrom => $prevstartfrom,
61 itemtype => ItemType($itemtype),
62 duration => $duration);
64 $template->param(SEARCH_RESULTS => $resultsarray,
65 LibraryName => C4::Context->preference("LibraryName"),
70 if ($count>$number_of_results) {
71 for (my $i=1; $i<$count/$number_of_results+1; $i++) {
73 my $themelang = $template->param('themelang');
74 ($startfrom==($i-1)*$number_of_results+1) && ($highlight=1);
75 push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*$number_of_results+1 };
79 $template->param(numbers => $numbers);
81 output_html_with_http_headers $query, $cookie, $template->output;