4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 =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.tt",
52 flagsrequired
=> { editcatalogue
=> '*' },
58 my $frameworks = getframeworks
;
59 my @frameworkcodeloop;
60 foreach my $thisframeworkcode ( sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %{$frameworks} ) {
61 push @frameworkcodeloop, {
62 value
=> $thisframeworkcode,
63 frameworktext
=> $frameworks->{$thisframeworkcode}->{'frameworktext'},
68 # Searching the catalog.
72 my @operands = $query;
75 $QParser = C4
::Context
->queryparser if (C4
::Context
->preference('UseQueryParser'));
80 my ( $builterror,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
81 ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery
(undef,\
@operands);
85 my ( $error, $marcresults, $total_hits ) = SimpleSearch
($builtquery, $results_per_page * ($page - 1), $results_per_page);
87 if ( defined $error ) {
88 $template->param( error
=> $error );
89 warn "error: " . $error;
90 output_html_with_http_headers
$input, $cookie, $template->output;
95 # SimpleSearch() give the results per page we want, so 0 offet here
96 my $total = @
{$marcresults};
97 my @newresults = searchResults
( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults );
98 foreach my $line (@newresults) {
99 if ( not exists $line->{'size'} ) { $line->{'size'} = "" }
102 total
=> $total_hits,
104 resultsloop
=> \
@newresults,
105 pagination_bar
=> pagination_bar
( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages
( $total_hits, $results_per_page ), $page, 'page' ),
109 # fill with books in breeding farm
114 # fill isbn or title, depending on what has been entered
115 #u must do check on isbn because u can find number in beginning of title
116 #check is on isbn legnth 13 for new isbn and 10 for old isbn
117 my ( $title, $isbn );
119 my $clean_query = $query;
120 $clean_query =~ s/-//g; # remove hyphens
121 my $querylength = length $clean_query;
122 if ( $querylength == 13 || $querylength == 10 ) {
129 ( $countbr, @resultsbr ) = BreedingSearch
( $title, $isbn );
131 my $breeding_loop = [];
132 for my $resultsbr (@resultsbr) {
133 push @
{$breeding_loop}, {
134 id
=> $resultsbr->{import_record_id
},
135 isbn
=> $resultsbr->{isbn
},
136 copyrightdate
=> $resultsbr->{copyrightdate
},
137 editionstatement
=> $resultsbr->{editionstatement
},
138 file
=> $resultsbr->{file_name
},
139 title
=> $resultsbr->{title
},
140 author
=> $resultsbr->{author
},
145 frameworkcodeloop
=> \
@frameworkcodeloop,
146 breeding_count
=> $countbr,
147 breeding_loop
=> $breeding_loop,
148 z3950_search_params
=> C4
::Search
::z3950_search_args
($query),
151 output_html_with_http_headers
$input, $cookie, $template->output;