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
33 use C4::Interface::CGI::Output;
37 my $booksellerid=$input->param('booksellerid');
38 my $title=$input->param('title');
39 my $author=$input->param('author');
40 my $copyright=$input->param('copyright');
41 my ($count,@booksellers)=bookseller($booksellerid);
42 my $ordnum=$input->param('ordnum');
43 my $biblio=$input->param('biblio');
44 my $basketno=$input->param('basketno');
45 my $suggestionid = $input->param('suggestionid');
48 my $dbh = C4::Context->dbh;
49 if ($ordnum eq ''){ # create order
51 # $ordnum=newordernum;
52 if ($biblio && !$suggestionid) {
53 $data=bibdata($biblio);
55 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
56 # otherwise, retrieve suggestion information.
59 $data=bibdata($biblio);
61 $data = getsuggestion($suggestionid);
64 if ($data->{'title'} eq ''){
65 $data->{'title'}=$title;
66 $data->{'author'}=$author;
67 $data->{'copyrightdate'}=$copyright;
70 $data=getsingleorder($ordnum);
71 $biblio=$data->{'biblionumber'};
73 my ($template, $loggedinuser, $cookie)
74 = get_template_and_user({template_name => "acqui/newbiblio.tmpl",
78 flagsrequired => {acquisition => 1},
83 # get currencies (for change rates calcs if needed
84 my ($count,$rates)=getcurrencies();
85 my @loop_currency = ();
86 for (my $i=0;$i<$count;$i++){
88 $line{currency} = $rates->[$i]->{'currency'};
89 $line{rate} = $rates->[$i]->{'rate'};
90 push @loop_currency, \%line;
94 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
98 while (my ($value,$lib) = $sth->fetchrow_array) {
99 push @itemtype, $value;
100 $itemtypes{$value}=$lib;
102 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
103 -values => \@itemtype,
104 -default => $data->{'itemtype'},
105 -labels => \%itemtypes,
110 # build branches list
114 my ($count2,@branches)=branches();
115 for (my $i=0;$i<$count2;$i++){
116 push @select_branch, $branches[$i]->{'branchcode'};#
117 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
119 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
120 -values => \@select_branch,
121 -default => $data->{'branchcode'},
122 -labels => \%select_branches,
126 # build bookfund list
129 my %select_bookfunds;
130 ($count2,@bookfund)=bookfunds();
131 for (my $i=0;$i<$count2;$i++){
132 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
133 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
135 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
136 -values => \@select_bookfund,
137 -default => $data->{'bookfundid'},
138 -labels => \%select_bookfunds,
143 $template->param( existing => $biblio,
146 basketno => $basketno,
147 booksellerid => $booksellerid,
148 suggestionid => $suggestionid,
150 biblioitemnumber => $data->{'biblioitemnumber'},
151 itemtype => $data->{'itemtype'},
152 discount => $booksellers[0]->{'discount'},
153 listincgst => $booksellers[0]->{'listincgst'},
154 listprice => $booksellers[0]->{'listprice'},
155 gstreg => $booksellers[0]->{'gstreg'},
156 name => $booksellers[0]->{'name'},
157 currency => $booksellers[0]->{'listprice'},
158 gstrate => C4::Context->preference("gist") ,
159 loop_currencies => \@loop_currency,
160 orderexists => ($new eq 'yes')?0:1,
161 title => $data->{'title'},
162 author => $data->{'author'},
163 copyrightdate => $data->{'copyrightdate'},
164 CGIitemtype => $CGIitemtype,
165 CGIbranch => $CGIbranch,
166 CGIbookfund => $CGIbookfund,
167 isbn => $data->{'isbn'},
168 seriestitle => $data->{'seriestitle'},
169 quantity => $data->{'quantity'},
170 listprice => $data->{'listprice'},
171 rrp => $data->{'rrp'},
172 invoice => $data->{'booksellerinvoicenumber'},
173 ecost => $data->{'ecost'},
174 notes => $data->{'notes'},
175 sort1 => $data->{'sort1'},
176 sort2 => $data->{'sort2'},
177 publishercode => $data->{'publishercode'});
179 output_html_with_http_headers $input, $cookie, $template->output;