7 use C4::Output; # now contains gettemplate
12 $flagsrequired->{borrow}=1;
14 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired);
17 my $template = gettemplate ("opac-searchresults.tmpl", "opac");
21 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 ...
38 foreach my $field (@fields) {
39 $search{$field} = $query->param($field);
40 if ($search{$field}) {
41 push @$forminputs, {field => $field, value => $search{$field}};
42 $searchdesc .= "$field = $search{$field}, ";
45 $search{'ttype'} = $query->param('ttype');
46 push @$forminputs, {field => 'ttype', value => $search{'ttype'}};
48 if (my $subjectitems=$query->param('subjectitems')){
49 $search{'subject'} = $subjectitems;
50 $searchdesc.="subject = $subjectitems, ";
53 @$forminputs=() unless $forminputs;
54 $template->param(FORMINPUTS => $forminputs);
62 my $startfrom = $query->param('startfrom');
63 my $subjectitems=$query->param('subjectitems');
65 @results = subsearch($env,$subjectitems, $num, $startfrom);
68 ($count, @results) = catalogsearch($env,'',\%search,$num,$startfrom);
71 foreach my $res (@results) {
72 my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra");
74 foreach my $itm (@items) {
75 $norequests = 0 unless $itm->{'notforloan'};
77 $res->{'norequests'} = $norequests;
81 my $startfrom=$query->param('startfrom');
82 ($startfrom) || ($startfrom=0);
84 my $resultsarray=\@results;
85 ($resultsarray) || (@$resultsarray=());
88 # sorting out which results to display.
89 $template->param(startfrom => $startfrom+1);
90 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
91 $template->param(numrecords => $count);
92 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
93 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
94 $template->param(nextstartfrom => $nextstartfrom);
97 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
98 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
99 $template->param(displaynext => $displaynext);
100 $template->param(displayprev => $displayprev);
101 $template->param(prevstartfrom => $prevstartfrom);
103 $template->param(searchdesc => $searchdesc);
104 $template->param(SEARCH_RESULTS => $resultsarray);
105 $template->param(loggedinuser => $loggedinuser);
110 for (my $i=1; $i<$count/10+1; $i++) {
112 my $themelang = $template->param('themelang');
113 ($startfrom==($i-1)*10) && ($highlight=1);
114 push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*10 };
118 $template->param(numbers => $numbers);
120 $template->param(loggedinuser => $loggedinuser);
122 print $query->header(-cookie => $cookie), $template->output;