bugfix
[koha.git] / acqui / finishreceive.pl
blob4e05ebd77c64a63bbf0145617b711fd08c4c3104
1 #!/usr/bin/perl
3 #script to add a new item and to mark orders as received
4 #written 1/3/00 by chris@katipo.co.nz
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
24 use C4::Output;
25 use C4::Catalogue;
26 use C4::Biblio;
27 use CGI;
28 use C4::Search;
30 my $input=new CGI;
31 #print $input->header;
33 my $user=$input->remote_user;
34 #print $input->dump;
35 my $biblionumber = $input->param('biblio');
36 my $ordnum=$input->param('ordnum');
37 my $quantrec=$input->param('quantityrec');
38 my $quantity=$input->param('quantity');
39 my $notes=$input->param('notes');
40 my $cost=$input->param('cost');
41 my $invoiceno=$input->param('invoice');
42 my $bibitemno=$input->param('biblioitemnum');
43 my $data=bibitemdata($bibitemno);
44 my $publisher=$data->{'publishercode'};
45 my $pubdate=$data->{'publicationdate'};
46 my $class=$data->{'classification'};
47 my $dewey=$data->{'dewey'};
48 my $subclass=$data->{'subclass'};
50 my $size=$data->{'size'};
51 my $illus=$data->{'illus'};
52 my $pages=$data->{'pages'};
53 my $replacement=$input->param('rrp');
54 my $branch=$input->param('branch');
55 my $bookfund=$input->param('bookfund');
56 my $itemtype=$input->param('format');
57 my $isbn=$input->param('ISBN');
58 my $bookseller = $input->param('bookseller');
59 my $id = $bookseller;
60 my $biblio = {
61 biblionumber => $biblionumber,
62 title => $input->param('title')?$input->param('title'):"",
63 author => $input->param('author')?$input->param('author'):"",
64 copyrightdate => $input->param('copyright')?$input->param('copyright'):"",
65 series => $input->param('Series')?$input->param('Series'):""
66 }; # my $biblio
68 if ($quantrec != 0){
69 $cost /= $quantrec;
72 my $gst=$input->param('gst');
73 my $freight=$input->param('freight');
74 my $volinf=$input->param('volinf');
75 my $loan=0;
76 if ($itemtype =~ /REF/){
77 $loan=1;
80 if ($itemtype =~ /PER/){
81 # print "$bibitemno";
82 $class="Periodical";
83 $bibitemno = &newbiblioitem({
84 biblionumber => $biblionumber,
85 itemtype => $itemtype?$itemtype:"",
86 isbn => $isbn?$isbn:"",
87 volumeddesc => $volinf?$volinf:"",
88 classification => $class?$class:"" });
89 # print "here $bibitemno";
91 if ($quantity != 0){
92 receiveorder($biblionumber,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund);
93 modbiblio($biblio);
94 &modbibitem({
95 biblioitemnumber => $bibitemno,
96 biblionumber => $biblionumber,
97 itemtype => $itemtype?$itemtype:"",
98 isbn => $isbn?$isbn:"",
99 publisher => $publisher?$publisher:"",
100 publicationyear => $pubdate?$pubdate:"",
101 class => $class?$class:"",
102 dewey => $dewey?$dewey:"",
103 subclass => $subclass?$subclass:"",
104 illus => $illus?$illus:"",
105 pages => $pages?$pages:"",
106 volumeddesc => $volinf?$volinf:"",
107 notes => $notes?$notes:"",
108 size => $size?$size:"" });
110 my $barcode=$input->param('barcode');
111 my @barcodes;
112 if ($barcode =~ /\,/){
113 @barcodes=split(/\,/,$barcode);
114 }elsif ($barcode =~ /\|/){
115 @barcodes=split(/\|/,$barcode);
116 } else {
117 $barcodes[0]=$barcode;
118 # print $input->header;
119 # print @barcodes;
120 # print $barcode;
122 # print STDERR "************ biblionumber => $biblionumber\n";
123 my ($error) = newitems({ biblioitemnumber => $bibitemno,
124 biblionumber => $biblionumber,
125 replacementprice => $replacement,
126 price => $cost,
127 booksellerid => $bookseller,
128 homebranch => $branch,
129 loan => $loan },
130 @barcodes);
131 if ($error eq ''){
132 if ($itemtype ne 'PER'){
133 print $input->redirect("/cgi-bin/koha/acqui/receive.pl?invoice=$invoiceno&id=$id&freight=$freight&gst=$gst");
134 } else {
135 print $input->redirect("/acquisitions/");
137 } else {
138 print $input->header;
139 print $error;
141 } else {
142 print $input->header;
143 delorder($biblionumber,$ordnum);
144 print $input->redirect("/acquisitions/");