12 my ($template, $borrowernumber, $cookie)
13 = get_template_and_user({template_name => "opac-searchresults.tmpl",
17 flagsrequired => {borrow => 1},
21 my $subject=$query->param('subject');
26 $template->param(subjectsearch => $subject);
29 # get all the search variables
30 # we assume that C4::Search will validate these values for us
31 my @fields = ('keyword', 'subject', 'author', 'illustrator', 'itemnumber', 'isbn', 'date-before', 'date-after', 'class', 'dewey', 'branch', 'title', 'abstract', 'publisher');
35 # collect all the fields ...
40 foreach my $field (@fields) {
41 $search{$field} = $query->param($field);
42 if ($field eq 'keyword'){
43 $search{$field} = $query->param('words') unless $search{$field};
45 if ($search{$field}) {
46 push @$forminputs, {field => $field, value => $search{$field}};
47 $searchdesc .= "$field = $search{$field}, ";
51 $search{'ttype'} = $query->param('ttype');
52 push @$forminputs, {field => 'ttype', value => $search{'ttype'}};
54 if (my $subjectitems=$query->param('subjectitems')){
55 $search{'subject'} = $subjectitems;
56 $searchdesc.="subject = $subjectitems, ";
59 @$forminputs=() unless $forminputs;
60 $template->param(FORMINPUTS => $forminputs);
65 my $number_of_results = 20;
68 my $startfrom = $query->param('startfrom');
69 my $subjectitems=$query->param('subjectitems');
71 @results = subsearch($env,$subjectitems, $number_of_results, $startfrom);
74 ($count, @results) = catalogsearch($env,'',\%search,$number_of_results,$startfrom);
78 foreach my $res (@results) {
79 my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra");
81 foreach my $itm (@items) {
82 $norequests = 0 unless $itm->{'notforloan'};
84 $res->{'norequests'} = $norequests;
85 # set up the even odd elements....
86 $res->{'even'} = 1 if $num % 2 == 0;
87 $res->{'odd'} = 1 if $num % 2 == 1;
92 my $startfrom=$query->param('startfrom');
93 ($startfrom) || ($startfrom=0);
95 my $resultsarray=\@results;
96 ($resultsarray) || (@$resultsarray=());
99 # sorting out which results to display.
100 $template->param(startfrom => $startfrom+1);
101 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
102 $template->param(numrecords => $count);
103 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
104 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
105 $template->param(nextstartfrom => $nextstartfrom);
108 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
109 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
110 $template->param(displaynext => $displaynext);
111 $template->param(displayprev => $displayprev);
112 $template->param(prevstartfrom => $prevstartfrom);
114 $template->param(searchdesc => $searchdesc);
115 $template->param(SEARCH_RESULTS => $resultsarray);
120 for (my $i=1; $i<$count/10+1; $i++) {
122 my $themelang = $template->param('themelang');
123 ($startfrom==($i-1)*10) && ($highlight=1);
124 push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*10 };
128 $template->param(numbers => $numbers);
130 print $query->header(
131 -type => guesstype($template->output),
133 ), $template->output;