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.
72 use C4
::Bookseller
; # GetBookSellerFromId
74 use C4
::Suggestions
; # GetSuggestion
75 use C4
::Biblio
; # GetBiblioData
79 use C4
::Branch
; # GetBranches
83 my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR!
84 my $title = $input->param('title');
85 my $author = $input->param('author');
86 my $copyright = $input->param('copyright');
87 my $bookseller = GetBookSellerFromId
($booksellerid); # FIXME: else ERROR!
88 my $ordnum = $input->param('ordnum');
89 my $biblionumber = $input->param('biblionumber');
90 my $basketno = $input->param('basketno');
91 my $purchaseorder= $input->param('purchaseordernumber');
92 my $suggestionid = $input->param('suggestionid');
93 # my $donation = $input->param('donation');
94 my $close = $input->param('close');
97 my $dbh = C4
::Context
->dbh;
99 if ( $ordnum eq '' ) { # create order
102 # $ordnum=newordernum;
103 if ( $biblionumber && !$suggestionid ) {
104 $data = GetBiblioData
($biblionumber);
107 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
108 # otherwise, retrieve suggestion information.
110 $data = ($biblionumber) ? GetBiblioData
($biblionumber) : GetSuggestion
($suggestionid);
114 $data = GetOrder
($ordnum);
115 $biblionumber = $data->{'biblionumber'};
116 #get basketno and supplierno. too!
117 my $data2 = GetBasket
( $data->{'basketno'} );
118 $basketno = $data2->{'basketno'};
119 $booksellerid = $data2->{'booksellerid'};
122 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
124 template_name
=> "acqui/neworderempty.tmpl",
127 authnotrequired
=> 0,
128 flagsrequired
=> { acquisition
=> 1 },
133 # get currencies (for change rates calcs if needed)
134 my @rates = GetCurrencies
();
135 my $count = scalar @rates;
137 my @loop_currency = ();
138 for ( my $i = 0 ; $i < $count ; $i++ ) {
140 $line{currency
} = $rates[$i]->{'currency'};
141 $line{rate
} = $rates[$i]->{'rate'};
142 push @loop_currency, \
%line;
145 # build itemtype list
146 my $itemtypes = GetItemTypes
;
149 foreach my $thisitemtype (sort keys %$itemtypes) {
150 push @itemtypesloop, { itemtype
=> $itemtypes->{$thisitemtype}->{'itemtype'} , desc
=> $itemtypes->{$thisitemtype}->{'description'} } ;
153 # build branches list
154 my $onlymine=C4
::Context
->preference('IndependantBranches') &&
155 C4
::Context
->userenv &&
156 C4
::Context
->userenv->{flags
}!=1 &&
157 C4
::Context
->userenv->{branch
};
158 my $branches = GetBranches
($onlymine);
160 foreach my $thisbranch ( sort keys %$branches ) {
162 value
=> $thisbranch,
163 branchname
=> $branches->{$thisbranch}->{'branchname'},
165 $row{'selected'} = 1 if( $thisbranch eq $data->{branchcode
}) ;
166 push @branchloop, \
%row;
168 $template->param( branchloop
=> \
@branchloop , itypeloop
=> \
@itemtypesloop );
170 # build bookfund list
171 my $borrower= GetMember
($loggedinuser);
172 my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
175 my %select_bookfunds;
177 my @bookfund = GetBookFunds
($homebranch);
178 my $count2 = scalar @bookfund;
180 for ( my $i = 0 ; $i < $count2 ; $i++ ) {
181 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
182 $select_bookfunds{ $bookfund[$i]->{'bookfundid'} } =
183 $bookfund[$i]->{'bookfundname'};
185 my $CGIbookfund = CGI
::scrolling_list
(
188 -values => \
@select_bookfund,
189 -default => ($data->{'bookfundid'} ?
$data->{'bookfundid'} : $select_bookfund[0]),
190 -labels
=> \
%select_bookfunds,
198 $bookfundid = $data->{'bookfundid'};
199 $bookfundname = $select_bookfunds{$bookfundid};
203 my $CGIsort1 = buildCGIsort
( "Asort1", "sort1", $data->{'sort1'} );
205 $template->param( CGIsort1
=> $CGIsort1 );
207 $template->param( sort1
=> $data->{'sort1'} );
210 my $CGIsort2 = buildCGIsort
( "Asort2", "sort2", $data->{'sort2'} );
212 $template->param( CGIsort2
=> $CGIsort2 );
214 $template->param( sort2
=> $data->{'sort2'} );
217 #do a biblioitems lookup on bib
218 my @bibitems = GetBiblioItemByBiblioNumber
($biblionumber);
219 my $bibitemscount = scalar @bibitems;
221 if ( $bibitemscount > 0 ) {
222 # warn "NEWBIBLIO: bibitems for $biblio exists\n";
224 for ( my $i = 0 ; $i < $bibitemscount ; $i++ ) {
226 $line{biblioitemnumber
} = $bibitems[$i]->{'biblioitemnumber'};
227 $line{isbn
} = $bibitems[$i]->{'isbn'};
228 $line{itemtype
} = $bibitems[$i]->{'itemtype'};
229 $line{volumeddesc
} = $bibitems[$i]->{'volumeddesc'};
230 push( @bibitemloop, \
%line );
232 $template->param( bibitemloop
=> \
@bibitemloop );
234 $template->param( bibitemexists
=> "1" );
240 bookfundid
=> $bookfundid,
241 bookfundname
=> $bookfundname
246 existing
=> $biblionumber,
248 basketno
=> $basketno,
249 booksellerid
=> $booksellerid,
250 suggestionid
=> $suggestionid,
251 biblionumber
=> $biblionumber,
252 authorisedbyname
=> $borrower->{'firstname'} . " " . $borrower->{'surname'},
253 biblioitemnumber
=> $data->{'biblioitemnumber'},
254 itemtype
=> $data->{'itemtype'},
255 itemtype_desc
=> $itemtypes->{$data->{'itemtype'}}->{description
},
256 discount
=> $bookseller->{'discount'},
257 listincgst
=> $bookseller->{'listincgst'},
258 listprice
=> $bookseller->{'listprice'},
259 gstreg
=> $bookseller->{'gstreg'},
260 invoiceinc
=> $bookseller->{'invoiceincgst'},
261 invoicedisc
=> $bookseller->{'invoicedisc'},
262 nocalc
=> $bookseller->{'nocalc'},
263 name
=> $bookseller->{'name'},
264 currency
=> $bookseller->{'listprice'},
265 gstrate
=> C4
::Context
->preference("gist"),
266 loop_currencies
=> \
@loop_currency,
267 orderexists
=> ( $new eq 'yes' ) ?
0 : 1,
268 title
=> $data->{'title'},
269 author
=> $data->{'author'},
270 copyrightdate
=> $data->{'copyrightdate'},
271 CGIbookfund
=> $CGIbookfund,
272 isbn
=> $data->{'isbn'},
273 seriestitle
=> $data->{'seriestitle'},
274 quantity
=> $data->{'quantity'},
275 listprice
=> $data->{'listprice'},
276 rrp
=> $data->{'rrp'},
277 total
=> $data->{ecost
}*$data->{quantity
},
278 invoice
=> $data->{'booksellerinvoicenumber'},
279 ecost
=> $data->{'ecost'},
280 purchaseordernumber
=> $data->{'purchaseordernumber'},
281 notes
=> $data->{'notes'},
282 publishercode
=> $data->{'publishercode'},
283 # donation => $donation
286 output_html_with_http_headers
$input, $cookie, $template->output;