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
26 use C4::Interface::CGI::Output;
31 my $isbn = $input->param('isbn');
32 my $title = $input->param('title');
33 my $offset = $input->param('offset');
34 my $num = $input->param('num');
35 my $showoffset = $offset + 1;
39 my $marc_p = C4::Context->boolean_preference("marc");
41 if ( !$isbn && !$title ) {
42 print $input->redirect('addbooks.pl');
45 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 template_name => "acqui.simple/isbnsearch.tmpl",
51 flagsrequired => { catalogue => 1 },
56 # fill with books in ACTIVE DB (biblio)
61 if ( !$num ) { $num = 10 }
62 ( $count, @results ) = isbnsearch( $isbn, $title );
64 if ( $count < ( $offset + $num ) ) {
68 $total = $offset + $num;
73 for ( my $i = $offset ; $i < $total ; $i++ ) {
79 my %row_data; # get a fresh hash for the row data
80 $row_data{toggle} = $toggle;
81 $row_data{biblionumber} = $results[$i]->{'biblionumber'};
82 $row_data{title} = $results[$i]->{'title'};
83 $row_data{author} = $results[$i]->{'author'};
84 $row_data{copyrightdate} = $results[$i]->{'copyrightdate'};
85 $row_data{classification} = $results[$i]->{'classification'};
86 $row_data{NOTMARC} = !$marc_p;
87 push ( @loop_data, \%row_data );
89 $template->param( startfrom => $offset + 1 );
90 ( $offset + $num <= $count )
91 ? ( $template->param( endat => $offset + $num ) )
92 : ( $template->param( endat => $count ) );
93 $template->param( numrecords => $count );
94 my $nextstartfrom = ( $offset + $num < $count ) ? ( $offset + $num ) : (-1);
95 my $prevstartfrom = ( $offset - $num >= 0 ) ? ( $offset - $num ) : (-1);
96 $template->param( nextstartfrom => $nextstartfrom );
99 ( $nextstartfrom == -1 ) ? ( $displaynext = 0 ) : ( $displaynext = 1 );
100 ( $prevstartfrom == -1 ) ? ( $displayprev = 0 ) : ( $displayprev = 1 );
101 $template->param( displaynext => $displaynext );
102 $template->param( displayprev => $displayprev );
116 for ( my $i = 1 ; $i < $count / 10 + 1 ; $i++ ) {
119 ( $offset == ( $i - 1 ) * 10 ) && ( $highlight = 1 );
123 highlight => $highlight,
126 startfrom => ( $i - 1 ) * 10
132 # fill with books in breeding farm
133 ( $count, @results ) = breedingsearch( $title, $isbn );
134 my @breeding_loop = ();
135 for ( my $i = 0 ; $i <= $#results ; $i++ ) {
143 $row_data{toggle} = $toggle;
144 $row_data{id} = $results[$i]->{'id'};
145 $row_data{isbn} = $results[$i]->{'isbn'};
146 $row_data{file} = $results[$i]->{'file'};
147 $row_data{title} = $results[$i]->{'title'};
148 $row_data{author} = $results[$i]->{'author'};
149 $row_data{NOTMARC}= !$marc_p;
150 push ( @breeding_loop, \%row_data );
155 my $frameworks = getframeworks;
156 my @frameworkcodeloop;
157 foreach my $thisframeworkcode (keys %$frameworks) {
158 my %row =(value => $thisframeworkcode,
159 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
161 push @frameworkcodeloop, \%row;
167 showoffset => $showoffset,
171 breeding_loop => \@breeding_loop,
172 numbers => \@numbers,
176 frameworkcodeloop => \@frameworkcodeloop,
179 print $input->header(
180 -type => guesstype( $template->output ),