5 #script to show display basket of orders
6 #written by chris@katipo.co.nz 24/2/2000
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
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
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.
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
31 use C4::Interface::CGI::Output;
38 my $basketno = $query->param('basket');
39 my $booksellerid = $query->param('supplierid');
40 my $order = $query->param('order');
41 my ($template, $loggedinuser, $cookie)
42 = get_template_and_user({template_name => "acqui/basket.tmpl",
46 flagsrequired => {acquisition => 1},
52 my $basket = getbasket($basketno);
53 # FIXME : the query->param('supplierid') below is probably useless. The bookseller is always known from the basket
54 # if no booksellerid in parameter, get it from basket
55 # warn "=>".$basket->{booksellerid};
56 $booksellerid = $basket->{booksellerid} unless $booksellerid;
57 my ($count2,@booksellers)=bookseller($booksellerid);
59 # get librarian branch...
60 if (C4::Context->preference("IndependantBranches")) {
61 my $userenv = C4::Context->userenv;
62 unless ($userenv->{flags} == 1){
63 my $validtest = ($basket->{creationdate} eq '')
64 || ($basket->{branch} eq '')
65 || ($userenv->{branch} eq $basket->{branch})
66 || ($userenv->{branch} eq '')
67 || ($basket->{branch} eq '');
69 print $query->redirect("../mainpage.pl");
75 # if new basket, pre-fill infos
76 $basket->{creationdate} = "" unless ($basket->{creationdate});
77 $basket->{authorisedby} = $loggedinuser unless ($basket->{authorisedby});
78 ($count,@results)=getbasketcontent($basketno,'',$order);
80 my $line_total; # total of each line
81 my $sub_total; # total of line totals
83 my $grand_total; # $subttotal + $gist
85 # my $line_total_est; # total of each line
86 my $sub_total_est; # total of line totals
88 my $grand_total_est; # $subttotal + $gist
93 for (my $i=0;$i<$count;$i++){
94 my $rrp=$results[$i]->{'listprice'};
95 $rrp=curconvert($results[$i]->{'currency'},$rrp);
97 $sub_total_est+=$results[$i]->{'quantity'}*$results[$i]->{'rrp'};
98 $line_total=$results[$i]->{'quantity'}*$results[$i]->{'ecost'};
99 $sub_total+=$line_total;
100 $qty_total += $results[$i]->{'quantity'};
102 $line{ordernumber} = $results[$i]->{'ordernumber'};
103 $line{publishercode} = $results[$i]->{'publishercode'};
104 $line{isbn} = $results[$i]->{'isbn'};
105 $line{booksellerid} = $results[$i]->{'booksellerid'};
106 $line{basketno}=$basketno;
107 $line{title} = $results[$i]->{'title'};
108 $line{notes} = $results[$i]->{'notes'};
109 $line{author} = $results[$i]->{'author'};
111 $line{rrp} = sprintf("%.2f",$results[$i]->{'rrp'});
112 $line{ecost} = sprintf("%.2f",$results[$i]->{'ecost'});
113 $line{quantity} = $results[$i]->{'quantity'};
114 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
115 $line{line_total} = sprintf("%.2f",$line_total);
116 $line{biblionumber} = $results[$i]->{'biblionumber'};
117 $line{bookfundid} = $results[$i]->{'bookfundid'};
119 push @books_loop, \%line;
121 my $prefgist =C4::Context->preference("gist");
122 $gist=sprintf("%.2f",$sub_total*$prefgist);
123 $grand_total=$sub_total+$gist;
124 $grand_total_est = $sub_total_est+sprintf("%.2f",$sub_total_est*$prefgist);
125 $gist_est = sprintf("%.2f",$sub_total_est*$prefgist);
126 $template->param(basketno => $basketno,
127 creationdate => format_date($basket->{creationdate}),
128 authorisedby => $basket->{authorisedby},
129 authorisedbyname => $basket->{authorisedbyname},
130 closedate => format_date($basket->{closedate}),
131 active => $booksellers[0]->{'active'},
132 booksellerid=> $booksellers[0]->{'id'},
133 name => $booksellers[0]->{'name'},
134 address1 => $booksellers[0]->{'address1'},
135 address2 => $booksellers[0]->{'address2'},
136 address3 => $booksellers[0]->{'address3'},
137 address4 => $booksellers[0]->{'address4'},
138 entrydate => format_date($results[0]->{'entrydate'}),
139 books_loop => \@books_loop,
141 sub_total => $sub_total,
143 grand_total =>$grand_total,
144 sub_total_est => $sub_total_est,
145 gist_est => $gist_est,
146 grand_total_est =>$grand_total_est,
147 currency => $booksellers[0]->{'listprice'},
148 qty_total => $qty_total,
150 output_html_with_http_headers $query, $cookie, $template->output;