invoice number problems fixed, "fast receive" now works
[wip/koha-chris_n.git] / acqui / basket.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to show display basket of 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::Date;
35 use strict;
36
37 my $query =new CGI;
38 my $basket=$query ->param('basket');
39 my ($template, $loggedinuser, $cookie)
40     = get_template_and_user({template_name => "acqui/basket.tmpl",
41                              query => $query,
42                              type => "intranet",
43                              authnotrequired => 0,
44                              flagsrequired => {acquisition => 1},
45                              debug => 1,
46                              });
47 my ($count,@results);
48 if ($basket eq ''){
49         $basket=newbasket();
50         $results[0]->{'booksellerid'}=$query->param('id');
51         $results[0]->{'authorisedby'} = $loggedinuser;
52 } else {
53         ($count,@results)=basket($basket);
54 }
55
56 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
57
58 my $line_total; # total of each line
59 my $sub_total; # total of line totals
60 my $gist;      # GST
61 my $grand_total; # $subttotal + $gist
62 my $toggle=0;
63
64 my @books_loop;
65 for (my $i=0;$i<$count;$i++){
66         my $rrp=$results[$i]->{'listprice'};
67         $rrp=curconvert($results[$i]->{'currency'},$rrp);
68
69         $line_total=$results[$i]->{'quantity'}*$results[$i]->{'ecost'};
70         $sub_total+=$line_total;
71         my %line;
72         if ($toggle==0){
73                 $line{color}='#EEEEEE';
74                 $toggle=1;
75         } else {
76                 $line{color}='white';
77                 $toggle=0;
78         }
79         $line{ordernumber} = $results[$i]->{'ordernumber'};
80         $line{isbn} = $results[$i]->{'isbn'};
81         $line{booksellerid} = $results[$i]->{'booksellerid'};
82         $line{basket}=$basket;
83         $line{title} = $results[$i]->{'title'};
84         $line{author} = $results[$i]->{'author'};
85         $line{i} = $i;
86         $line{rrp} = $results[$i]->{'rrp'};
87         $line{ecost} = $results[$i]->{'ecost'};
88         $line{quantity} = $results[$i]->{'quantity'};
89         $line{line_total} = $line_total;
90         $line{biblionumber} = $results[$i]->{'biblionumber'};
91         push @books_loop, \%line;
92 }
93 my $prefgist =C4::Context->preference("gist");
94 $gist=sprintf("%.2f",$sub_total*$prefgist);
95 $grand_total=$sub_total+$gist;
96
97 $template->param(basket => $basket,
98                                                 authorisedby => $results[0]->{'authorisedby'},
99                                                 entrydate => format_date($results[0]->{'entrydate'}),
100                                                 id=> $results[0]->{'booksellerid'},
101                                                 name => $booksellers[0]->{'name'},
102                                                 books_loop => \@books_loop,
103                                                 count =>$count,
104                                                 sub_total => $sub_total,
105                                                 gist => $gist,
106                                                 grand_total =>$grand_total,
107                                                 currency => $booksellers[0]->{'listprice'},
108                                                 );
109 output_html_with_http_headers $query, $cookie, $template->output;