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 ) {
180 my $selected = 1 if $thisbranch eq $branch;
182 value => $thisbranch,
183 selected => $selected,
184 branchname => $branches->{$thisbranch}->{'branchname'},
186 push @branchloop, \%row;
188 $template->param( branchloop => \@branchloop );
190 # build bookfund list
191 my ($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser);
196 my %select_bookfunds;
198 @bookfund = GetBookFunds($homebranch);
199 $count2 = scalar @bookfund;
201 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
202 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
203 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
204 $bookfund[$i]->{'bookfundname'};
206 my $CGIbookfund = CGI::scrolling_list(
208 -values => \@select_bookfund,
209 -default => $data->{'bookfundid'},
210 -labels => \%select_bookfunds,
218 $bookfundid = $data->{'bookfundid'};
219 $bookfundname = $select_bookfunds{$bookfundid};
223 my $CGIsort1 = buildCGIsort( "Asort1", "sort1", $data->{'sort1'} );
225 $template->param( CGIsort1 => $CGIsort1 );
228 $template->param( sort1 => $data->{'sort1'} );
231 my $CGIsort2 = buildCGIsort( "Asort2", "sort2", $data->{'sort2'} );
233 $template->param( CGIsort2 => $CGIsort2 );
236 $template->param( sort2 => $data->{'sort2'} );
241 #do a biblioitems lookup on bib
242 my @bibitems = GetBiblioItemByBiblioNumber($biblio);
243 my $bibitemscount = scalar @bibitems;
245 if ( $bibitemscount > 0 ) {
246 # warn "NEWBIBLIO: bibitems for $biblio exists\n";
247 # warn Dumper $bibitemscount, @bibitems;
251 for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
253 $line{biblioitemnumber} = $bibitems[$i]->{'biblioitemnumber'};
254 $line{isbn} = $bibitems[$i]->{'isbn'};
255 $line{itemtype} = $bibitems[$i]->{'itemtype'};
256 $line{volumeddesc} = $bibitems[$i]->{'volumeddesc'};
257 push( @bibitemloop, \%line );
259 $template->param( bibitemloop => \@bibitemloop );
261 $template->param( bibitemexists => "1" );
267 bookfundid => $bookfundid,
268 bookfundname => $bookfundname
276 basketno => $basketno,
277 booksellerid => $booksellerid,
278 suggestionid => $suggestionid,
280 biblioitemnumber => $data->{'biblioitemnumber'},
281 itemtype => $data->{'itemtype'},
282 discount => $booksellers[0]->{'discount'},
283 listincgst => $booksellers[0]->{'listincgst'},
284 listprice => $booksellers[0]->{'listprice'},
285 gstreg => $booksellers[0]->{'gstreg'},
286 invoiceinc => $booksellers[0]->{'invoiceincgst'},
287 invoicedisc => $booksellers[0]->{'invoicedisc'},
288 nocalc => $booksellers[0]->{'nocalc'},
289 name => $booksellers[0]->{'name'},
290 currency => $booksellers[0]->{'listprice'},
291 gstrate => C4::Context->preference("gist"),
292 loop_currencies => \@loop_currency,
293 orderexists => ( $new eq 'yes' ) ? 0 : 1,
294 title => $data->{'title'},
295 author => $data->{'author'},
296 copyrightdate => $data->{'copyrightdate'},
297 CGIitemtype => $CGIitemtype,
298 CGIbookfund => $CGIbookfund,
299 isbn => $data->{'isbn'},
300 seriestitle => $data->{'seriestitle'},
301 quantity => $data->{'quantity'},
302 listprice => $data->{'listprice'},
303 rrp => $data->{'rrp'},
304 invoice => $data->{'booksellerinvoicenumber'},
305 ecost => $data->{'ecost'},
306 notes => $data->{'notes'},
307 publishercode => $data->{'publishercode'},
308 # donation => $donation
311 output_html_with_http_headers $input, $cookie, $template->output;