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
34 use C4::Interface::CGI::Output;
38 my $booksellerid=$input->param('booksellerid');
39 my $title=$input->param('title');
40 my $author=$input->param('author');
41 my $copyright=$input->param('copyright');
42 my ($count,@booksellers)=bookseller($booksellerid);
43 my $ordnum=$input->param('ordnum');
44 my $biblio=$input->param('biblio');
45 my $basketno=$input->param('basketno');
46 my $suggestionid = $input->param('suggestionid');
49 my $dbh = C4::Context->dbh;
50 if ($ordnum eq ''){ # create order
52 # $ordnum=newordernum;
53 if ($biblio && !$suggestionid) {
54 $data=bibdata($biblio);
56 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
57 # otherwise, retrieve suggestion information.
60 $data=bibdata($biblio);
62 $data = getsuggestion($suggestionid);
65 if ($data->{'title'} eq ''){
66 $data->{'title'}=$title;
67 $data->{'author'}=$author;
68 $data->{'copyrightdate'}=$copyright;
71 $data=getsingleorder($ordnum);
72 $biblio=$data->{'biblionumber'};
74 my ($template, $loggedinuser, $cookie)
75 = get_template_and_user({template_name => "acqui/newbiblio.tmpl",
79 flagsrequired => {acquisition => 1},
84 # get currencies (for change rates calcs if needed
85 my ($count,$rates)=getcurrencies();
86 my @loop_currency = ();
87 for (my $i=0;$i<$count;$i++){
89 $line{currency} = $rates->[$i]->{'currency'};
90 $line{rate} = $rates->[$i]->{'rate'};
91 push @loop_currency, \%line;
95 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
99 while (my ($value,$lib) = $sth->fetchrow_array) {
100 push @itemtype, $value;
101 $itemtypes{$value}=$lib;
103 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
104 -values => \@itemtype,
105 -default => $data->{'itemtype'},
106 -labels => \%itemtypes,
111 # build branches list
115 my ($count2,@branches)=branches();
116 for (my $i=0;$i<$count2;$i++){
117 push @select_branch, $branches[$i]->{'branchcode'};#
118 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
120 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
121 -values => \@select_branch,
122 -default => $data->{'branchcode'},
123 -labels => \%select_branches,
127 # build bookfund list
130 my %select_bookfunds;
131 ($count2,@bookfund)=bookfunds();
132 for (my $i=0;$i<$count2;$i++){
133 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
134 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
136 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
137 -values => \@select_bookfund,
138 -default => $data->{'bookfundid'},
139 -labels => \%select_bookfunds,
143 my $CGIsort1 = buildCGIsort("Asort1","sort1",$data->{'sort1'});
145 $template->param(CGIsort1 => $CGIsort1);
147 $template->param( sort1 => $data->{'sort1'});
150 my $CGIsort2 = buildCGIsort("Asort2","sort2",$data->{'sort2'});
152 $template->param(CGIsort2 =>$CGIsort2);
154 $template->param( sort2 => $data->{'sort2'});
159 $template->param( existing => $biblio,
162 basketno => $basketno,
163 booksellerid => $booksellerid,
164 suggestionid => $suggestionid,
166 biblioitemnumber => $data->{'biblioitemnumber'},
167 itemtype => $data->{'itemtype'},
168 discount => $booksellers[0]->{'discount'},
169 listincgst => $booksellers[0]->{'listincgst'},
170 listprice => $booksellers[0]->{'listprice'},
171 gstreg => $booksellers[0]->{'gstreg'},
172 name => $booksellers[0]->{'name'},
173 currency => $booksellers[0]->{'listprice'},
174 gstrate => C4::Context->preference("gist") ,
175 loop_currencies => \@loop_currency,
176 orderexists => ($new eq 'yes')?0:1,
177 title => $data->{'title'},
178 author => $data->{'author'},
179 copyrightdate => $data->{'copyrightdate'},
180 CGIitemtype => $CGIitemtype,
181 CGIbranch => $CGIbranch,
182 CGIbookfund => $CGIbookfund,
183 isbn => $data->{'isbn'},
184 seriestitle => $data->{'seriestitle'},
185 quantity => $data->{'quantity'},
186 listprice => $data->{'listprice'},
187 rrp => $data->{'rrp'},
188 invoice => $data->{'booksellerinvoicenumber'},
189 ecost => $data->{'ecost'},
190 notes => $data->{'notes'},
191 publishercode => $data->{'publishercode'});
193 output_html_with_http_headers $input, $cookie, $template->output;