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 $donation = $input->param('donation');
50 my $close = $input->param('close');
53 my $dbh = C4::Context->dbh;
55 if ( $ordnum eq '' ) { # create order
58 # $ordnum=newordernum;
59 if ( $biblio && !$suggestionid ) {
60 $data = bibdata($biblio);
63 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
64 # otherwise, retrieve suggestion information.
67 $data = bibdata($biblio);
70 $data = GetSuggestion($suggestionid);
73 if ( $data->{'title'} eq '' ) {
74 $data->{'title'} = $title;
75 $data->{'author'} = $author;
76 $data->{'copyrightdate'} = $copyright;
80 $data = getsingleorder($ordnum);
81 $biblio = $data->{'biblionumber'};
82 #get basketno and suppleirno. too!
83 my $data2 = getbasket( $data->{'basketno'} );
84 $basketno = $data2->{'basketno'};
85 $booksellerid = $data2->{'booksellerid'};
88 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
90 template_name => "acqui/newbiblio.tmpl",
94 flagsrequired => { acquisition => 1 },
99 # get currencies (for change rates calcs if needed
100 my ( $count, $rates ) = getcurrencies();
101 my @loop_currency = ();
102 for ( my $i = 0 ; $i < $count ; $i++ ) {
104 $line{currency} = $rates->[$i]->{'currency'};
105 $line{rate} = $rates->[$i]->{'rate'};
106 push @loop_currency, \%line;
109 # build itemtype list
112 "Select itemtype,description from itemtypes order by description");
116 while ( my ( $value, $lib ) = $sth->fetchrow_array ) {
117 push @itemtype, $value;
118 $itemtypes{$value} = $lib;
120 my $CGIitemtype = CGI::scrolling_list(
122 -values => \@itemtype,
123 -default => $data->{'itemtype'},
124 -labels => \%itemtypes,
130 # build branches list
131 my $branches = getbranches;
133 foreach my $thisbranch ( sort keys %$branches ) {
135 value => $thisbranch,
136 branchname => $branches->{$thisbranch}->{'branchname'},
138 push @branchloop, \%row;
140 $template->param( branchloop => \@branchloop );
142 # build bookfund list
145 "Select flags, branchcode from borrowers where borrowernumber = ?");
146 $sthtemp->execute($loggedinuser);
147 my ( $flags, $homebranch ) = $sthtemp->fetchrow;
152 my %select_bookfunds;
153 ( $count2, @bookfund ) = bookfunds($homebranch);
154 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
155 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
156 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
157 $bookfund[$i]->{'bookfundname'};
159 my $CGIbookfund = CGI::scrolling_list(
161 -values => \@select_bookfund,
162 -default => $data->{'bookfundid'},
163 -labels => \%select_bookfunds,
170 $bookfundid = $data->{'bookfundid'};
171 $bookfundname = $select_bookfunds{$bookfundid};
175 my $CGIsort1 = buildCGIsort( "Asort1", "sort1", $data->{'sort1'} );
177 $template->param( CGIsort1 => $CGIsort1 );
180 $template->param( sort1 => $data->{'sort1'} );
183 my $CGIsort2 = buildCGIsort( "Asort2", "sort2", $data->{'sort2'} );
185 $template->param( CGIsort2 => $CGIsort2 );
188 $template->param( sort2 => $data->{'sort2'} );
193 #do a biblioitems lookup on bib
194 ( my $bibitemscount, my @bibitems ) = getbiblioitembybiblionumber($biblio);
195 if ( $bibitemscount > 0 ) {
196 # warn "NEWBIBLIO: bibitems for $biblio exists\n";
197 # warn Dumper $bibitemscount, @bibitems;
201 for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
203 $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'};
204 $line{isbn} = $bibitems[$i]->{'isbn'};
205 $line{itemtype} = $bibitems[$i]->{'itemtype'};
206 $line{volumeddesc} = $bibitems[$i]->{'volumeddesc'};
207 push( @bibitemloop, \%line );
209 $template->param( bibitemloop => \@bibitemloop );
211 $template->param( bibitemexists => "1" );
217 bookfundid => $bookfundid,
218 bookfundname => $bookfundname
226 basketno => $basketno,
227 booksellerid => $booksellerid,
228 suggestionid => $suggestionid,
230 biblioitemnumber => $data->{'biblioitemnumber'},
231 itemtype => $data->{'itemtype'},
232 discount => $booksellers[0]->{'discount'},
233 listincgst => $booksellers[0]->{'listincgst'},
234 listprice => $booksellers[0]->{'listprice'},
235 gstreg => $booksellers[0]->{'gstreg'},
236 invoiceinc => $booksellers[0]->{'invoiceincgst'},
237 invoicedisc => $booksellers[0]->{'invoicedisc'},
238 nocalc => $booksellers[0]->{'nocalc'},
239 name => $booksellers[0]->{'name'},
240 currency => $booksellers[0]->{'listprice'},
241 gstrate => C4::Context->preference("gist"),
242 loop_currencies => \@loop_currency,
243 orderexists => ( $new eq 'yes' ) ? 0 : 1,
244 title => $data->{'title'},
245 author => $data->{'author'},
246 copyrightdate => $data->{'copyrightdate'},
247 CGIitemtype => $CGIitemtype,
248 CGIbookfund => $CGIbookfund,
249 isbn => $data->{'isbn'},
250 seriestitle => $data->{'seriestitle'},
251 quantity => $data->{'quantity'},
252 listprice => $data->{'listprice'},
253 rrp => $data->{'rrp'},
254 invoice => $data->{'booksellerinvoicenumber'},
255 ecost => $data->{'ecost'},
256 notes => $data->{'notes'},
257 publishercode => $data->{'publishercode'},
258 donation => $donation
261 output_html_with_http_headers $input, $cookie, $template->output;