2 # WARNING: 4-character tab stops here
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
29 use C4::Interface::CGI::Output;
33 my $type=$query->param('type');
34 my $op = $query->param('op');
35 my $dbh = C4::Context->dbh;
37 my $startfrom=$query->param('startfrom');
38 $startfrom=0 if(!defined $startfrom);
39 my ($template, $loggedinuser, $cookie);
42 if ($op eq "do_search") {
43 my @marclist = $query->param('marclist');
44 my @and_or = $query->param('and_or');
45 my @excluding = $query->param('excluding');
46 my @operator = $query->param('operator');
47 my @value = $query->param('value');
49 $resultsperpage= $query->param('resultsperpage');
50 $resultsperpage = 19 if(!defined $resultsperpage);
51 my $orderby = $query->param('orderby');
53 # builds tag and subfield arrays
56 foreach my $marc (@marclist) {
58 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc);
60 push @tags,$dbh->quote("$tag$subfield");
62 push @tags, $dbh->quote(substr($marc,0,4));
68 my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
69 \@excluding, \@operator, \@value,
70 $startfrom*$resultsperpage, $resultsperpage,$orderby);
72 ($template, $loggedinuser, $cookie)
73 = get_template_and_user({template_name => "serials/result.tmpl",
77 flagsrequired => {borrowers => 1},
78 flagsrequired => {catalogue => 1},
82 # multi page display gestion
84 my $displayprev=$startfrom;
85 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
92 for(my $i = 0 ; $i <= $#marclist ; $i++)
94 push @field_data, { term => "marclist", val=>$marclist[$i] };
95 push @field_data, { term => "and_or", val=>$and_or[$i] };
96 push @field_data, { term => "excluding", val=>$excluding[$i] };
97 push @field_data, { term => "operator", val=>$operator[$i] };
98 push @field_data, { term => "value", val=>$value[$i] };
103 if ($total>$resultsperpage)
105 for (my $i=1; $i<$total/$resultsperpage+1; $i++)
110 ($startfrom==($i-1)) && ($highlight=1);
111 push @numbers, { number => $i,
112 highlight => $highlight ,
113 searchdata=> \@field_data,
114 startfrom => ($i-1)};
119 my $from = $startfrom*$resultsperpage+1;
122 if($total < (($startfrom+1)*$resultsperpage))
126 $to = (($startfrom+1)*$resultsperpage);
128 $template->param(result => $results,
129 startfrom=> $startfrom,
130 displaynext=> $displaynext,
131 displayprev=> $displayprev,
132 resultsperpage => $resultsperpage,
133 startfromnext => $startfrom+1,
134 startfromprev => $startfrom-1,
135 searchdata=>\@field_data,
142 ($template, $loggedinuser, $cookie)
143 = get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
146 authnotrequired => 0,
147 flagsrequired => {catalogue => 1},
150 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
156 while (my ($value,$lib) = $sth->fetchrow_array) {
157 push @itemtype, $value;
158 $itemtypes{$value}=$lib;
161 my $CGIitemtype=CGI::scrolling_list( -name => 'value',
162 -values => \@itemtype,
163 -labels => \%itemtypes,
169 CGIitemtype => $CGIitemtype,
175 output_html_with_http_headers $query, $cookie, $template->output;