5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
22 =head1 cataloguing:addbooks.pl
39 my $success = $input->param('biblioitem');
40 my $query = $input->param('q');
41 my @value = $input->param('value');
42 my $page = $input->param('page') || 1;
43 my $results_per_page = 20;
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
48 template_name => "cataloguing/addbooks.tmpl",
52 flagsrequired => { editcatalogue => 1 },
58 my $frameworks = getframeworks;
59 my @frameworkcodeloop;
60 foreach my $thisframeworkcode ( keys %$frameworks ) {
62 value => $thisframeworkcode,
63 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
65 push @frameworkcodeloop, \%row;
68 # Searching the catalog.
72 my ( $error, $marcresults ) = SimpleSearch($query);
74 if ( defined $error ) {
75 $template->param( error => $error );
76 warn "error: " . $error;
77 output_html_with_http_headers $input, $cookie, $template->output;
82 my $total = scalar @$marcresults;
83 my @newresults = searchResults( $query, $total, $results_per_page, $page, @$marcresults );
88 resultsloop => \@newresults,
89 pagination_bar => pagination_bar(
90 "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&",
91 getnbpages( $total, $results_per_page ),
98 # fill with books in breeding farm
100 my ( $title, $isbn );
102 # fill isbn or title, depending on what has been entered
103 #u must do check on isbn because u can find number in beginning of title
104 #check is on isbn legnth 13 for new isbn and 10 for old isbn
105 my $querylength = length($query);
106 if ( $query =~ /\d/ and ( $querylength eq 13 or $querylength eq 10 ) ) {
109 $title = $query unless $isbn;
110 my ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ) if $query;
111 my @breeding_loop = ();
112 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
120 $row_data{toggle} = $toggle;
121 $row_data{id} = $resultsbr[$i]->{'id'};
122 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
123 $row_data{file} = $resultsbr[$i]->{'file'};
124 $row_data{title} = $resultsbr[$i]->{'title'};
125 $row_data{author} = $resultsbr[$i]->{'author'};
126 push( @breeding_loop, \%row_data );
130 frameworkcodeloop => \@frameworkcodeloop,
131 breeding_loop => \@breeding_loop,
134 output_html_with_http_headers $input, $cookie, $template->output;