Previously there was no check to make sure that an issn number
[koha.git] / modbibitem.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to modify/delete groups
6
7 #written 8/11/99
8 # modified 11/11/99 by chris@katipo.co.nz
9 # modified 18/4/00 by chris@katipo.co.nz
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 require Exporter;
30
31 use C4::Output;
32 use C4::Koha;
33 use CGI;
34 use HTML::Template;
35 use C4::Date;
36 use C4::Biblio;
37 use C4::Acquisition;
38 use C4::Auth;
39 use C4::Interface::CGI::Output;
40
41 my $input = new CGI;
42 my $bibitemnum=$input->param('bibitem');
43 my $data=bibitemdata($bibitemnum);
44 my $biblio=$input->param('biblio');
45 my $submit=$input->param('submit');
46 if ($submit eq ''){
47   print $input->redirect("deletebiblioitem.pl?biblioitemnumber=$bibitemnum&biblionumber=$biblio");
48 }
49
50 my ($template, $loggedinuser, $cookie) = get_template_and_user({
51         template_name   => 'modbibitem.tmpl',
52         query           => $input,
53         type            => "intranet",
54         authnotrequired => 0,
55         flagsrequired   => {catalogue => 1},
56     });
57
58
59 my %inputs;
60
61 #hash is set up with input name being the key then
62 #the value is a tab separated list, the first item being the input type
63 #$inputs{'Author'}="text\t$data->{'author'}\t0";
64 #$inputs{'Title'}="text\t$data->{'title'}\t1";
65 my $dewey = $data->{'dewey'};
66 $dewey =~ s/0+$//;
67 if ($dewey eq "000.") { $dewey = "";};
68 if ($dewey < 10){$dewey='00'.$dewey;}
69 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
70 if ($dewey <= 0){
71   $dewey='';
72 }
73 $dewey=~ s/\.$//;
74 $inputs{'Class'}="text\t$data->{'classification'}$dewey$data->{'subclass'}\t2";
75 $inputs{'Item Type'}="text\t$data->{'itemtype'}\t3";
76 $inputs{'URL'}="text\t$data->{'url'}\t4";
77 $inputs{'Publisher'}="text\t$data->{'publishercode'}\t5";
78 #$inputs{'Copyright date'}="text\t$data->{'copyrightdate'}\t6";
79 $inputs{'ISBN'}="text\t$data->{'isbn'}\t7";
80 $inputs{'Publication Year'}="text\t$data->{'publicationyear'}\t8";
81 $inputs{'Pages'}="text\t$data->{'pages'}\t9";
82 $inputs{'Illustrations'}="text\t$data->{'illustration'}\t10";
83 #$inputs{'Series Title'}="text\t$data->{'seriestitle'}\t11";
84 #$inputs{'Additional Author'}="text\t$additional\t12";
85 #$inputs{'Subtitle'}="text\t$subtitle->[0]->{'subtitle'}\t13";
86 #$inputs{'Unititle'}="text\t$data->{'unititle'}\t14";
87 #$inputs{'Notes'}="textarea\t$data->{'notes'}\t15";
88 #$inputs{'Serial'}="text\t$data->{'serial'}\t16";
89 $inputs{'Volume'}="text\t$data->{'volumeddesc'}\t17";
90 #$inputs{'Analytic author'}="text\t\t18";
91 #$inputs{'Analytic title'}="text\t\t19";
92
93 $inputs{'bibnum'}="hidden\t$data->{'biblionumber'}\t20";
94 $inputs{'bibitemnum'}="hidden\t$data->{'biblioitemnumber'}\t21";
95
96 $template->param( biblionumber => $data->{'biblionumber'},
97                                                                 title => $data->{'title'},
98                                                                 author => $data->{'author'},
99                                                                 description => $data->{'description'},
100                                                                 loggedinuser => $loggedinuser,
101                                                                 );
102
103 my ($count,@bibitems)=bibitems($data->{'biblionumber'});
104
105 my @bibitemloop;
106
107 for (my $i=0;$i<$count;$i++){
108         my %line;
109         $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'};
110         $line{description} = $bibitems[$i]->{'description'};
111         $line{isbn} = $bibitems[$i]->{'isbn'};
112         push(@bibitemloop,\%line);
113 }
114 $template->param(bibitemloop =>\@bibitemloop);
115
116
117 #my $notesinput=$input->textfield(-name=>'Notes', -default=>$data->{'bnotes'}, -size=>20);
118 $template->param(bnotes=>$data->{'bnotes'});
119
120 $template->param(itemtype => $data->{'itemtype'});
121
122 $template->param(url => $data->{'url'});
123 $template->param(classification => $data->{'classification'},
124                                                                 dewey => $dewey,
125                                                                 subclass => $data->{'subclass'},
126                                                                 publishercode => $data->{'publishercode'},
127                                                                 place => $data->{'place'},
128                                                                 isbn => $data->{'isbn'},
129                                                                 publicationyear => $data->{'publicationyear'},
130                                                                 pages => $data->{'pages'},
131                                                                 illustration => $data->{'illustration'},
132                                                                 volumeddesc => $data->{'volumeddesc'},
133                                                                 size => $data->{'size'},
134                                                                 biblionumber => $data->{'biblionumber'},
135                                                                 biblioitemnumber => $data->{'biblioitemnumber'});
136
137 my (@items)=itemissues($data->{'biblioitemnumber'});
138 #print @items;
139 my @itemloop;
140 my $count=@items;
141 for (my $i=0;$i<$count;$i++){
142         my %line;
143         $items[$i]->{'datelastseen'} = format_date($items[$i]->{'datelastseen'});
144         $line{barcode}=$items[$i]->{'barcode'};
145         $line{itemnumber}=$items[$i]->{'itemnumber'};
146         $line{biblionumber}=$data->{'biblionumber'};
147         $line{biblioitemnumber}=$data->{'biblioitemnumber'};
148         $line{holdingbranch}=$items[$i]->{'holdingbranch'};
149         $line{datelastseen}=$items[$i]->{'datelastseen'};
150         push(@itemloop,\%line);
151 }
152 $template->param(itemloop => \@itemloop);
153 print "Content-Type: text/html\n\n", $template->output;
154