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