catalogue.pm deals only with acquisitions.
[koha.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{publishercode} = $results[$i]->{'publishercode'};
81         $line{isbn} = $results[$i]->{'isbn'};
82         $line{booksellerid} = $results[$i]->{'booksellerid'};
83         $line{basket}=$basket;
84         $line{title} = $results[$i]->{'title'};
85         $line{author} = $results[$i]->{'author'};
86         $line{i} = $i;
87         $line{rrp} = $results[$i]->{'rrp'};
88         $line{ecost} = $results[$i]->{'ecost'};
89         $line{quantity} = $results[$i]->{'quantity'};
90         $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
91         $line{line_total} = $line_total;
92         $line{biblionumber} = $results[$i]->{'biblionumber'};
93         push @books_loop, \%line;
94 }
95 my $prefgist =C4::Context->preference("gist");
96 $gist=sprintf("%.2f",$sub_total*$prefgist);
97 $grand_total=$sub_total+$gist;
98
99 $template->param(basket => $basket,
100                                 authorisedby => $results[0]->{'authorisedby'},
101                                 entrydate => format_date($results[0]->{'entrydate'}),
102                                 id=> $results[0]->{'booksellerid'},
103                                 name => $booksellers[0]->{'name'},
104                                 books_loop => \@books_loop,
105                                 count =>$count,
106                                 sub_total => $sub_total,
107                                 gist => $gist,
108                                 grand_total =>$grand_total,
109                                 currency => $booksellers[0]->{'listprice'},
110                                 );
111 output_html_with_http_headers $query, $cookie, $template->output;