6 use C4::Interface::CGI::Output;
18 my $dbh=C4::Context->dbh;
19 my $sth=$dbh->prepare("select description,itemtype from itemtypes order by description");
21 while (my ($description,$itemtype) = $sth->fetchrow) {
22 $classlist.="<option value=\"$itemtype\">$description</option>\n";
27 my $op = $query->param("op");
28 my $type=$query->param('type');
30 my $startfrom=$query->param('startfrom');
31 $startfrom=0 if(!defined $startfrom);
32 my ($template, $loggedinuser, $cookie);
35 if ($op eq "do_search") {
36 my @marclist = $query->param('marclist');
37 my @and_or = $query->param('and_or');
38 my @excluding = $query->param('excluding');
39 my @operator = $query->param('operator');
40 my @value = $query->param('value');
42 $resultsperpage= $query->param('resultsperpage');
43 $resultsperpage = 19 if(!defined $resultsperpage);
44 my $orderby = $query->param('orderby');
46 # builds tag and subfield arrays
49 foreach my $marc (@marclist) {
51 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc,'');
53 push @tags,$dbh->quote("$tag$subfield");
55 push @tags, $dbh->quote(substr($marc,0,4));
61 findseealso($dbh,\@tags);
62 my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
63 \@excluding, \@operator, \@value,
64 $startfrom*$resultsperpage, $resultsperpage,$orderby);
66 ($template, $loggedinuser, $cookie)
67 = get_template_and_user({template_name => "opac-searchresults.tmpl",
74 # multi page display gestion
76 my $displayprev=$startfrom;
77 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
84 for(my $i = 0 ; $i <= $#marclist ; $i++)
86 push @field_data, { term => "marclist", val=>$marclist[$i] };
87 push @field_data, { term => "and_or", val=>$and_or[$i] };
88 push @field_data, { term => "excluding", val=>$excluding[$i] };
89 push @field_data, { term => "operator", val=>$operator[$i] };
90 push @field_data, { term => "value", val=>$value[$i] };
95 if ($total>$resultsperpage)
97 for (my $i=1; $i<$total/$resultsperpage+1; $i++)
102 ($startfrom==($i-1)) && ($highlight=1);
103 push @numbers, { number => $i,
104 highlight => $highlight ,
105 searchdata=> \@field_data,
106 startfrom => ($i-1)};
111 my $from = $startfrom*$resultsperpage+1;
114 if($total < (($startfrom+1)*$resultsperpage))
118 $to = (($startfrom+1)*$resultsperpage);
120 $template->param(results => $results,
121 startfrom=> $startfrom,
122 displaynext=> $displaynext,
123 displayprev=> $displayprev,
124 resultsperpage => $resultsperpage,
126 startfromnext => $startfrom+1,
127 startfromprev => $startfrom-1,
128 searchdata=>\@field_data,
136 ($template, $loggedinuser, $cookie)
137 = get_template_and_user({template_name => "opac-search.tmpl",
140 authnotrequired => 1,
144 $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
150 while (my ($value,$lib) = $sth->fetchrow_array) {
151 push @itemtype, $value;
152 $itemtypes{$value}=$lib;
155 my $CGIitemtype=CGI::scrolling_list( -name => 'value',
156 -values => \@itemtype,
157 -labels => \%itemtypes,
165 my ($count2,@branches)=branches();
166 push @select_branch, "";
167 $select_branches{''} = "";
168 for (my $i=0;$i<$count2;$i++){
169 push @select_branch, $branches[$i]->{'branchcode'};#
170 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
172 my $CGIbranch=CGI::scrolling_list( -name => 'value',
173 -values => \@select_branch,
174 -labels => \%select_branches,
179 $template->param(classlist => $classlist,
180 CGIitemtype => $CGIitemtype,
181 CGIbranch => $CGIbranch,
185 output_html_with_http_headers $query, $cookie, $template->output;