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
29 this script allows to create a new record to order it. This record shouldn't exist
37 the bookseller the librarian has to buy a new book.
40 the title of this new record.
43 the author of this new record.
46 the copyright of this new record.
49 the number of this order.
54 the basket number for this new order.
57 if this order comes from a suggestion.
80 use C4::Interface::CGI::Output;
85 my $booksellerid = $input->param('booksellerid');
86 my $title = $input->param('title');
87 my $author = $input->param('author');
88 my $copyright = $input->param('copyright');
89 my @booksellers = GetBookSeller($booksellerid);
90 my $count = scalar @booksellers;
91 my $ordnum = $input->param('ordnum');
92 my $biblio = $input->param('biblio');
93 my $basketno = $input->param('basketno');
94 my $suggestionid = $input->param('suggestionid');
95 # my $donation = $input->param('donation');
96 my $close = $input->param('close');
99 my $dbh = C4::Context->dbh;
101 if ( $ordnum eq '' ) { # create order
104 # $ordnum=newordernum;
105 if ( $biblio && !$suggestionid ) {
106 $data = bibdata($biblio);
109 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
110 # otherwise, retrieve suggestion information.
113 $data = bibdata($biblio);
116 $data = GetSuggestion($suggestionid);
119 if ( $data->{'title'} eq '' ) {
120 $data->{'title'} = $title;
121 $data->{'author'} = $author;
122 $data->{'copyrightdate'} = $copyright;
126 $data = GetSingleOrder($ordnum);
127 $biblio = $data->{'biblionumber'};
128 #get basketno and suppleirno. too!
129 my $data2 = GetBasket( $data->{'basketno'} );
130 $basketno = $data2->{'basketno'};
131 $booksellerid = $data2->{'booksellerid'};
134 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
136 template_name => "acqui/newbiblio.tmpl",
139 authnotrequired => 0,
140 flagsrequired => { acquisition => 1 },
145 # get currencies (for change rates calcs if needed)
146 my @rates = GetCurrencies();
147 my $count = scalar @rates;
149 my @loop_currency = ();
150 for ( my $i = 0 ; $i < $count ; $i++ ) {
152 $line{currency} = $rates[$i]->{'currency'};
153 $line{rate} = $rates[$i]->{'rate'};
154 push @loop_currency, \%line;
157 # build itemtype list
158 my $itemtypes = GetItemTypes;
162 foreach my $thisitemtype (sort keys %$itemtypes) {
163 push @itemtypesloop, $itemtypes->{$thisitemtype}->{'itemtype'};
164 $itemtypesloop{$itemtypes->{$thisitemtype}->{'itemtype'}} = $itemtypes->{$thisitemtype}->{'description'};
167 my $CGIitemtype = CGI::scrolling_list(
169 -values => \@itemtypesloop,
170 -default => $data->{'itemtype'},
171 -labels => \%itemtypesloop,
176 # build branches list
177 my $branches = GetBranches;
179 foreach my $thisbranch ( sort keys %$branches ) {
181 value => $thisbranch,
182 branchname => $branches->{$thisbranch}->{'branchname'},
184 push @branchloop, \%row;
186 $template->param( branchloop => \@branchloop );
188 # build bookfund list
189 my ($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser);
194 my %select_bookfunds;
196 @bookfund = GetBookFunds($homebranch);
197 $count2 = scalar @bookfund;
199 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
200 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
201 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
202 $bookfund[$i]->{'bookfundname'};
204 my $CGIbookfund = CGI::scrolling_list(
206 -values => \@select_bookfund,
207 -default => $data->{'bookfundid'},
208 -labels => \%select_bookfunds,
216 $bookfundid = $data->{'bookfundid'};
217 $bookfundname = $select_bookfunds{$bookfundid};
221 my $CGIsort1 = buildCGIsort( "Asort1", "sort1", $data->{'sort1'} );
223 $template->param( CGIsort1 => $CGIsort1 );
226 $template->param( sort1 => $data->{'sort1'} );
229 my $CGIsort2 = buildCGIsort( "Asort2", "sort2", $data->{'sort2'} );
231 $template->param( CGIsort2 => $CGIsort2 );
234 $template->param( sort2 => $data->{'sort2'} );
239 #do a biblioitems lookup on bib
240 my @bibitems = GetBiblioItemByBiblioNumber($biblio);
241 my $bibitemscount = scalar @bibitems;
243 if ( $bibitemscount > 0 ) {
244 # warn "NEWBIBLIO: bibitems for $biblio exists\n";
245 # warn Dumper $bibitemscount, @bibitems;
249 for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
251 $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'};
252 $line{isbn} = $bibitems[$i]->{'isbn'};
253 $line{itemtype} = $bibitems[$i]->{'itemtype'};
254 $line{volumeddesc} = $bibitems[$i]->{'volumeddesc'};
255 push( @bibitemloop, \%line );
257 $template->param( bibitemloop => \@bibitemloop );
259 $template->param( bibitemexists => "1" );
265 bookfundid => $bookfundid,
266 bookfundname => $bookfundname
274 basketno => $basketno,
275 booksellerid => $booksellerid,
276 suggestionid => $suggestionid,
278 biblioitemnumber => $data->{'biblioitemnumber'},
279 itemtype => $data->{'itemtype'},
280 discount => $booksellers[0]->{'discount'},
281 listincgst => $booksellers[0]->{'listincgst'},
282 listprice => $booksellers[0]->{'listprice'},
283 gstreg => $booksellers[0]->{'gstreg'},
284 invoiceinc => $booksellers[0]->{'invoiceincgst'},
285 invoicedisc => $booksellers[0]->{'invoicedisc'},
286 nocalc => $booksellers[0]->{'nocalc'},
287 name => $booksellers[0]->{'name'},
288 currency => $booksellers[0]->{'listprice'},
289 gstrate => C4::Context->preference("gist"),
290 loop_currencies => \@loop_currency,
291 orderexists => ( $new eq 'yes' ) ? 0 : 1,
292 title => $data->{'title'},
293 author => $data->{'author'},
294 copyrightdate => $data->{'copyrightdate'},
295 CGIitemtype => $CGIitemtype,
296 CGIbookfund => $CGIbookfund,
297 isbn => $data->{'isbn'},
298 seriestitle => $data->{'seriestitle'},
299 quantity => $data->{'quantity'},
300 listprice => $data->{'listprice'},
301 rrp => $data->{'rrp'},
302 invoice => $data->{'booksellerinvoicenumber'},
303 ecost => $data->{'ecost'},
304 notes => $data->{'notes'},
305 publishercode => $data->{'publishercode'},
306 # donation => $donation
309 output_html_with_http_headers $input, $cookie, $template->output;