improvement in book shelves
[koha.git] / acqui.simple / additem-nomarc.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
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
12 # version.
13 #
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.
17 #
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
21
22 # $Log$
23 # Revision 1.4  2004/11/19 16:41:49  tipaul
24 # improving behaviour when MARC=OFF
25 #
26 # Revision 1.3  2004/08/13 16:37:25  tipaul
27 # adding frameworkcode to API in some subs
28 #
29 # Revision 1.2  2003/05/11 06:59:11  rangi
30 # Mostly templated.
31 # Still needs some work
32 #
33
34 use CGI;
35 use strict;
36 use C4::Acquisition;
37 use C4::Biblio;
38 use C4::Output;
39 use HTML::Template;
40 use C4::Auth;
41 use C4::Interface::CGI::Output;
42
43 my $input        = new CGI;
44 my $biblionumber = $input->param('biblionumber');
45 my $error        = $input->param('error');
46 my $maxbarcode;
47 my $isbn;
48 my $bibliocount;
49 my @biblios;
50 my $biblioitemcount;
51 my @biblioitems;
52 my $branchcount;
53 my @branches;
54 my %branchnames;
55 my $itemcount;
56 my @items;
57 my $itemtypecount;
58 my @itemtypes;
59 my %itemtypedescriptions;
60
61 if ( !$biblionumber ) {
62     print $input->redirect('addbooks.pl');
63 }
64 else {
65
66     ( $bibliocount, @biblios ) = &getbiblio($biblionumber);
67
68     if ( !$bibliocount ) {
69         print $input->redirect('addbooks.pl');
70     }
71     else {
72
73         ( $biblioitemcount, @biblioitems ) =
74           &getbiblioitembybiblionumber($biblionumber);
75         ( $branchcount,   @branches )  = &branches;
76         ( $itemtypecount, @itemtypes ) = &getitemtypes;
77
78         for ( my $i = 0 ; $i < $itemtypecount ; $i++ ) {
79             $itemtypedescriptions{ $itemtypes[$i]->{'itemtype'} } =
80               $itemtypes[$i]->{'description'};
81         }    # for
82
83         for ( my $i = 0 ; $i < $branchcount ; $i++ ) {
84             $branchnames{ $branches[$i]->{'branchcode'} } =
85               $branches[$i]->{'branchname'};
86         }    # for
87
88         #       print $input->header;
89         #       print startpage();
90         #       print startmenu('acquisitions');
91         my $input = new CGI;
92         my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
93             {
94                 template_name   => "acqui.simple/additem-nomarc.tmpl",
95                 query           => $input,
96                 type            => "intranet",
97                 authnotrequired => 0,
98                 flagsrequired   => { catalogue => 1 },
99                 debug           => 1,
100             }
101         );
102
103         if ( $error eq "nobarcode" ) {
104             $template->param( NOBARCODE => 1 );
105         }
106         elsif ( $error eq "nobiblioitem" ) {
107             $template->param( NOBIBLIOITEM => 1 );
108         }
109         elsif ( $error eq "barcodeinuse" ) {
110             $template->param( BARCODEINUSE => 1 );
111         }    # elsif
112
113         for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
114             if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
115                 $biblioitems[$i]->{'WEB'} = 1;
116
117             }
118             $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
119             $biblioitems[$i]->{'dewey'} = $1;
120             ( $itemcount, @items ) =
121               &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
122             $biblioitems[$i]->{'items'} = \@items;
123         }    # for
124         $template->param(
125             BIBNUM    => $biblionumber,
126             AUTHOR    => $biblios[0]->{'author'},
127             TITLE     => $biblios[0]->{'title'},
128             COPYRIGHT => $biblios[0]->{'copyrightdate'},
129             SERIES    => $biblios[0]->{'seriestitle'},
130             NOTES     => $biblios[0]->{'notes'},
131             BIBITEMS  => \@biblioitems,
132             BRANCHES  => \@branches,
133             ITEMTYPES => \@itemtypes,
134
135         );
136
137         output_html_with_http_headers $input, $cookie, $template->output;
138     }    # if
139 }    # if