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.
79 use C4
::Branch
; # GetBranches
83 my $booksellerid = $input->param('booksellerid');
84 my $title = $input->param('title');
85 my $author = $input->param('author');
86 my $copyright = $input->param('copyright');
87 my @booksellers = GetBookSeller
($booksellerid);
88 my $count = scalar @booksellers;
89 my $ordnum = $input->param('ordnum');
90 my $biblionumber = $input->param('biblionumber');
91 my $basketno = $input->param('basketno');
92 my $purchaseorder= $input->param('purchaseordernumber');
93 my $suggestionid = $input->param('suggestionid');
94 # my $donation = $input->param('donation');
95 my $close = $input->param('close');
98 my $dbh = C4
::Context
->dbh;
100 if ( $ordnum eq '' ) { # create order
103 # $ordnum=newordernum;
104 if ( $biblionumber && !$suggestionid ) {
105 $data = GetBiblioData
($biblionumber);
108 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
109 # otherwise, retrieve suggestion information.
112 $data = GetBiblioData
($biblionumber);
115 $data = GetSuggestion
($suggestionid);
120 $data = GetOrder
($ordnum);
121 $biblionumber = $data->{'biblionumber'};
122 #get basketno and suppleirno. too!
123 my $data2 = GetBasket
( $data->{'basketno'} );
124 $basketno = $data2->{'basketno'};
125 $booksellerid = $data2->{'booksellerid'};
128 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
130 template_name
=> "acqui/neworderempty.tmpl",
133 authnotrequired
=> 0,
134 flagsrequired
=> { acquisition
=> 1 },
139 # get currencies (for change rates calcs if needed)
140 my @rates = GetCurrencies
();
141 $count = scalar @rates;
143 my @loop_currency = ();
144 for ( my $i = 0 ; $i < $count ; $i++ ) {
146 $line{currency
} = $rates[$i]->{'currency'};
147 $line{rate
} = $rates[$i]->{'rate'};
148 push @loop_currency, \
%line;
151 # build itemtype list
152 my $itemtypes = GetItemTypes
;
155 foreach my $thisitemtype (sort keys %$itemtypes) {
156 push @itemtypesloop, { itemtype
=> $itemtypes->{$thisitemtype}->{'itemtype'} , desc
=> $itemtypes->{$thisitemtype}->{'description'} } ;
159 # build branches list
160 my $onlymine=C4
::Context
->preference('IndependantBranches') &&
161 C4
::Context
->userenv &&
162 C4
::Context
->userenv->{flags
}!=1 &&
163 C4
::Context
->userenv->{branch
};
164 my $branches = GetBranches
($onlymine);
166 foreach my $thisbranch ( sort keys %$branches ) {
168 value
=> $thisbranch,
169 branchname
=> $branches->{$thisbranch}->{'branchname'},
171 push @branchloop, \
%row;
173 $template->param( branchloop
=> \
@branchloop , itypeloop
=> \
@itemtypesloop );
175 # build bookfund list
176 my $borrower= GetMember
($loggedinuser);
177 my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
182 my %select_bookfunds;
184 @bookfund = GetBookFunds
($homebranch);
185 $count2 = scalar @bookfund;
187 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
188 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
189 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
190 $bookfund[$i]->{'bookfundname'};
192 my $CGIbookfund = CGI
::scrolling_list
(
195 -values => \
@select_bookfund,
196 -default => $data->{'bookfundid'},
197 -labels
=> \
%select_bookfunds,
206 $bookfundid = $data->{'bookfundid'};
207 $bookfundname = $select_bookfunds{$bookfundid};
211 my $CGIsort1 = buildCGIsort
( "Asort1", "sort1", $data->{'sort1'} );
213 $template->param( CGIsort1
=> $CGIsort1 );
216 $template->param( sort1
=> $data->{'sort1'} );
219 my $CGIsort2 = buildCGIsort
( "Asort2", "sort2", $data->{'sort2'} );
221 $template->param( CGIsort2
=> $CGIsort2 );
224 $template->param( sort2
=> $data->{'sort2'} );
229 #do a biblioitems lookup on bib
230 my @bibitems = GetBiblioItemByBiblioNumber
($biblionumber);
231 my $bibitemscount = scalar @bibitems;
233 if ( $bibitemscount > 0 ) {
234 # warn "NEWBIBLIO: bibitems for $biblio exists\n";
238 for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
240 $line{biblioitemnumber
} = $bibitems[$i]->{'biblioitemnumber'};
241 $line{isbn
} = $bibitems[$i]->{'isbn'};
242 $line{itemtype
} = $bibitems[$i]->{'itemtype'};
243 $line{volumeddesc
} = $bibitems[$i]->{'volumeddesc'};
244 push( @bibitemloop, \
%line );
246 $template->param( bibitemloop
=> \
@bibitemloop );
248 $template->param( bibitemexists
=> "1" );
254 bookfundid
=> $bookfundid,
255 bookfundname
=> $bookfundname
260 existing
=> $biblionumber,
262 basketno
=> $basketno,
263 booksellerid
=> $booksellerid,
264 suggestionid
=> $suggestionid,
265 biblionumber
=> $biblionumber,
266 authorisedbyname
=> $borrower->{'firstname'} . " " . $borrower->{'surname'},
267 biblioitemnumber
=> $data->{'biblioitemnumber'},
268 itemtype
=> $data->{'itemtype'},
269 itemtype_desc
=> $itemtypes->{$data->{'itemtype'}}->{description
},
270 discount
=> $booksellers[0]->{'discount'},
271 listincgst
=> $booksellers[0]->{'listincgst'},
272 listprice
=> $booksellers[0]->{'listprice'},
273 gstreg
=> $booksellers[0]->{'gstreg'},
274 invoiceinc
=> $booksellers[0]->{'invoiceincgst'},
275 invoicedisc
=> $booksellers[0]->{'invoicedisc'},
276 nocalc
=> $booksellers[0]->{'nocalc'},
277 name
=> $booksellers[0]->{'name'},
278 currency
=> $booksellers[0]->{'listprice'},
279 gstrate
=> C4
::Context
->preference("gist"),
280 loop_currencies
=> \
@loop_currency,
281 orderexists
=> ( $new eq 'yes' ) ?
0 : 1,
282 title
=> $data->{'title'},
283 author
=> $data->{'author'},
284 copyrightdate
=> $data->{'copyrightdate'},
285 CGIbookfund
=> $CGIbookfund,
286 isbn
=> $data->{'isbn'},
287 seriestitle
=> $data->{'seriestitle'},
288 quantity
=> $data->{'quantity'},
289 listprice
=> $data->{'listprice'},
290 rrp
=> $data->{'rrp'},
291 total
=> $data->{ecost
}*$data->{quantity
},
292 invoice
=> $data->{'booksellerinvoicenumber'},
293 ecost
=> $data->{'ecost'},
294 purchaseordernumber
=> $data->{'purchaseordernumber'},
295 notes
=> $data->{'notes'},
296 publishercode
=> $data->{'publishercode'},
297 # donation => $donation
300 output_html_with_http_headers
$input, $cookie, $template->output;