11 my ($template, $borrowernumber, $cookie)
12 = get_template_and_user({template_name => "opac-searchresults.tmpl",
16 flagsrequired => {borrow => 1},
20 my $subject=$query->param('subject');
25 $template->param(subjectsearch => $subject);
28 # get all the search variables
29 # we assume that C4::Search will validate these values for us
30 my @fields = ('keyword', 'subject', 'author', 'illustrator', 'itemnumber', 'isbn', 'date-before', 'date-after', 'class', 'dewey', 'branch', 'title', 'abstract', 'publisher');
34 # collect all the fields ...
39 foreach my $field (@fields) {
40 $search{$field} = $query->param($field);
41 if ($field eq 'keyword'){
42 $search{$field} = $query->param('words') unless $search{$field};
44 if ($search{$field}) {
45 push @$forminputs, {field => $field, value => $search{$field}};
46 $searchdesc .= "$field = $search{$field}, ";
50 $search{'ttype'} = $query->param('ttype');
51 push @$forminputs, {field => 'ttype', value => $search{'ttype'}};
53 if (my $subjectitems=$query->param('subjectitems')){
54 $search{'subject'} = $subjectitems;
55 $searchdesc.="subject = $subjectitems, ";
58 @$forminputs=() unless $forminputs;
59 $template->param(FORMINPUTS => $forminputs);
64 my $number_of_results = 20;
67 my $startfrom = $query->param('startfrom');
68 my $subjectitems=$query->param('subjectitems');
70 @results = subsearch($env,$subjectitems, $number_of_results, $startfrom);
73 ($count, @results) = catalogsearch($env,'',\%search,$number_of_results,$startfrom);
77 foreach my $res (@results) {
78 my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra");
80 foreach my $itm (@items) {
81 $norequests = 0 unless $itm->{'notforloan'};
83 $res->{'norequests'} = $norequests;
84 # set up the even odd elements....
85 $res->{'even'} = 1 if $num % 2 == 0;
86 $res->{'odd'} = 1 if $num % 2 == 1;
91 my $startfrom=$query->param('startfrom');
92 ($startfrom) || ($startfrom=0);
94 my $resultsarray=\@results;
95 ($resultsarray) || (@$resultsarray=());
98 # sorting out which results to display.
99 $template->param(startfrom => $startfrom+1);
100 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
101 $template->param(numrecords => $count);
102 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
103 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
104 $template->param(nextstartfrom => $nextstartfrom);
107 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
108 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
109 $template->param(displaynext => $displaynext);
110 $template->param(displayprev => $displayprev);
111 $template->param(prevstartfrom => $prevstartfrom);
113 $template->param(searchdesc => $searchdesc);
114 $template->param(SEARCH_RESULTS => $resultsarray);
119 for (my $i=1; $i<$count/10+1; $i++) {
121 my $themelang = $template->param('themelang');
122 ($startfrom==($i-1)*10) && ($highlight=1);
123 push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*10 };
127 $template->param(numbers => $numbers);
129 print $query->header(-cookie => $cookie), $template->output;