Changing GetSerials2 to take more than one status in parameter.
[koha.git] / acqui / finishreceive.pl
1 #!/usr/bin/perl
2
3 #script to add a new item and to mark orders as received
4 #written 1/3/00 by chris@katipo.co.nz
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
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.
15 #
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.
19 #
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
23
24 use strict;
25 use C4::Output;
26 use C4::Acquisition;
27 use C4::Biblio;
28 use CGI;
29 use C4::Search;
30
31 my $input=new CGI;
32
33 my $user=$input->remote_user;
34 my $biblionumber = $input->param('biblionumber');
35 my $biblioitemnumber=$input->param('biblioitemnumber');
36 my $ordnum=$input->param('ordnum');
37 my $quantrec=$input->param('quantityrec');
38 my $quantity=$input->param('quantity');
39 my $cost=$input->param('cost');
40 my $invoiceno=$input->param('invoice');
41 my $datereceived=$input->param('datereceived');
42 my $replacement=$input->param('rrp');
43 my $gst=$input->param('gst');
44 my $freight=$input->param('freight');
45 my $supplierid = $input->param('supplierid');
46 my $branch=$input->param('branch');
47
48 # if ($quantrec != 0){
49 #       $cost /= $quantrec;
50 # }
51
52 if ($quantity != 0) {
53     # save the quantity recieved.
54     $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantrec,$user,$cost,$invoiceno,$datereceived,$freight,$replacement);
55     # create items if the user has entered barcodes
56     my $barcode=$input->param('barcode');
57     my @barcodes=split(/\,| |\|/,$barcode);
58     # foreach barcode provided, build the item MARC::Record and create the item
59     foreach my $bc (@barcodes) {
60         my $itemRecord = TransformKohaToMarc({
61                     "items.replacementprice" => $replacement,
62                     "items.price"            => $cost,
63                     "items.booksellerid"     => $supplierid,
64                     "items.homebranch"       => $branch,
65                     "items.holdingbranch"    => $branch,
66                     "items.barcode"          => $bc,
67                     "items.loan"             => 0, });
68         AddItem($itemRecord,$biblionumber);
69     }
70     print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived");
71 } else {
72     print $input->header;
73     delorder($biblionumber,$ordnum);
74     print $input->redirect("/acquisitions/");
75 }