3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
27 use C4::Interface::CGI::Output;
32 my $offset = $input->param('offset');
33 my $num = $input->param('num');
37 my $marc_p = C4::Context->boolean_preference("marc");
38 my $dbh = C4::Context->dbh;
40 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42 template_name => "cataloguing/isbnsearch.tmpl",
46 flagsrequired => { editcatalogue => 1 },
51 # fill with books in ACTIVE DB (biblio)
55 if ( !$num ) { $num = 10 }
56 my @marclist = $input->param('marclist');
57 my @and_or = $input->param('and_or');
58 my @excluding = $input->param('excluding');
59 my @operator = $input->param('operator');
60 my @value = $input->param('value');
63 my $resultsperpage= $input->param('resultsperpage');
64 $resultsperpage = 10 if(!defined $resultsperpage);
65 my $startfrom=$input->param('startfrom');
66 $startfrom=0 if(!defined $startfrom);
67 my $orderby = $input->param('orderby');
68 my $desc_or_asc = $input->param('desc_or_asc');
70 # builds tag and subfield arrays
73 foreach my $marc (@marclist) {
75 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc,'');
77 push @tags,$dbh->quote("$tag$subfield");
79 push @tags, $dbh->quote(substr($marc,0,4));
85 findseealso($dbh,\@tags);
86 my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
87 \@excluding, \@operator, \@value,
88 $startfrom*$resultsperpage, $resultsperpage,'biblio.title','ASC');
91 # @results = @$resultsref;
95 # for ( my $i = $offset ; $i < $total ; $i++ ) {
101 # my %row_data; # get a fresh hash for the row data
102 # $row_data{toggle} = $toggle;
103 # $row_data{biblionumber} = $results[$i]->{'biblionumber'};
104 # $row_data{title} = $results[$i]->{'title'};
105 # $row_data{author} = $results[$i]->{'author'};
106 # $row_data{copyrightdate} = $results[$i]->{'copyrightdate'};
107 # $row_data{classification} = $results[$i]->{'classification'};
108 # $row_data{NOTMARC} = !$marc_p;
109 # push ( @loop_data, \%row_data );
111 # multi page display gestion
113 my $displayprev=$startfrom;
114 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
120 for(my $i = 0 ; $i <= $#marclist ; $i++) {
121 push @field_data, { term => "marclist", val=>$marclist[$i] };
122 push @field_data, { term => "and_or", val=>$and_or[$i] };
123 push @field_data, { term => "excluding", val=>$excluding[$i] };
124 push @field_data, { term => "operator", val=>$operator[$i] };
125 push @field_data, { term => "value", val=>$value[$i] };
130 if ($total>$resultsperpage) {
131 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
134 ($startfrom==($i-1)) && ($highlight=1);
135 push @numbers, { number => $i,
136 highlight => $highlight ,
137 searchdata=> \@field_data,
138 startfrom => ($i-1)};
142 my $from = $startfrom*$resultsperpage+1;
145 if($total < (($startfrom+1)*$resultsperpage))
149 $to = (($startfrom+1)*$resultsperpage);
152 # fill with books in breeding farm
154 my ( $countbr, @resultsbr ) = BreedingSearch( @value[0], @value[1] );
155 my @breeding_loop = ();
156 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
164 $row_data{toggle} = $toggle;
165 $row_data{id} = $resultsbr[$i]->{'id'};
166 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
167 $row_data{file} = $resultsbr[$i]->{'file'};
168 $row_data{title} = $resultsbr[$i]->{'title'};
169 $row_data{author} = $resultsbr[$i]->{'author'};
170 $row_data{NOTMARC}= !$marc_p;
171 push ( @breeding_loop, \%row_data );
175 my $frameworks = getframeworks;
176 my @frameworkcodeloop;
177 foreach my $thisframeworkcode (keys %$frameworks) {
178 my %row =(value => $thisframeworkcode,
179 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
181 push @frameworkcodeloop, \%row;
187 startfrom=> $startfrom,
188 displaynext=> $displaynext,
189 displayprev=> $displayprev,
190 resultsperpage => $resultsperpage,
191 startfromnext => $startfrom+1,
192 startfromprev => $startfrom-1,
193 searchdata=>\@field_data,
200 breeding_loop => \@breeding_loop,
202 frameworkcodeloop => \@frameworkcodeloop,
205 print $input->header(
206 -type => guesstype( $template->output ),