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