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
28 use C4::Interface::CGI::Output;
33 my $offset = $input->param('offset');
34 my $num = $input->param('num');
38 my $marc_p = C4::Context->boolean_preference("marc");
39 my $dbh = C4::Context->dbh;
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "cataloguing/isbnsearch.tmpl",
47 flagsrequired => { editcatalogue => 1 },
52 # fill with books in ACTIVE DB (biblio)
56 if ( !$num ) { $num = 10 }
57 my @marclist = $input->param('marclist');
58 my @and_or = $input->param('and_or');
59 my @excluding = $input->param('excluding');
60 my @operator = $input->param('operator');
61 my @value = $input->param('value');
64 my $resultsperpage= $input->param('resultsperpage');
65 $resultsperpage = 10 if(!defined $resultsperpage);
66 my $startfrom=$input->param('startfrom');
67 $startfrom=0 if(!defined $startfrom);
68 my $orderby = $input->param('orderby');
69 my $desc_or_asc = $input->param('desc_or_asc');
71 # builds tag and subfield arrays
74 foreach my $marc (@marclist) {
76 my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc,'');
78 push @tags,$dbh->quote("$tag$subfield");
80 push @tags, $dbh->quote(substr($marc,0,4));
86 findseealso($dbh,\@tags);
87 my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
88 \@excluding, \@operator, \@value,
89 $startfrom*$resultsperpage, $resultsperpage,'biblio.title','ASC');
90 # @results = @$resultsref;
94 # for ( my $i = $offset ; $i < $total ; $i++ ) {
100 # my %row_data; # get a fresh hash for the row data
101 # $row_data{toggle} = $toggle;
102 # $row_data{biblionumber} = $results[$i]->{'biblionumber'};
103 # $row_data{title} = $results[$i]->{'title'};
104 # $row_data{author} = $results[$i]->{'author'};
105 # $row_data{copyrightdate} = $results[$i]->{'copyrightdate'};
106 # $row_data{classification} = $results[$i]->{'classification'};
107 # $row_data{NOTMARC} = !$marc_p;
108 # push ( @loop_data, \%row_data );
110 # multi page display gestion
112 my $displayprev=$startfrom;
113 if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
119 for(my $i = 0 ; $i <= $#marclist ; $i++) {
120 push @field_data, { term => "marclist", val=>$marclist[$i] };
121 push @field_data, { term => "and_or", val=>$and_or[$i] };
122 push @field_data, { term => "excluding", val=>$excluding[$i] };
123 push @field_data, { term => "operator", val=>$operator[$i] };
124 push @field_data, { term => "value", val=>$value[$i] };
129 if ($total>$resultsperpage) {
130 for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
133 ($startfrom==($i-1)) && ($highlight=1);
134 push @numbers, { number => $i,
135 highlight => $highlight ,
136 searchdata=> \@field_data,
137 startfrom => ($i-1)};
141 my $from = $startfrom*$resultsperpage+1;
144 if($total < (($startfrom+1)*$resultsperpage))
148 $to = (($startfrom+1)*$resultsperpage);
151 # fill with books in breeding farm
153 my ( $countbr, @resultsbr ) = BreedingSearch( @value[0], @value[1] );
154 my @breeding_loop = ();
155 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
163 $row_data{toggle} = $toggle;
164 $row_data{id} = $resultsbr[$i]->{'id'};
165 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
166 $row_data{file} = $resultsbr[$i]->{'file'};
167 $row_data{title} = $resultsbr[$i]->{'title'};
168 $row_data{author} = $resultsbr[$i]->{'author'};
169 $row_data{NOTMARC}= !$marc_p;
170 push ( @breeding_loop, \%row_data );
174 my $frameworks = getframeworks;
175 my @frameworkcodeloop;
176 foreach my $thisframeworkcode (keys %$frameworks) {
177 my %row =(value => $thisframeworkcode,
178 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
180 push @frameworkcodeloop, \%row;
186 startfrom=> $startfrom,
187 displaynext=> $displaynext,
188 displayprev=> $displayprev,
189 resultsperpage => $resultsperpage,
190 startfromnext => $startfrom+1,
191 startfromprev => $startfrom-1,
192 searchdata=>\@field_data,
199 breeding_loop => \@breeding_loop,
201 frameworkcodeloop => \@frameworkcodeloop,
204 print $input->header(
205 -type => guesstype( $template->output ),