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