Unido have far less info about their patrons, cutting down the confirmation screen
[koha.git] / acqui / receive.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use C4::Auth;
27 use C4::Catalogue;
28 use C4::Biblio;
29 use C4::Output;
30 use CGI;
31 use C4::Interface::CGI::Output;
32 use C4::Database;
33 use HTML::Template;
34 use C4::Catalogue;
35 use strict;
36
37 my $input=new CGI;
38 my $id=$input->param('id');
39 my ($count,@booksellers)=bookseller($id);
40 my $invoice=$input->param('invoice');
41 my $freight=$input->param('freight');
42 my $gst=$input->param('gst');
43 my $date=localtime(time);
44
45 my ($template, $loggedinuser, $cookie)
46     = get_template_and_user({template_name => "acqui/recieve.tmpl",
47                              query => $input,
48                              type => "intranet",
49                              authnotrequired => 0,
50                              flagsrequired => {acquisition => 1},
51                              debug => 1,
52                              });
53
54 my @results;
55 ($count,@results)=invoice($invoice);
56 if ($invoice eq ''){
57         ($count,@results)=getallorders($id);
58 }
59 my $totalprice=0;
60 my $totalfreight=0;
61 my $totalquantity=0;
62 my $total;
63 my $tototal;
64 my $toggle;
65 my @loop_orders = ();
66 for (my$i=0;$i<$count;$i++){
67         $total=($results[$i]->{'unitprice'} + $results[$i]->{'freight'}) * $results[$i]->{'quantityreceived'};
68         $results[$i]->{'unitprice'}+=0;
69         my %line;
70         if ($toggle==0){
71                 $line{color}='#ffffcc';
72                 $toggle=1;
73         } else {
74                 $line{color}='white';
75                 $toggle=0;
76         }
77         $line{basketno} = $results[$i]->{'basketno'};
78         $line{isbn} = $results[$i]->{'isbn'};
79         $line{ordernumber} = $results[$i]->{'ordernumber'};
80         $line{biblionumber} = $results[$i]->{'biblionumber'};
81         $line{invoice} = $invoice;
82         $line{gst} = $gst;
83         $line{title} = $results[$i]->{'title'};
84         $line{author} = $results[$i]->{'author'};
85         $line{unitprice} = $results[$i]->{'unitprice'};
86         $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
87         $line{total} = $total;
88         $line{id} = $id;
89         push @loop_orders, \%line;
90         $totalprice+=$results[$i]->{'unitprice'};
91         $totalfreight+=$results[$i]->{'freight'};
92         $totalquantity+=$results[$i]->{'quantityreceived'};
93         $tototal+=$total;
94 }
95
96 $totalfreight=$freight;
97 $tototal=$tototal+$freight;
98
99 $template->param(invoice => $invoice,
100                                                 date => $date,
101                                                 name => $booksellers[0]->{'name'},
102                                                 id => $id,
103                                                 gst => $gst,
104                                                 freight => $freight,
105                                                 invoice => $invoice,
106                                                 count => $count,
107                                                 loop_orders => \@loop_orders,
108                                                 totalprice => $totalprice,
109                                                 totalfreight => $totalfreight,
110                                                 totalquantity => $totalquantity,
111                                                 tototal => $tototal,
112                                                 gst => $gst,
113                                                 grandtot => $tototal+$gst,
114                                                 );
115 output_html_with_http_headers $input, $cookie, $template->output;