bugfixes xhtml & prog templates
[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('biblio');
35 my $bibitemno=$input->param('biblioitemnum');
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 $replacement=$input->param('rrp');
42 my $gst=$input->param('gst');
43 my $freight=$input->param('freight');
44 my $supplierid = $input->param('supplierid');
45 my $branch=$input->param('branch');
46
47 # if ($quantrec != 0){
48 #       $cost /= $quantrec;
49 # }
50
51 if ($quantity != 0) {
52         # save the quantity recieved.
53         receiveorder($biblionumber,$ordnum,$quantrec,$user,$cost,$invoiceno,$freight,$replacement);
54         # create items if the user has entered barcodes
55         my $barcode=$input->param('barcode');
56         my @barcodes=split(/\,| |\|/,$barcode);
57         my ($error) = newitems({ biblioitemnumber => $bibitemno,
58                                         biblionumber     => $biblionumber,
59                                         replacementprice => $replacement,
60                                         price            => $cost,
61                                         booksellerid     => $supplierid,
62                                         homebranch       => $branch,
63                                         loan             => 0 },
64                                 @barcodes);
65         print $input->redirect("/cgi-bin/koha/acqui/receive.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst");
66 } else {
67         print $input->header;
68         delorder($biblionumber,$ordnum);
69         print $input->redirect("/acquisitions/");
70 }