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;
42 my $marc_p = C4::Context->boolean_preference("marc");
43 my $SQLorZEBRA=C4::Context->preference("SQLorZEBRA");
44 if ( !$isbn && !$title ) {
45 print $input->redirect('addbooks.pl');
48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
50 template_name => "cataloguing/isbnsearch.tmpl",
54 flagsrequired => { editcatalogue => 1 },
59 # fill with books in ACTIVE DB (biblio)
64 if ( !$num ) { $num = 10 }
71 $search{'isbn'}=$isbn;
72 push @kohafield, "isbn";
75 $search{'title'}=$title;
76 push @kohafield, "title";
78 push @relation, "\@attr 5=1 \@attr 6=3 \@attr 4=1 \@attr 3=1 ";
80 $search{avoidquerylog}=1;
81 if ($SQLorZEBRA eq "sql"){
82 ($count, @results) =cataloguing_search(\%search,$num,$offset);
84 ($count,@results) =ZEBRAsearch_kohafields(\@kohafield,\@value, \@relation,$order, \@and_or, 1,"",$offset, $num,"intranet");
87 my $grandtotal=$count;
88 if ( $count < ( $offset + $num ) ) {
92 $total = $offset + $num;
97 @loop_data=@results if $count >0;;
98 $template->param( startfrom => $offset + 1 );
99 ( $offset + $num <= $count )
100 ? ( $template->param( endat => $offset + $num ) )
101 : ( $template->param( endat => $count ) );
102 $template->param( numrecords => $count );
103 my $nextstartfrom = ( $offset + $num < $count ) ? ( $offset + $num ) : (-1);
104 my $prevstartfrom = ( $offset - $num >= 0 ) ? ( $offset - $num ) : (-1);
105 $template->param( nextstartfrom => $nextstartfrom );
108 ( $nextstartfrom == -1 ) ? ( $displaynext = 0 ) : ( $displaynext = 1 );
109 ( $prevstartfrom == -1 ) ? ( $displayprev = 0 ) : ( $displayprev = 1 );
110 $template->param( displaynext => $displaynext );
111 $template->param( displayprev => $displayprev );
125 for ( my $i = 1 ; $i < $count / 10 + 1 ; $i++ ) {
128 ( $offset == ( $i - 1 ) * 10 ) && ( $highlight = 1 );
132 highlight => $highlight,
135 startfrom => ( $i - 1 ) * 10
141 # fill with books in breeding farm
142 ( $count, @results ) = BreedingSearch( $title, $isbn );
143 my @breeding_loop = ();
144 for ( my $i = 0 ; $i <= $#results ; $i++ ) {
152 $row_data{toggle} = $toggle;
153 $row_data{id} = $results[$i]->{'id'};
154 $row_data{isbn} = $results[$i]->{'isbn'};
155 $row_data{file} = $results[$i]->{'file'};
156 $row_data{title} = $results[$i]->{'title'};
157 $row_data{author} = $results[$i]->{'author'};
158 $row_data{classification} = $results[$i]->{'classification'};
159 $row_data{subclass} = $results[$i]->{'subclass'};
160 push ( @breeding_loop, \%row_data );
163 my $frameworks = getframeworks;
164 my @frameworkcodeloop;
165 foreach my $thisframeworkcode (keys %$frameworks) {
166 my %row =(value => $thisframeworkcode,
167 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
169 push @frameworkcodeloop, \%row;
176 showoffset => $showoffset,
178 grandtotal => $grandtotal,
180 results_loop => \@loop_data,
181 breeding_loop => \@breeding_loop,
182 numbers => \@numbers,
185 frameworkcodeloop => \@frameworkcodeloop
188 output_html_with_http_headers $input, $cookie, $template->output;