5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
23 # Revision 1.4 2006/07/27 13:52:49 toins
24 # 1 sub renamed and cleaned.
26 # Revision 1.3 2006/07/21 10:12:00 toins
27 # subs renamed according to coding guidelines.
29 # Revision 1.2 2006/07/12 17:17:12 toins
30 # getitemtypes renamed to GetItemTypes
32 # Revision 1.1 2006/01/17 16:40:54 tipaul
33 # moving acqui.simple directory to cataloguing, as acqui.simple contains cataloguing scripts...
35 # Revision 1.8 2005/10/26 09:11:34 tipaul
36 # big commit, still breaking things...
38 # * synch with rel_2_2. Probably the last non manual synch, as rel_2_2 should not be modified deeply.
39 # * code cleaning (cleaning warnings from perl -w) continued
41 # Revision 1.4.2.1 2005/03/25 12:52:44 tipaul
42 # needs "editcatalogue" flag, not "catalogue"
44 # Revision 1.4 2004/11/19 16:41:49 tipaul
45 # improving behaviour when MARC=OFF
47 # Revision 1.3 2004/08/13 16:37:25 tipaul
48 # adding frameworkcode to API in some subs
50 # Revision 1.2 2003/05/11 06:59:11 rangi
52 # Still needs some work
62 use C4::Interface::CGI::Output;
65 my $biblionumber = $input->param('biblionumber');
66 my $error = $input->param('error');
78 if ( !$biblionumber ) {
79 print $input->redirect('addbooks.pl');
83 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
85 template_name => "acqui.simple/additem-nomarc.tmpl",
89 flagsrequired => { editcatalogue => 1 },
93 ( $bibliocount, @biblios ) = &getbiblio($biblionumber);
95 if ( !$bibliocount ) {
96 print $input->redirect('addbooks.pl');
99 @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
100 $biblioitemcount = scalar @biblioitems;
101 my $branches = GetBranches;
103 foreach my $thisbranch (sort keys %$branches) {
104 my %row =(value => $thisbranch,
105 branchname => $branches->{$thisbranch}->{'branchname'},
107 push @branchloop, \%row;
109 my $itemtypes = &GetItemTypes;
111 foreach my $thisitemtype (sort keys %$itemtypes) {
112 my %row =(value => $thisitemtype,
113 description => $itemtypes->{$thisitemtype}->{'description'},
115 push @itemtypeloop, \%row;
117 if ( $error eq "nobarcode" ) {
118 $template->param( NOBARCODE => 1 );
120 elsif ( $error eq "nobiblioitem" ) {
121 $template->param( NOBIBLIOITEM => 1 );
123 elsif ( $error eq "barcodeinuse" ) {
124 $template->param( BARCODEINUSE => 1 );
127 for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
128 if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
129 $biblioitems[$i]->{'WEB'} = 1;
131 $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
132 $biblioitems[$i]->{'dewey'} = $1;
133 ( $itemcount, @items ) = &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
134 $biblioitems[$i]->{'items'} = \@items;
137 BIBNUM => $biblionumber,
138 AUTHOR => $biblios[0]->{'author'},
139 TITLE => $biblios[0]->{'title'},
140 COPYRIGHT => $biblios[0]->{'copyrightdate'},
141 SERIES => $biblios[0]->{'seriestitle'},
142 NOTES => $biblios[0]->{'notes'},
143 BIBITEMS => \@biblioitems,
144 branchloop => \@branchloop,
145 itemtypeloop => \@itemtypeloop,
147 ( $bibliocount, @biblios ) = &getbiblio($biblionumber);
149 if ( !$bibliocount ) {
150 print $input->redirect('addbooks.pl');
154 @biblioitems =&GetBiblioItemByBiblioNumber($biblionumber);
155 $biblioitemcount = scalar @biblioitems;
156 @branches = &GetBranches;
157 ( $itemtypecount, @itemtypes ) = &GetItemTypes;
159 for ( my $i = 0 ; $i < $itemtypecount ; $i++ ) {
160 $itemtypedescriptions{ $itemtypes[$i]->{'itemtype'} } =
161 $itemtypes[$i]->{'description'};
164 for ( my $i = 0 ; $i < $#branches ; $i++ ) {
165 $branchnames{ $branches[$i]->{'branchcode'} } =
166 $branches[$i]->{'branchname'};
169 # print $input->header;
171 # print startmenu('acquisitions');
173 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
175 template_name => "acqui.simple/additem-nomarc.tmpl",
178 authnotrequired => 0,
179 flagsrequired => { editcatalogue => 1 },
184 if ( $error eq "nobarcode" ) {
185 $template->param( NOBARCODE => 1 );
187 elsif ( $error eq "nobiblioitem" ) {
188 $template->param( NOBIBLIOITEM => 1 );
190 elsif ( $error eq "barcodeinuse" ) {
191 $template->param( BARCODEINUSE => 1 );
194 for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
195 if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
196 $biblioitems[$i]->{'WEB'} = 1;
199 $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
200 $biblioitems[$i]->{'dewey'} = $1;
201 ( $itemcount, @items ) =
202 &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
203 $biblioitems[$i]->{'items'} = \@items;
206 BIBNUM => $biblionumber,
207 AUTHOR => $biblios[0]->{'author'},
208 TITLE => $biblios[0]->{'title'},
209 COPYRIGHT => $biblios[0]->{'copyrightdate'},
210 SERIES => $biblios[0]->{'seriestitle'},
211 NOTES => $biblios[0]->{'notes'},
212 BIBITEMS => \@biblioitems,
213 BRANCHES => \@branches,
214 ITEMTYPES => \@itemtypes,
218 output_html_with_http_headers $input, $cookie, $template->output;