* graphic bugfixes
[koha.git] / updatebiblio.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
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.
12 #
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.
16 #
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
20
21 use strict;
22 require Exporter;
23 use C4::Context;
24 use C4::Output;  # contains gettemplate
25 use C4::Search;
26 use C4::Auth;
27 use C4::Interface::CGI::Output;
28 use CGI;
29 use C4::Biblio;
30 use C4::Output;
31 use HTML::Template;
32
33 my $input       = new CGI;
34 my $bibnum      = checkinp($input->param('biblionumber'));
35 my $biblio = {
36         biblionumber => $bibnum,
37         title        => $input->param('title')?$input->param('title'):"",
38         author       => $input->param('author')?$input->param('author'):"",
39         abstract     => $input->param('abstract')?$input->param('abstract'):"",
40         copyrightdate    => $input->param('copyrightdate')?$input->param('copyrightdate'):"",
41         seriestitle  => $input->param('seriestitle')?$input->param('seriestitle'):"",
42         serial       => $input->param('serial')?$input->param('serial'):"",
43         unititle     => $input->param('unititle')?$input->param('unititle'):"",
44         notes        => $input->param('notes')?$input->param('notes'):"",
45 }; # my $biblio
46 my $subtitle    = checkinp($input->param('subtitle'));
47 my $subject     = checkinp($input->param('subject'));
48 my $addauthor   = checkinp($input->param('additionalauthor'));
49 my $force       = $input->param('Force');
50 my %data;
51 my @sub;
52 my @subs;
53 my @names;
54 my $count;
55 my $error;
56
57 &modbiblio($biblio);
58 &modsubtitle($bibnum, $subtitle);
59 &modaddauthor($bibnum, $addauthor);
60
61 $subject = uc($subject);
62 @sub     = split(/\|/, $subject);
63 $count   = @sub;
64
65 for (my $i = 0; $i < $count; $i++) {
66         $sub[$i] =~ s/ +$//;
67 } # for
68
69 $error = &modsubject($bibnum,$force,@sub);
70
71 if ($error ne ''){
72                 my ($template, $loggedinuser, $cookie) = get_template_and_user({
73                         template_name   => "updatebiblio.tmpl",
74                         query           => $input,
75                         type            => "intranet",
76                         flagsrequired   => {catalogue => 1},
77                 });
78
79
80         my @subs=split('\n',$error);
81         my @names=$input->param;
82         my $count=@names;
83                 my @dataloop;
84         for (my $i=0;$i<$count;$i++) {
85                 if ($names[$i] ne 'Force') {
86                         my %line;
87                 $line{'value'}=$input->param("$names[$i]");
88                         $line{'name'}=$names[$i];
89                         push(@dataloop, \%line);
90                 } # if
91         } # for
92         $template->param(substring =>$subs[0],
93                                                 error =>$error,
94                                                 dataloop => \@dataloop);
95                 print "Content-Type: text/html\n\n", $template->output;
96 } else {
97         print $input->redirect("detail.pl?type=intra&bib=$bibnum");
98 } # else
99
100 sub checkinp{
101   my ($inp)=@_;
102   $inp=~ s/\'/\\\'/g;
103   $inp=~ s/\"/\\\"/g;
104   return($inp);
105 }