Fixed wrong path for tab file.
[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 &modsubtitle($bibnum, $subtitle);
58 &modaddauthor($bibnum, $addauthor);
59
60 $subject = uc($subject);
61 @sub     = split(/\||\n/, $subject);
62 $count   = @sub;
63
64 for (my $i = 0; $i < $count; $i++) {
65         $sub[$i] =~ s/ +$//;
66 } # for
67
68 $error = &modsubject($bibnum,$force,@sub);
69
70 &modbiblio($biblio);
71
72 if ($error ne ''){
73                 my ($template, $loggedinuser, $cookie) = get_template_and_user({
74                         template_name   => "updatebiblio.tmpl",
75                         query           => $input,
76                         type            => "intranet",
77                         flagsrequired   => {catalogue => 1},
78                 });
79
80
81         my @subs=split('\n',$error);
82         my @names=$input->param;
83         my $count=@names;
84                 my @dataloop;
85         for (my $i=0;$i<$count;$i++) {
86                 if ($names[$i] ne 'Force') {
87                         my %line;
88                 $line{'value'}=$input->param("$names[$i]");
89                         $line{'name'}=$names[$i];
90                         push(@dataloop, \%line);
91                 } # if
92         } # for
93         $template->param(substring =>$subs[0],
94                                                 error =>$error,
95                                                 dataloop => \@dataloop);
96                 print "Content-Type: text/html\n\n", $template->output;
97 } else {
98         print $input->redirect("detail.pl?type=intra&bib=$bibnum");
99 } # else
100
101 sub checkinp{
102   my ($inp)=@_;
103   $inp=~ s/\'/\\\'/g;
104   $inp=~ s/\"/\\\"/g;
105   return($inp);
106 }