Bug 2351 : Receive acqui order was not incrementing loop counter when saving multiple...
[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 CGI;
26 use C4::Auth;
27 use C4::Output;
28 use C4::Context;
29 use C4::Acquisition;
30 use C4::Biblio;
31 use C4::Items;
32 use C4::Search;
33
34 my $input=new CGI;
35 my $flagsrequired = { acquisition => 1};
36 my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired, 'intranet');
37 my $user=$input->remote_user;
38 my $biblionumber = $input->param('biblionumber');
39 my $biblioitemnumber=$input->param('biblioitemnumber');
40 my $ordnum=$input->param('ordnum');
41 my $origquantityrec=$input->param('origquantityrec');
42 my $quantityrec=$input->param('quantityrec');
43 my $quantity=$input->param('quantity');
44 my $cost=$input->param('cost');
45 my $invoiceno=$input->param('invoice');
46 my $datereceived=$input->param('datereceived');
47 my $replacement=$input->param('rrp');
48 my $gst=$input->param('gst');
49 my $freight=$input->param('freight');
50 my $supplierid = $input->param('supplierid');
51 my @branch=$input->param('homebranch');
52 my @barcode=$input->param('barcode');
53 my @ccode=$input->param('ccode');
54 my @itemtype=$input->param('itemtype');
55 my @location=$input->param('location');
56 my @enumchron=$input->param('volinf');
57 my $cnt = 0;
58
59 if ($quantityrec > $origquantityrec ) {
60     # save the quantity recieved.
61     $datereceived = ModReceiveOrder($biblionumber,$ordnum,$quantityrec,$user,$cost,$invoiceno,$freight,$replacement,undef,$datereceived);
62     # create items if the user has entered barcodes
63    # my @barcodes=split(/\,| |\|/,$barcode);
64     # foreach barcode provided, build the item MARC::Record and create the item
65     foreach my $bc (@barcode) {
66         my $itemRecord = TransformKohaToMarc({
67                     "items.replacementprice" => $replacement,
68                     "items.price"            => $cost,
69                     "items.booksellerid"     => $supplierid,
70                     "items.homebranch"       => $branch[$cnt],
71                     "items.holdingbranch"    => $branch[$cnt],
72                     "items.barcode"          => $barcode[$cnt],
73                     "items.ccode"          => $ccode[$cnt],
74                     "items.itype"          => $itemtype[$cnt],
75                     "items.location"          => $location[$cnt],
76                     "items.enumchron"          => $enumchron[$cnt], # FIXME : No integration here with serials module.
77                     "items.loan"             => 0, });
78                 AddItemFromMarc($itemRecord,$biblionumber);
79                 $cnt++;
80         }
81 }
82     print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived");
83 #} else {
84 #    print $input->header;
85 #    #delorder($biblionumber,$ordnum);
86 #    print $input->redirect("/acquisitions/");
87 #}