3 #script to add an order into the system
4 #written 29/2/00 by chris@katipo.co.nz
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
30 this script allows to add an order.
33 =item newbasket2.pl to add an order from nothing.
35 =item newbiblio.pl to add an order from an existing biblio.
37 =item suggestion-select.pl to add an order from an existing suggestion.
41 All of the cgi parameters below are related to the new order.
46 the number of this new order.
49 the number of this new basket
52 the bookseller the librarian has to pay.
57 the title of the record ordered.
60 the author of the record ordered.
62 =item C<copyrightdate>
63 the copyrightdate of the record ordered.
66 the ISBN of the record ordered.
71 the quantity to order.
74 the price of this order.
77 the branch where this order will be received.
85 bookfund use to pay this order.
87 =item C<sort1> & C<sort2>
102 the number of the invoice for this order.
104 =item C<publishercode>
106 =item C<suggestionid>
107 if it is an order from an existing suggestion : the id of this suggestion.
123 use C4::Interface::CGI::Output;
132 # get_template_and_user used only to check auth & get user id
133 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
135 template_name => "acqui/booksellers.tmpl",
138 authnotrequired => 0,
139 flagsrequired => { acquisition => 1 },
145 my $ordnum = $input->param('ordnum');
146 my $basketno = $input->param('basketno');
147 my $booksellerid = $input->param('booksellerid');
148 my $existing = $input->param('existing'); # existing biblio, (not basket or order)
149 my $title = $input->param('title');
150 my $author = $input->param('author');
151 my $copyrightdate = $input->param('copyrightdate');
152 my $isbn = $input->param('ISBN');
153 my $itemtype = $input->param('format');
154 my $quantity = $input->param('quantity');
155 my $listprice = $input->param('list_price');
156 my $branch = $input->param('branch');
157 if ( $listprice eq '' ) {
160 my $series = $input->param('series');
161 my $notes = $input->param('notes');
162 my $bookfund = $input->param('bookfund');
163 my $sort1 = $input->param('sort1');
164 my $sort2 = $input->param('sort2');
165 my $rrp = $input->param('rrp');
166 my $ecost = $input->param('ecost');
167 my $gst = $input->param('GST');
168 my $budget = $input->param('budget');
169 my $cost = $input->param('cost');
170 my $sub = $input->param('sub');
171 my $invoice = $input->param('invoice');
172 my $publishercode = $input->param('publishercode');
173 my $suggestionid = $input->param('suggestionid');
174 my $donation = $input->param('donation');
175 my $user = $input->remote_user;
177 #warn "CREATEBIBITEM = $input->param('createbibitem')";
178 #warn Dumper $input->param('createbibitem');
179 my $createbibitem = $input->param('createbibitem');
181 # create, modify or delete biblio
182 # create if $quantity>=0 and $existing='no'
183 # modify if $quantity>=0 and $existing='yes'
184 # delete if $quantity has been se to 0 by the librarian
187 if ( $quantity ne '0' ) {
189 #check to see if biblio exists
190 if ( $existing eq 'no' ) {
192 #if it doesnt create it
193 $bibnum = &newbiblio(
195 title => $title ? $title : "",
196 author => $author ? $author : "",
197 copyrightdate => $copyrightdate ? $copyrightdate : "",
198 series => $series ? $series : "",
201 $bibitemnum = &newbiblioitem(
203 biblionumber => $bibnum,
204 itemtype => $itemtype ? $itemtype : "",
205 isbn => $isbn ? $isbn : "",
206 publishercode => $publishercode ? $publishercode : "",
210 # change suggestion status if applicable
212 ModStatus( $suggestionid, 'ORDERED', '', $bibnum );
216 elsif ( $createbibitem eq 'YES' ) {
217 $bibnum = $input->param('biblio');
218 $bibitemnum = $input->param('bibitemnum');
219 $bibitemnum = &newbiblioitem(
221 biblionumber => $bibnum,
222 itemtype => $itemtype ? $itemtype : "",
223 isbn => $isbn ? $isbn : "",
224 publishercode => $publishercode ? $publishercode : "",
229 biblionumber => $bibnum,
230 title => $title ? $title : "",
231 author => $author ? $author : "",
232 copyrightdate => $copyrightdate ? $copyrightdate : "",
233 series => $series ? $series : ""
238 # then attach it to an existing bib
241 warn "attaching to an existing bibitem";
243 $bibnum = $input->param('biblio');
245 # if we are moddig the bibitem, not creating it createbib wont be set,
247 if ($createbibitem) {
248 $bibitemnum = $createbibitem;
251 $bibitemnum = $input->param('bibitemnum');
254 my $oldtype = $input->param('oldtype');
257 biblioitemnumber => $bibitemnum,
259 publishercode => $publishercode,
261 $itemtype, # added itemtype, not prev. being changed.
266 biblionumber => $bibnum,
267 title => $title ? $title : "",
268 author => $author ? $author : "",
269 copyrightdate => $copyrightdate ? $copyrightdate : "",
270 series => $series ? $series : ""
276 # warn "MODORDER $title / $ordnum / $quantity / $bookfund";
278 $title, $ordnum, $quantity, $listprice,
279 $bibnum, $basketno, $booksellerid, $loggedinuser,
280 $notes, $bookfund, $bibitemnum, $rrp,
281 $ecost, $gst, $budget, $cost,
282 $invoice, $sort1, $sort2
286 ( $basketno, $ordnum ) = NewOrder(
287 $basketno, $bibnum, $title, $quantity,
288 $listprice, $booksellerid, $loggedinuser, $notes,
289 $bookfund, $bibitemnum, $rrp, $ecost,
290 $gst, $budget, $cost, $sub,
291 $invoice, $sort1, $sort2
295 my $barcode = $input->param('barcode');
296 my @barcodes = split( /\,| |\|/, $barcode );
297 my ($error) = newitems(
299 biblioitemnumber => $bibitemnum,
300 biblionumber => $bibnum,
301 replacementprice => $rrp,
303 booksellerid => $booksellerid,
304 homebranch => $branch,
310 $bibnum, $ordnum, $quantity, $user, $cost,
311 $invoice, 0, $bookfund, $rrp
316 $bibnum = $input->param('biblio');
317 DelOrder( $bibnum, $ordnum );
319 print $input->redirect("basket.pl?basket=$basketno");