bugfix
[koha.git] / moditem.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5
6 #script to modify/delete biblios
7 #written 8/11/99
8 # modified 11/11/99 by chris@katipo.co.nz
9 # modified 12/16/02 by hdl@ifrance.com : Templating
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 C4::Acquisitions;
34 use C4::Biblio;
35 use HTML::Template;
36
37 my $input = new CGI;
38 my $submit=$input->param('delete.x');
39 my $itemnum=$input->param('item');
40 my $bibitemnum=$input->param('bibitem');
41 if ($submit ne ''){
42   print $input->redirect("/cgi-bin/koha/delitem.pl?itemnum=$itemnum&bibitemnum=$bibitemnum");
43 }
44
45 #print $input->header;
46 #print $input->dump;
47
48 my $data=bibitemdata($bibitemnum);
49
50 my $item=itemnodata('blah','',$itemnum);
51 #my ($analytictitle)=analytic($biblionumber,'t');
52 #my ($analyticauthor)=analytic($biblionumber,'a');
53
54
55 #print startpage();
56 #print startmenu('catalogue');
57 my $template=gettemplate("moditem.tmpl");
58
59 my %inputs;
60
61
62
63 #hash is set up with input name being the key then
64 #the value is a tab separated list, the first item being the input type
65 #$inputs{'Author'}="text\t$data->{'author'}\t0";
66 #$inputs{'Title'}="text\t$data->{'title'}\t1";
67 # FIXME - The Dewey code is a string, not a number. And "000" is a
68 # perfectly acceptable value.
69 my $dewey = $data->{'dewey'};
70 $dewey =~ s/0+$//;
71 if ($dewey eq "000.") { $dewey = "";};
72 if ($dewey < 10){$dewey='00'.$dewey;}
73 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
74 if ($dewey <= 0){
75   $dewey='';
76 }
77 $dewey=~ s/\.$//;
78
79 # 12/16/2002 hdl@ifrance.com : all these inputs seem unused !!!
80
81 $inputs{'Barcode'}="text\t$item->{'barcode'}\t0";
82 $inputs{'Class'}="hidden\t$data->{'classification'}$dewey$data->{'subclass'}\t2";
83 #$inputs{'Item Type'}="text\t$data->{'itemtype'}\t3";
84 #$inputs{'Subject'}="textarea\t$sub\t4";
85 $inputs{'Publisher'}="hidden\t$data->{'publishercode'}\t5";
86 #$inputs{'Copyright date'}="text\t$data->{'copyrightdate'}\t6";
87 $inputs{'ISBN'}="hidden\t$data->{'isbn'}\t7";
88 $inputs{'Publication Year'}="hidden\t$data->{'publicationyear'}\t8";
89 $inputs{'Pages'}="hidden\t$data->{'pages'}\t9";
90 $inputs{'Illustrations'}="hidden\t$data->{'illustration'}\t10";
91 #$inputs{'Series Title'}="text\t$data->{'seriestitle'}\t11";
92 #$inputs{'Additional Author'}="text\t$additional\t12";
93 #$inputs{'Subtitle'}="text\t$subtitle->[0]->{'subtitle'}\t13";
94 #$inputs{'Unititle'}="text\t$data->{'unititle'}\t14";
95 $inputs{'ItemNotes'}="textarea\t$item->{'itemnotes'}\t15";
96 #$inputs{'Serial'}="text\t$data->{'serial'}\t16";
97 $inputs{'Volume'}="hidden\t$data->{'volumeddesc'}\t17";
98 $inputs{'Home Branch'}="text\t$item->{'homebranch'}\t18";
99 $inputs{'Lost'}="radio\t$item->{'itemlost'}\t19";
100 #$inputs{'Analytic author'}="text\t\t18";
101 #$inputs{'Analytic title'}="text\t\t19";
102 $inputs{'bibnum'}="hidden\t$data->{'biblionumber'}\t20";
103 $inputs{'bibitemnum'}="hidden\t$data->{'biblioitemnumber'}\t21";
104 $inputs{'itemnumber'}="hidden\t$itemnum\t22";
105
106 #12/16/2002 hdl@ifrance.com : end of comment
107
108
109
110 #12/16/2002 hdl@ifrance.com : templating
111 $template->param(       title => $data->{'title'},
112                                                                 author => $data->{'author'},
113                                                                 barcode => $item->{'barcode'},
114                                                                 classification => "$data->{'classification'}$dewey$data->{'subclass'}",
115                                                                 publisher => $data->{'publisher'},
116                                                                 publicationyear => $data->{'publicationyear'},
117                                                                 pages => $data->{'pages'},
118                                                                 illustration => $data->{'illustration'},
119                                                                 itemnotes => $item->{'itemnotes'},
120                                                                 volumedesc => $data->{'volumedesc'},
121                                                                 homebranch => $data->{'homebranch'},
122                                                                 itemlost => ($item->{'itemlost'} ==1),
123                                                                 itemwithdrawn => ($item->{'wthdrawn'} ==1),
124                                                                 biblionumber => $data->{'biblionumber'},
125                                                                 biblioitemnumber => $data->{'biblioitemnumber'},
126                                                                 itemnumber => $itemnum);
127
128 print "Content-Type: text/html\n\n", $template->output;
129 #12/16/2002 hdl@ifrance.com : templating