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 $isbn = $input->param('isbn');
33 my $title = $input->param('title');
34 my $offset = $input->param('offset');
35 my $num = $input->param('num');
36 my $showoffset = $offset + 1;
43 my $marc_p = C4::Context->boolean_preference("marc");
44 my $SQLorZEBRA=C4::Context->preference("SQLorZEBRA");
45 if ( !$isbn && !$title ) {
46 print $input->redirect('addbooks.pl');
49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51 template_name => "cataloguing/isbnsearch.tmpl",
55 flagsrequired => { editcatalogue => 1 },
60 # fill with books in ACTIVE DB (biblio)
65 if ( !$num ) { $num = 10 }
72 $search{'isbn'}=$isbn;
73 push @kohafield, "isbn";
76 $search{'title'}=$title;
77 push @kohafield, "title";
79 push @relation, "\@attr 5=1 \@attr 6=3 \@attr 4=1 \@attr 3=1 ";
81 $search{avoidquerylog}=1;
82 if ($SQLorZEBRA eq "sql"){
83 ($count, @results) =cataloguing_search(\%search,$num,$offset);
85 ($count,$facets,@results) =ZEBRAsearch_kohafields(\@kohafield,\@value, \@relation,$order, \@and_or, 1,"",$offset, $num,"intranet");
88 my $grandtotal=$count;
89 if ( $count < ( $offset + $num ) ) {
93 $total = $offset + $num;
98 @loop_data=@results if $count >0;;
99 $template->param( startfrom => $offset + 1 );
100 ( $offset + $num <= $count )
101 ? ( $template->param( endat => $offset + $num ) )
102 : ( $template->param( endat => $count ) );
103 $template->param( numrecords => $count );
104 my $nextstartfrom = ( $offset + $num < $count ) ? ( $offset + $num ) : (-1);
105 my $prevstartfrom = ( $offset - $num >= 0 ) ? ( $offset - $num ) : (-1);
106 $template->param( nextstartfrom => $nextstartfrom );
109 ( $nextstartfrom == -1 ) ? ( $displaynext = 0 ) : ( $displaynext = 1 );
110 ( $prevstartfrom == -1 ) ? ( $displayprev = 0 ) : ( $displayprev = 1 );
111 $template->param( displaynext => $displaynext );
112 $template->param( displayprev => $displayprev );
126 for ( my $i = 1 ; $i < $count / 10 + 1 ; $i++ ) {
129 ( $offset == ( $i - 1 ) * 10 ) && ( $highlight = 1 );
133 highlight => $highlight,
136 startfrom => ( $i - 1 ) * 10
142 # fill with books in breeding farm
143 ( $count, @results ) = BreedingSearch( $title, $isbn );
144 my @breeding_loop = ();
145 for ( my $i = 0 ; $i <= $#results ; $i++ ) {
153 $row_data{toggle} = $toggle;
154 $row_data{id} = $results[$i]->{'id'};
155 $row_data{isbn} = $results[$i]->{'isbn'};
156 $row_data{file} = $results[$i]->{'file'};
157 $row_data{title} = $results[$i]->{'title'};
158 $row_data{author} = $results[$i]->{'author'};
159 $row_data{classification} = $results[$i]->{'classification'};
160 $row_data{subclass} = $results[$i]->{'subclass'};
161 push ( @breeding_loop, \%row_data );
164 my $frameworks = getframeworks;
165 my @frameworkcodeloop;
166 foreach my $thisframeworkcode (keys %$frameworks) {
167 my %row =(value => $thisframeworkcode,
168 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
170 push @frameworkcodeloop, \%row;
177 showoffset => $showoffset,
179 grandtotal => $grandtotal,
181 results_loop => \@loop_data,
182 breeding_loop => \@breeding_loop,
183 numbers => \@numbers,
186 frameworkcodeloop => \@frameworkcodeloop
189 output_html_with_http_headers $input, $cookie, $template->output;