3 #script to show display basket of orders
4 #written by chris@katipo.co.nz 24/2/2000
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
36 use C4::Interface::CGI::Output;
40 my $booksellerid = $input->param('booksellerid');
41 my $title = $input->param('title');
42 my $author = $input->param('author');
43 my $copyright = $input->param('copyright');
44 my ( $count, @booksellers ) = bookseller($booksellerid);
45 my $ordnum = $input->param('ordnum');
46 my $biblio = $input->param('biblio');
47 my $basketno = $input->param('basketno');
48 my $suggestionid = $input->param('suggestionid');
49 my $close = $input->param('close');
52 my $dbh = C4::Context->dbh;
54 if ( $ordnum eq '' ) { # create order
57 # $ordnum=newordernum;
58 if ( $biblio && !$suggestionid ) {
59 $data = bibdata($biblio);
62 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
63 # otherwise, retrieve suggestion information.
66 $data = bibdata($biblio);
69 $data = getsuggestion($suggestionid);
72 if ( $data->{'title'} eq '' ) {
73 $data->{'title'} = $title;
74 $data->{'author'} = $author;
75 $data->{'copyrightdate'} = $copyright;
79 $data = getsingleorder($ordnum);
80 $biblio = $data->{'biblionumber'};
82 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
84 template_name => "acqui/newbiblio.tmpl",
88 flagsrequired => { acquisition => 1 },
93 # get currencies (for change rates calcs if needed
94 my ( $count, $rates ) = getcurrencies();
95 my @loop_currency = ();
96 for ( my $i = 0 ; $i < $count ; $i++ ) {
98 $line{currency} = $rates->[$i]->{'currency'};
99 $line{rate} = $rates->[$i]->{'rate'};
100 push @loop_currency, \%line;
103 # build itemtype list
106 "Select itemtype,description from itemtypes order by description");
110 while ( my ( $value, $lib ) = $sth->fetchrow_array ) {
111 push @itemtype, $value;
112 $itemtypes{$value} = $lib;
114 my $CGIitemtype = CGI::scrolling_list(
116 -values => \@itemtype,
117 -default => $data->{'itemtype'},
118 -labels => \%itemtypes,
124 # build branches list
125 my $branches = getbranches;
127 foreach my $thisbranch ( sort keys %$branches ) {
129 value => $thisbranch,
130 branchname => $branches->{$thisbranch}->{'branchname'},
132 push @branchloop, \%row;
134 $template->param( branchloop => \@branchloop );
136 # build bookfund list
139 "Select flags, branchcode from borrowers where borrowernumber = ?");
140 $sthtemp->execute($loggedinuser);
141 my ( $flags, $homebranch ) = $sthtemp->fetchrow;
146 my %select_bookfunds;
147 ( $count2, @bookfund ) = bookfunds($homebranch);
148 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
149 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
150 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
151 $bookfund[$i]->{'bookfundname'};
153 my $CGIbookfund = CGI::scrolling_list(
155 -values => \@select_bookfund,
156 -default => $data->{'bookfundid'},
157 -labels => \%select_bookfunds,
164 $bookfundid = $data->{'bookfundid'};
165 $bookfundname = $select_bookfunds{$bookfundid};
169 my $CGIsort1 = buildCGIsort( "Asort1", "sort1", $data->{'sort1'} );
171 $template->param( CGIsort1 => $CGIsort1 );
174 $template->param( sort1 => $data->{'sort1'} );
177 my $CGIsort2 = buildCGIsort( "Asort2", "sort2", $data->{'sort2'} );
179 $template->param( CGIsort2 => $CGIsort2 );
182 $template->param( sort2 => $data->{'sort2'} );
188 bookfundid => $bookfundid,
189 bookfundname => $bookfundname
197 basketno => $basketno,
198 booksellerid => $booksellerid,
199 suggestionid => $suggestionid,
201 biblioitemnumber => $data->{'biblioitemnumber'},
202 itemtype => $data->{'itemtype'},
203 discount => $booksellers[0]->{'discount'},
204 listincgst => $booksellers[0]->{'listincgst'},
205 listprice => $booksellers[0]->{'listprice'},
206 gstreg => $booksellers[0]->{'gstreg'},
207 invoiceinc => $booksellers[0]->{'invoiceincgst'},
208 invoicedisc => $booksellers[0]->{'invoicedisc'},
209 nocalc => $booksellers[0]->{'nocalc'},
210 name => $booksellers[0]->{'name'},
211 currency => $booksellers[0]->{'listprice'},
212 gstrate => C4::Context->preference("gist"),
213 loop_currencies => \@loop_currency,
214 orderexists => ( $new eq 'yes' ) ? 0 : 1,
215 title => $data->{'title'},
216 author => $data->{'author'},
217 copyrightdate => $data->{'copyrightdate'},
218 CGIitemtype => $CGIitemtype,
219 CGIbookfund => $CGIbookfund,
220 isbn => $data->{'isbn'},
221 seriestitle => $data->{'seriestitle'},
222 quantity => $data->{'quantity'},
223 listprice => $data->{'listprice'},
224 rrp => $data->{'rrp'},
225 invoice => $data->{'booksellerinvoicenumber'},
226 ecost => $data->{'ecost'},
227 notes => $data->{'notes'},
228 publishercode => $data->{'publishercode'}
231 output_html_with_http_headers $input, $cookie, $template->output;