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;
81 if(not defined $marcresults){
82 $template->param(query => $query);
83 warn "no result found";
84 output_html_with_http_headers $input, $cookie, $template->output;
89 my $total = scalar @$marcresults;
90 my @newresults = searchResults( $query, $total, $results_per_page, $page, @$marcresults );
95 resultsloop => \@newresults,
96 pagination_bar => pagination_bar(
97 "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&",
98 getnbpages( $total, $results_per_page ),
105 # fill with books in breeding farm
107 my ( $title, $isbn );
109 # fill isbn or title, depending on what has been entered
110 #u must do check on isbn because u can find number in beginning of title
111 #check is on isbn legnth 13 for new isbn and 10 for old isbn
112 my $querylength = length($query);
113 if ( $query =~ /\d/ and ( $querylength eq 13 or $querylength eq 10 ) ) {
116 $title = $query unless $isbn;
117 my ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ) if $query;
118 my @breeding_loop = ();
119 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
127 $row_data{toggle} = $toggle;
128 $row_data{id} = $resultsbr[$i]->{'id'};
129 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
130 $row_data{file} = $resultsbr[$i]->{'file'};
131 $row_data{title} = $resultsbr[$i]->{'title'};
132 $row_data{author} = $resultsbr[$i]->{'author'};
133 push( @breeding_loop, \%row_data );
137 frameworkcodeloop => \@frameworkcodeloop,
138 breeding_loop => \@breeding_loop,
141 output_html_with_http_headers $input, $cookie, $template->output;