moving cataloguing scripts to a cataloguing directory (more logic than acqui.simple...
[koha.git] / cataloguing / saveitem.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 use CGI;
23 use strict;
24 # use C4::Catalogue;
25 use C4::Biblio;
26
27 my $input            = new CGI;
28 my $barcode          = $input->param('barcode');
29 my $biblionumber     = $input->param('biblionumber');
30 my $biblioitemnumber = $input->param('biblioitemnumber');
31 my $item             = {
32     biblionumber     => $biblionumber,
33     biblioitemnumber => $biblioitemnumber?$biblioitemnumber:"",
34     homebranch       => $input->param('homebranch'),
35     holdingbranch       => $input->param('homebranch'),
36     replacementprice => $input->param('replacementprice')?$input->param('replacementprice'):"",
37     itemnotes        => $input->param('notes')?$input->param('notes'):""
38 }; # my $item
39 my $biblioitem       = {
40     biblionumber      => $biblionumber,
41     itemtype          => $input->param('itemtype'),
42     isbn              => $input->param('isbn')?$input->param('isbn'):"",
43     publishercode     => $input->param('publishercode')?$input->param('publishercode'):"",
44     publicationyear   => $input->param('publicationyear')?$input->param('publicationyear'):"",
45     place             => $input->param('place')?$input->param('place'):"",
46     illus             => $input->param('illus')?$input->param('illus'):"",
47     url               => $input->param('url')?$input->param('url'):"",
48     dewey             => $input->param('dewey')?$input->param('dewey'):"",
49     subclass          => $input->param('subclass')?$input->param('subclass'):"",
50     issn              => $input->param('issn')?$input->param('issn'):"",
51     lccn              => $input->param('lccn')?$input->param('lccn'):"",
52     volume            => $input->param('volume')?$input->param('volume'):"",
53     number            => $input->param('number')?$input->param('number'):"",
54     volumeddesc       => $input->param('volumeddesc')?$input->param('volumeddesc'):"",
55     pages             => $input->param('pages')?$input->param('pages'):"",
56     size              => $input->param('size')?$input->param('size'):"",
57     notes             => $input->param('itemnotes')?$input->param('itemnotes'):""
58 }; # my biblioitem
59 my $newgroup = 0;
60 my $website  = 0;
61 my $count;
62 my @results;
63
64 if ($input->param('newgroup')) {
65     $newgroup = 1;
66     if ($biblioitem->{'itemtype'} eq "WEB") {
67         $website = 1;
68     } # if
69 } # if
70
71 if (! $biblionumber) {
72     print $input->redirect('addbooks.pl');
73 } elsif ((! $barcode) && (! $website)) {
74     print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=nobarcode");
75 } elsif ((! $newgroup) && (! $biblioitemnumber)) {
76     print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=nobiblioitem");
77 } else {
78
79     if ($website) {
80         &newbiblioitem($biblioitem);
81                 print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber");
82     } elsif (&checkitems(1,$barcode)) {
83         print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=barcodeinuse");
84     } else {
85
86         if ($newgroup) {
87             $biblioitemnumber = &newbiblioitem($biblioitem);
88             $item->{'biblioitemnumber'} = $biblioitemnumber;
89         } # if
90
91         &newitems($item, ($barcode));
92
93         print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber");
94     } # else
95 } # else