3 #script to show display basket of orders
4 #written by chris@katipo.co.nz 24/2/2000
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
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
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.
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
35 use C4::Interface::CGI::Output;
39 my $booksellerid=$input->param('booksellerid');
40 my $title=$input->param('title');
41 my $author=$input->param('author');
42 my $copyright=$input->param('copyright');
43 my ($count,@booksellers)=bookseller($booksellerid);
44 my $ordnum=$input->param('ordnum');
45 my $biblio=$input->param('biblio');
46 my $basketno=$input->param('basketno');
47 my $suggestionid = $input->param('suggestionid');
48 my $close= $input->param('close');
51 my $dbh = C4::Context->dbh;
52 if ($ordnum eq ''){ # create order
54 # $ordnum=newordernum;
55 if ($biblio && !$suggestionid) {
56 $data=bibdata($biblio);
58 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
59 # otherwise, retrieve suggestion information.
62 $data=bibdata($biblio);
64 $data = getsuggestion($suggestionid);
67 if ($data->{'title'} eq ''){
68 $data->{'title'}=$title;
69 $data->{'author'}=$author;
70 $data->{'copyrightdate'}=$copyright;
73 $data=getsingleorder($ordnum);
74 $biblio=$data->{'biblionumber'};
76 my ($template, $loggedinuser, $cookie)
77 = get_template_and_user({template_name => "acqui/newbiblio.tmpl",
81 flagsrequired => {acquisition => 1},
86 # get currencies (for change rates calcs if needed
87 my ($count,$rates)=getcurrencies();
88 my @loop_currency = ();
89 for (my $i=0;$i<$count;$i++){
91 $line{currency} = $rates->[$i]->{'currency'};
92 $line{rate} = $rates->[$i]->{'rate'};
93 push @loop_currency, \%line;
97 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
101 while (my ($value,$lib) = $sth->fetchrow_array) {
102 push @itemtype, $value;
103 $itemtypes{$value}=$lib;
105 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
106 -values => \@itemtype,
107 -default => $data->{'itemtype'},
108 -labels => \%itemtypes,
113 # build branches list
117 my ($count2,@branches)=branches();
118 for (my $i=0;$i<$count2;$i++){
119 if ((!C4::Context->preference('IndependantBranches'))||(C4::Context->preference('IndependantBranches') && (C4::Context->userenv->{flags} ==1))
120 ||((C4::Context->preference('IndependantBranches') && (C4::Context->userenv->{flags} !=1) && (C4::Context->userenv->{branch} eq $branches[$i]->{'branchcode'})))){
121 push @select_branch, $branches[$i]->{'branchcode'};#
122 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
125 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
126 -values => \@select_branch,
127 -default => $data->{'branchcode'},
128 -labels => \%select_branches,
132 # build bookfund list
133 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
134 $sthtemp->execute($loggedinuser);
135 my ($flags, $homebranch)=$sthtemp->fetchrow;
139 my %select_bookfunds;
140 ($count2,@bookfund)=bookfunds($homebranch);
141 for (my $i=0;$i<$count2;$i++){
142 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
143 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
145 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
146 -values => \@select_bookfund,
147 -default => $data->{'bookfundid'},
148 -labels => \%select_bookfunds,
154 $bookfundid=$data->{'bookfundid'};
155 $bookfundname= $select_bookfunds{$bookfundid};
159 my $CGIsort1 = buildCGIsort("Asort1","sort1",$data->{'sort1'});
161 $template->param(CGIsort1 => $CGIsort1);
163 $template->param( sort1 => $data->{'sort1'});
166 my $CGIsort2 = buildCGIsort("Asort2","sort2",$data->{'sort2'});
168 $template->param(CGIsort2 =>$CGIsort2);
170 $template->param( sort2 => $data->{'sort2'});
174 $template->param( close=> $close, bookfundid=>$bookfundid, bookfundname=>$bookfundname) if ($close);
177 $template->param( existing => $biblio,
180 basketno => $basketno,
181 booksellerid => $booksellerid,
182 suggestionid => $suggestionid,
184 biblioitemnumber => $data->{'biblioitemnumber'},
185 itemtype => $data->{'itemtype'},
186 discount => $booksellers[0]->{'discount'},
187 listincgst => $booksellers[0]->{'listincgst'},
188 listprice => $booksellers[0]->{'listprice'},
189 gstreg => $booksellers[0]->{'gstreg'},
190 invoiceinc => $booksellers[0]->{'invoiceincgst'},
191 invoicedisc => $booksellers[0]->{'invoicedisc'},
192 nocalc => $booksellers[0]->{'nocalc'},
193 name => $booksellers[0]->{'name'},
194 currency => $booksellers[0]->{'listprice'},
195 gstrate => C4::Context->preference("gist") ,
196 loop_currencies => \@loop_currency,
197 orderexists => ($new eq 'yes')?0:1,
198 title => $data->{'title'},
199 author => $data->{'author'},
200 copyrightdate => $data->{'copyrightdate'},
201 CGIitemtype => $CGIitemtype,
202 CGIbranch => $CGIbranch,
203 CGIbookfund => $CGIbookfund,
204 isbn => $data->{'isbn'},
205 seriestitle => $data->{'seriestitle'},
206 quantity => $data->{'quantity'},
207 listprice => $data->{'listprice'},
208 rrp => $data->{'rrp'},
209 invoice => $data->{'booksellerinvoicenumber'},
210 ecost => $data->{'ecost'},
211 notes => $data->{'notes'},
212 publishercode => $data->{'publishercode'});
214 output_html_with_http_headers $input, $cookie, $template->output;