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.6 2007/03/09 15:36:10 tipaul
24 # rel_3_0 moved to HEAD (introducing new files)
26 # Revision 1.4.2.3 2006/12/14 15:41:54 toins
27 # admin/branches.pl works now with mod_perl.
28 # New module : Branch.pm containt all functions dealings with branches.
30 # Revision 1.4.2.2 2006/12/05 11:35:30 toins
32 # additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
33 # Some functions renamed according to the coding guidelines.
35 # Revision 1.4.2.1 2006/09/26 16:05:05 toins
36 # adding missing template & fix wrong link on scripts.
38 # Revision 1.4 2006/07/27 13:52:49 toins
39 # 1 sub renamed and cleaned.
41 # Revision 1.3 2006/07/21 10:12:00 toins
42 # subs renamed according to coding guidelines.
44 # Revision 1.2 2006/07/12 17:17:12 toins
45 # getitemtypes renamed to GetItemTypes
47 # Revision 1.1 2006/01/17 16:40:54 tipaul
48 # moving acqui.simple directory to cataloguing, as acqui.simple contains cataloguing scripts...
50 # Revision 1.8 2005/10/26 09:11:34 tipaul
51 # big commit, still breaking things...
53 # * synch with rel_2_2. Probably the last non manual synch, as rel_2_2 should not be modified deeply.
54 # * code cleaning (cleaning warnings from perl -w) continued
56 # Revision 1.4.2.1 2005/03/25 12:52:44 tipaul
57 # needs "editcatalogue" flag, not "catalogue"
59 # Revision 1.4 2004/11/19 16:41:49 tipaul
60 # improving behaviour when MARC=OFF
62 # Revision 1.3 2004/08/13 16:37:25 tipaul
63 # adding frameworkcode to API in some subs
65 # Revision 1.2 2003/05/11 06:59:11 rangi
67 # Still needs some work
75 use C4::Branch; # GetBranches
77 use C4::Interface::CGI::Output;
80 my $biblionumber = $input->param('biblionumber');
81 my $error = $input->param('error');
93 if ( !$biblionumber ) {
94 print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl');
98 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
100 template_name => "cataloguing/additem-nomarc.tmpl",
103 authnotrequired => 0,
104 flagsrequired => { editcatalogue => 1 },
108 ( $bibliocount, @biblios ) = &GetBiblio($biblionumber);
110 if ( !$bibliocount ) {
111 print $input->redirect('addbooks.pl');
114 @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
115 $biblioitemcount = scalar @biblioitems;
116 my $branches = GetBranches;
118 foreach my $thisbranch (sort keys %$branches) {
119 my %row =(value => $thisbranch,
120 branchname => $branches->{$thisbranch}->{'branchname'},
122 push @branchloop, \%row;
124 my $itemtypes = &GetItemTypes;
126 foreach my $thisitemtype (sort keys %$itemtypes) {
127 my %row =(value => $thisitemtype,
128 description => $itemtypes->{$thisitemtype}->{'description'},
130 push @itemtypeloop, \%row;
132 if ( $error eq "nobarcode" ) {
133 $template->param( NOBARCODE => 1 );
135 elsif ( $error eq "nobiblioitem" ) {
136 $template->param( NOBIBLIOITEM => 1 );
138 elsif ( $error eq "barcodeinuse" ) {
139 $template->param( BARCODEINUSE => 1 );
142 for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
143 if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
144 $biblioitems[$i]->{'WEB'} = 1;
146 $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
147 $biblioitems[$i]->{'dewey'} = $1;
148 ( $itemcount, @items ) = &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
149 $biblioitems[$i]->{'items'} = \@items;
152 BIBNUM => $biblionumber,
153 AUTHOR => $biblios[0]->{'author'},
154 TITLE => $biblios[0]->{'title'},
155 COPYRIGHT => $biblios[0]->{'copyrightdate'},
156 SERIES => $biblios[0]->{'seriestitle'},
157 NOTES => $biblios[0]->{'notes'},
158 BIBITEMS => \@biblioitems,
159 branchloop => \@branchloop,
160 itemtypeloop => \@itemtypeloop,
162 ( $bibliocount, @biblios ) = &GetBiblio($biblionumber);
164 if ( !$bibliocount ) {
165 print $input->redirect('addbooks.pl');
169 @biblioitems =&GetBiblioItemByBiblioNumber($biblionumber);
170 $biblioitemcount = scalar @biblioitems;
171 @branches = &GetBranches;
172 ( $itemtypecount, @itemtypes ) = &GetItemTypes;
174 for ( my $i = 0 ; $i < $itemtypecount ; $i++ ) {
175 $itemtypedescriptions{ $itemtypes[$i]->{'itemtype'} } =
176 $itemtypes[$i]->{'description'};
179 for ( my $i = 0 ; $i < $#branches ; $i++ ) {
180 $branchnames{ $branches[$i]->{'branchcode'} } =
181 $branches[$i]->{'branchname'};
184 # print $input->header;
186 # print startmenu('acquisitions');
188 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
190 template_name => "cataloguing/additem-nomarc.tmpl",
193 authnotrequired => 0,
194 flagsrequired => { editcatalogue => 1 },
199 if ( $error eq "nobarcode" ) {
200 $template->param( NOBARCODE => 1 );
202 elsif ( $error eq "nobiblioitem" ) {
203 $template->param( NOBIBLIOITEM => 1 );
205 elsif ( $error eq "barcodeinuse" ) {
206 $template->param( BARCODEINUSE => 1 );
209 for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
210 if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
211 $biblioitems[$i]->{'WEB'} = 1;
214 $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
215 $biblioitems[$i]->{'dewey'} = $1;
216 ( $itemcount, @items ) =
217 &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
218 $biblioitems[$i]->{'items'} = \@items;
221 BIBNUM => $biblionumber,
222 AUTHOR => $biblios[0]->{'author'},
223 TITLE => $biblios[0]->{'title'},
224 COPYRIGHT => $biblios[0]->{'copyrightdate'},
225 SERIES => $biblios[0]->{'seriestitle'},
226 NOTES => $biblios[0]->{'notes'},
227 BIBITEMS => \@biblioitems,
228 BRANCHES => \@branches,
229 ITEMTYPES => \@itemtypes,
233 output_html_with_http_headers $input, $cookie, $template->output;