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