Removing noisy warn in C4/XSLT.pm
[koha.git] / cataloguing / addbooks.pl
blobe9113918aacf9794426710ef0881512707a37d12
1 #!/usr/bin/perl
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
11 # version.
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 with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
21 =head1 cataloguing:addbooks.pl
23 TODO
25 =cut
27 use strict;
28 use warnings;
29 use CGI;
30 use C4::Auth;
31 use C4::Biblio;
32 use C4::Breeding;
33 use C4::Output;
34 use C4::Koha;
35 use C4::Search;
37 my $input = new CGI;
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",
49 query => $input,
50 type => "intranet",
51 authnotrequired => 0,
52 flagsrequired => { editcatalogue => 'edit_catalogue' },
53 debug => 1,
57 # get framework list
58 my $frameworks = getframeworks;
59 my @frameworkcodeloop;
60 foreach my $thisframeworkcode ( sort {$frameworks->{$a} cmp $frameworks->{$b}}keys %{$frameworks} ) {
61 push @frameworkcodeloop, {
62 value => $thisframeworkcode,
63 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
68 # Searching the catalog.
69 if ($query) {
71 # find results
72 my ( $error, $marcresults, $total_hits ) = SimpleSearch($query, $results_per_page * ($page - 1), $results_per_page);
74 if ( defined $error ) {
75 $template->param( error => $error );
76 warn "error: " . $error;
77 output_html_with_http_headers $input, $cookie, $template->output;
78 exit;
81 # format output
82 # SimpleSearch() give the results per page we want, so 0 offet here
83 my $total = scalar @$marcresults;
84 my @newresults = searchResults( $query, $total, $results_per_page, 0, 0, @$marcresults );
85 $template->param(
86 total => $total_hits,
87 query => $query,
88 resultsloop => \@newresults,
89 pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
93 # fill with books in breeding farm
95 my $countbr = 0;
96 my @resultsbr;
97 if ($query) {
98 # fill isbn or title, depending on what has been entered
99 #u must do check on isbn because u can find number in beginning of title
100 #check is on isbn legnth 13 for new isbn and 10 for old isbn
101 my ( $title, $isbn );
102 if ($query=~/\d/) {
103 my $querylength = length $query;
104 if ( $querylength == 13 || $querylength == 10 ) {
105 $isbn = $query;
108 if (!$isbn) {
109 $title = $query;
111 ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
113 my $breeding_loop = [];
114 for my $resultsbr (@resultsbr) {
115 push @{$breeding_loop}, {
116 id => $resultsbr->{import_record_id},
117 isbn => $resultsbr->{isbn},
118 copyrightdate => $resultsbr->{copyrightdate},
119 editionstatement => $resultsbr->{editionstatement},
120 file => $resultsbr->{file_name},
121 title => $resultsbr->{title},
122 author => $resultsbr->{author},
126 $template->param(
127 frameworkcodeloop => \@frameworkcodeloop,
128 breeding_count => $countbr,
129 breeding_loop => $breeding_loop,
130 z3950_search_params => C4::Search::z3950_search_args($query),
133 output_html_with_http_headers $input, $cookie, $template->output;