Add Getopt::Long to fines.pl, and option to specify log output directory.
[koha.git] / cataloguing / addbooks.pl
blob045a4eed90f8e44d6cc1a1e5f6d0d42472af20e8
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 CGI;
29 use C4::Auth;
30 use C4::Biblio;
31 use C4::Breeding;
32 use C4::Output;
33 use C4::Koha;
34 use C4::Search;
36 my $input = new CGI;
38 my $success = $input->param('biblioitem');
39 my $query = $input->param('q');
40 my @value = $input->param('value');
41 my $page = $input->param('page') || 1;
42 my $results_per_page = 20;
45 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 template_name => "cataloguing/addbooks.tmpl",
48 query => $input,
49 type => "intranet",
50 authnotrequired => 0,
51 flagsrequired => { editcatalogue => 1 },
52 debug => 1,
56 # get framework list
57 my $frameworks = getframeworks;
58 my @frameworkcodeloop;
59 foreach my $thisframeworkcode ( keys %$frameworks ) {
60 my %row = (
61 value => $thisframeworkcode,
62 frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
64 push @frameworkcodeloop, \%row;
67 # Searching the catalog.
68 if ($query) {
70 # find results
71 my ( $error, $marcresults, $total_hits ) = SimpleSearch($query, $results_per_page * ($page - 1), $results_per_page);
73 if ( defined $error ) {
74 $template->param( error => $error );
75 warn "error: " . $error;
76 output_html_with_http_headers $input, $cookie, $template->output;
77 exit;
80 # format output
81 my $total = scalar @$marcresults;
82 my @newresults = searchResults( $query, $total, $results_per_page, $page-1, 0, @$marcresults );
83 $template->param(
84 total => $total_hits,
85 query => $query,
86 resultsloop => \@newresults,
87 pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
91 # fill with books in breeding farm
92 my $toggle = 0;
93 my ( $title, $isbn );
95 # fill isbn or title, depending on what has been entered
96 #u must do check on isbn because u can find number in beginning of title
97 #check is on isbn legnth 13 for new isbn and 10 for old isbn
98 my $querylength = length($query);
99 if ( $query =~ /\d/ and ( $querylength eq 13 or $querylength eq 10 ) ) {
100 $isbn = $query;
102 $title = $query unless $isbn;
103 my ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ) if $query;
104 my @breeding_loop = ();
105 for ( my $i = 0 ; $i <= $#resultsbr ; $i++ ) {
106 my %row_data;
107 if ( $i % 2 ) {
108 $toggle = 0;
110 else {
111 $toggle = 1;
113 $row_data{toggle} = $toggle;
114 $row_data{id} = $resultsbr[$i]->{'id'};
115 $row_data{isbn} = $resultsbr[$i]->{'isbn'};
116 $row_data{copyrightdate} = $resultsbr[$i]->{'copyrightdate'};
117 $row_data{editionstatement} = $resultsbr[$i]->{'editionstatement'};
118 $row_data{file} = $resultsbr[$i]->{'file'};
119 $row_data{title} = $resultsbr[$i]->{'title'};
120 $row_data{author} = $resultsbr[$i]->{'author'};
121 push( @breeding_loop, \%row_data );
124 $template->param(
125 frameworkcodeloop => \@frameworkcodeloop,
126 breeding_count => $countbr,
127 breeding_loop => \@breeding_loop,
128 z3950_search_params => C4::Search::z3950_search_args($query),
131 output_html_with_http_headers $input, $cookie, $template->output;