Several fixes to allow for creation of valid Code 128 barcodes.
[koha.git] / modbib.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to modify/delete biblios
6 #written 8/11/99
7 # modified 11/11/99 by chris@katipo.co.nz
8 # modified 12/16/2002 by hdl@ifrance.com : templating
9
10
11 # Copyright 2000-2002 Katipo Communications
12 #
13 # This file is part of Koha.
14 #
15 # Koha is free software; you can redistribute it and/or modify it under the
16 # terms of the GNU General Public License as published by the Free Software
17 # Foundation; either version 2 of the License, or (at your option) any later
18 # version.
19 #
20 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License along with
25 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
26 # Suite 330, Boston, MA  02111-1307 USA
27
28 use strict;
29
30 use C4::Search;
31 use CGI;
32 use C4::Output;
33 use HTML::Template;
34 use C4::Auth;
35 use C4::Context;
36 use C4::Interface::CGI::Output;
37
38 my $input = new CGI;
39
40 my $bibnum=$input->param('bibnum');
41 my $data=&bibdata($bibnum);
42 my ($subjectcount, $subject)     = &subject($bibnum);
43 my ($subtitlecount, $subtitle)   = &subtitle($bibnum);
44 my ($addauthorcount, $addauthor) = &addauthor($bibnum);
45 my $sub        = $subject->[0]->{'subject'};
46 my $additional = $addauthor->[0]->{'author'};
47 my $dewey;
48 my $submit=$input->param('submit.x');
49 if ($submit eq '') {
50   print $input->redirect("/cgi-bin/koha/delbiblio.pl?biblio=$bibnum");
51 } # if
52
53 my ($template, $loggedinuser, $cookie)
54     = get_template_and_user({template_name => "modbib.tmpl",
55                              query => $input,
56                              type => "intranet",
57                              authnotrequired => 0,
58                              flagsrequired => {acquisition => 1},
59                              debug => 1,
60                              });
61
62 # have to get all subtitles, subjects and additional authors
63 $sub = join("|", map { $_->{'subject'} } @{$subject});
64
65 $additional = join("|", map { $_->{'author'} } @{$addauthor});
66
67 $dewey = $data->{'dewey'};
68 $dewey =~ s/0+$//;
69 if ($dewey eq "000.") {
70     $dewey = "";
71 } # if
72 if ($dewey < 10) {
73     $dewey = '00' . $dewey;
74 } # if
75 if ($dewey < 100 && $dewey > 10) {
76     $dewey = '0' . $dewey;
77 } # if
78 if ($dewey <= 0){
79   $dewey='';
80 } # if
81 $dewey = ~ s/\.$//;
82
83 $data->{'title'} = &tidyhtml($data->{'title'});
84
85 $template->param ( biblionumber => $bibnum,
86                                                 biblioitemnumber => $data->{'biblioitemnumber'},
87                                                 author => $data->{'author'},
88                                                 title => $data->{'title'},
89                                                 abstract => $data->{'abstract'},
90                                                 subject => $sub,
91                                                 copyrightdate => $data->{'copyrightdate'},
92                                                 seriestitle => $data->{'seriestitle'},
93                                                 additionalauthor => $additional,
94                                                 subtitle => $data->{'subtitle'},
95                                                 unititle => $data->{'unititle'},
96                                                 notes => $data->{'bnotes'},
97                                                 serial => $data->{'serial'});
98
99 output_html_with_http_headers $input, $cookie, $template->output;
100
101 sub tidyhtml {
102   my ($inp)=@_;
103   $inp=~ s/\"/\&quot\;/g;
104   return($inp);
105 }