6 use C4::Interface::CGI::Output;
17 my $dbh=C4::Context->dbh;
18 my $sth=$dbh->prepare("select description,itemtype from itemtypes order by description");
20 while (my ($description,$itemtype) = $sth->fetchrow) {
21 $classlist.="<option value=\"$itemtype\">$description</option>\n";
26 my $op = $query->param("op");
27 my $type=$query->param('type');
29 my $startfrom=$query->param('startfrom');
30 $startfrom=0 if(!defined $startfrom);
31 my ($template, $loggedinuser, $cookie);
34 if ($op eq "do_search") {
35 my @marclist = $query->param('marclist');
36 my @and_or = $query->param('and_or');
37 my @excluding = $query->param('excluding');
38 my @operator = $query->param('operator');
39 my @value = $query->param('value');
41 $resultsperpage= $query->param('resultsperpage');
42 $resultsperpage = 19 if(!defined $resultsperpage);
43 my $orderby = $query->param('orderby');
45 # builds tag and subfield arrays
48 foreach my $marc (@marclist) {
50 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc);
52 push @tags,$dbh->quote("$tag$subfield");
54 push @tags, $dbh->quote(substr($marc,0,4));
60 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,
125 startfromnext => $startfrom+1,
126 startfromprev => $startfrom-1,
127 searchdata=>\@field_data,
135 ($template, $loggedinuser, $cookie)
136 = get_template_and_user({template_name => "opac-search.tmpl",
139 authnotrequired => 1,
143 $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
149 while (my ($value,$lib) = $sth->fetchrow_array) {
150 push @itemtype, $value;
151 $itemtypes{$value}=$lib;
154 my $CGIitemtype=CGI::scrolling_list( -name => 'value',
155 -values => \@itemtype,
156 -labels => \%itemtypes,
164 my ($count2,@branches)=branches();
165 push @select_branch, "";
166 $select_branches{''} = "";
167 for (my $i=0;$i<$count2;$i++){
168 push @select_branch, $branches[$i]->{'branchcode'};#
169 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
171 my $CGIbranch=CGI::scrolling_list( -name => 'value',
172 -values => \@select_branch,
173 -labels => \%select_branches,
178 $template->param(classlist => $classlist,
179 CGIitemtype => $CGIitemtype,
180 CGIbranch => $CGIbranch,
184 output_html_with_http_headers $query, $cookie, $template->output;