Specify datereceived when receiving a new parcel.
[wip/koha-chris_n.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::Context;
26 use C4::Output;
27 use C4::Acquisition;
28 use C4::Biblio;
29 use CGI;
30 use C4::Search;
31
32 my $input=new CGI;
33
34 my $user=$input->remote_user;
35 my $biblionumber = $input->param('biblionumber');
36 my $biblioitemnumber=$input->param('biblioitemnumber');
37 my $ordnum=$input->param('ordnum');
38 my $origquantityrec=$input->param('origquantityrec');
39 my $quantityrec=$input->param('quantityrec');
40 my $quantity=$input->param('quantity');
41 my $cost=$input->param('cost');
42 my $invoiceno=$input->param('invoice');
43 my $datereceived=$input->param('datereceived');
44 my $replacement=$input->param('rrp');
45 my $gst=$input->param('gst');
46 my $freight=$input->param('freight');
47 my $supplierid = $input->param('supplierid');
48 my @branch=$input->param('homebranch');
49 my @barcode=$input->param('barcode');
50 my @ccode=$input->param('ccode');
51 my @itemtype=$input->param('itemtype');
52 my @location=$input->param('location');
53 my $cnt = 0;
54 # if ($quantityrec != 0){
55 #       $cost /= $quantityrec;
56 # }
57
58 if ($quantityrec > $origquantityrec ) {
59     # save the quantity recieved.
60     $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantityrec,$user,$cost,$invoiceno,$datereceived,$freight,$replacement);
61     # create items if the user has entered barcodes
62    # my @barcodes=split(/\,| |\|/,$barcode);
63     # foreach barcode provided, build the item MARC::Record and create the item
64     foreach my $bc (@barcode) {
65         my $itemRecord = TransformKohaToMarc({
66                     "items.replacementprice" => $replacement,
67                     "items.price"            => $cost,
68                     "items.booksellerid"     => $supplierid,
69                     "items.homebranch"       => $branch[$cnt],
70                     "items.holdingbranch"    => $branch[$cnt],
71                     "items.barcode"          => $barcode[$cnt],
72                     "items.ccode"          => $ccode[$cnt],
73                     "items.itype"          => $itemtype[$cnt],
74                     "items.location"          => $location[$cnt],
75                     "items.loan"             => 0, });
76                 AddItem($itemRecord,$biblionumber);
77     }
78 }
79     print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived");
80 #} else {
81 #    print $input->header;
82 #    #delorder($biblionumber,$ordnum);
83 #    print $input->redirect("/acquisitions/");
84 #}