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 => "acqui.simple/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 = 5 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,'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] };
127 if ( $count < ( $offset + $num ) ) {
131 $total = $offset + $num;
136 for ( my $i = $offset ; $i < $total ; $i++ ) {
142 my %row_data; # get a fresh hash for the row data
143 $row_data{toggle} = $toggle;
144 $row_data{biblionumber} = $results[$i]->{'biblionumber'};
145 $row_data{title} = $results[$i]->{'title'};
146 $row_data{author} = $results[$i]->{'author'};
147 $row_data{copyrightdate} = $results[$i]->{'copyrightdate'};
148 $row_data{classification} = $results[$i]->{'classification'};
149 $row_data{NOTMARC} = !$marc_p;
150 push ( @loop_data, \%row_data );
152 $template->param( startfrom => $offset + 1 );
153 ( $offset + $num <= $count )
154 ? ( $template->param( endat => $offset + $num ) )
155 : ( $template->param( endat => $count ) );
156 $template->param( numrecords => $count );
157 my $nextstartfrom = ( $offset + $num < $count ) ? ( $offset + $num ) : (-1);
158 my $prevstartfrom = ( $offset - $num >= 0 ) ? ( $offset - $num ) : (-1);
159 $template->param( nextstartfrom => $nextstartfrom );
162 ( $nextstartfrom == -1 ) ? ( $displaynext = 0 ) : ( $displaynext = 1 );
163 ( $prevstartfrom == -1 ) ? ( $displayprev = 0 ) : ( $displayprev = 1 );
164 $template->param( displaynext => $displaynext );
165 $template->param( displayprev => $displayprev );
179 for ( my $i = 1 ; $i < $count / 10 + 1 ; $i++ ) {
182 ( $offset == ( $i - 1 ) * 10 ) && ( $highlight = 1 );
186 highlight => $highlight,
189 startfrom => ( $i - 1 ) * 10
195 # fill with books in breeding farm
197 my ( $countbr, @resultsbr ) = BreedingSearch( @value[0], @value[1] );
198 my @breeding_loop = ();
199 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
207 $row_data{toggle} = $toggle;
208 $row_data{id} = $resultsbr[$i]->{'id'};
209 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
210 $row_data{file} = $resultsbr[$i]->{'file'};
211 $row_data{title} = $resultsbr[$i]->{'title'};
212 $row_data{author} = $resultsbr[$i]->{'author'};
213 $row_data{NOTMARC}= !$marc_p;
214 push ( @breeding_loop, \%row_data );
218 my $frameworks = getframeworks;
219 my @frameworkcodeloop;
220 foreach my $thisframeworkcode (keys %$frameworks) {
221 my %row =(value => $thisframeworkcode,
222 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
224 push @frameworkcodeloop, \%row;
230 startfrom=> $startfrom,
231 displaynext=> $displaynext,
232 displayprev=> $displayprev,
233 resultsperpage => $resultsperpage,
234 startfromnext => $startfrom+1,
235 startfromprev => $startfrom-1,
236 searchdata=>\@field_data,
243 breeding_loop => \@breeding_loop,
245 frameworkcodeloop => \@frameworkcodeloop,
248 print $input->header(
249 -type => guesstype( $template->output ),