*** empty log message ***
[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
35 my $input = new CGI;
36
37 my $bibnum=$input->param('bibnum');
38 my $data=&bibdata($bibnum);
39 my ($subjectcount, $subject)     = &subject($data->{'biblionumber'});
40 my ($subtitlecount, $subtitle)   = &subtitle($data->{'biblionumber'});
41 my ($addauthorcount, $addauthor) = &addauthor($data->{'biblionumber'});
42 my $sub        = $subject->[0]->{'subject'};
43 my $additional = $addauthor->[0]->{'author'};
44 my $dewey;
45 my $submit=$input->param('submit.x');
46 if ($submit eq '') {
47   print $input->redirect("/cgi-bin/koha/delbiblio.pl?biblio=$bibnum");
48 } # if
49
50 #print $input->header;
51 # my ($analytictitle)  = &analytic($biblionumber,'t');
52 # my ($analyticauthor) = &analytic($biblionumber,'a');
53 #print startpage();
54 #print startmenu('catalogue');
55 my $template = gettemplate("modbib.tmpl");
56
57 # have to get all subtitles, subjects and additional authors
58 $sub = join("|", map { $_->{'subject'} } @{$subject});
59
60 $additional = join("|", map { $_->{'author'} } @{$addauthor});
61
62 $dewey = $data->{'dewey'};
63 $dewey =~ s/0+$//;
64 if ($dewey eq "000.") {
65     $dewey = "";
66 } # if
67 if ($dewey < 10) {
68     $dewey = '00' . $dewey;
69 } # if
70 if ($dewey < 100 && $dewey > 10) {
71     $dewey = '0' . $dewey;
72 } # if
73 if ($dewey <= 0){
74   $dewey='';
75 } # if
76 $dewey = ~ s/\.$//;
77
78 $data->{'title'} = &tidyhtml($data->{'title'});
79
80 $template->param ( biblionumber => $data->{'biblionumber'});
81 $template->param ( biblioitemnumber => $data->{'biblioitemnumber'});
82 $template->param ( author => $data->{'author'});
83 $template->param ( title => $data->{'title'});
84 $template->param ( abstract => $data->{'abstract'});
85 $template->param ( subject => $sub);
86 $template->param ( copyrightdate => $data->{'copyrightdate'});
87 $template->param ( seriestitle => $data->{'seriestitle'});
88 $template->param ( additionalauthor => $additional);
89 $template->param ( subtitle => $data->{'subtitle'});
90 $template->param ( untitle => $data->{'untitle'});
91 $template->param ( notes => $data->{'notes'});
92 $template->param ( serial => $data->{'serial'});
93
94 print "Content-Type: text/html\n\n", $template->output;
95
96 sub tidyhtml {
97   my ($inp)=@_;
98   $inp=~ s/\"/\&quot\;/g;
99   return($inp);
100 }