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 neworderbiblio.pl to add an order from nothing.
35 =item neworderempty.pl to add an order from an existing biblio.
37 =item newordersuggestion.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;
131 # get_template_and_user used only to check auth & get user id
132 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
134 template_name => "acqui/booksellers.tmpl",
137 authnotrequired => 0,
138 flagsrequired => { acquisition => 1 },
144 my $ordnum = $input->param('ordnum');
145 my $basketno = $input->param('basketno');
146 my $booksellerid = $input->param('booksellerid');
147 my $existing = $input->param('existing'); # existing biblio, (not basket or order)
148 my $title = $input->param('title');
149 my $author = $input->param('author');
150 my $copyrightdate = $input->param('copyrightdate');
151 my $isbn = $input->param('ISBN');
152 my $itemtype = $input->param('format');
153 my $quantity = $input->param('quantity');
154 my $listprice = $input->param('list_price');
155 my $branch = $input->param('branch');
156 if ( $listprice eq '' ) {
159 my $series = $input->param('series');
160 my $notes = $input->param('notes');
161 my $bookfund = $input->param('bookfund');
162 my $sort1 = $input->param('sort1');
163 my $sort2 = $input->param('sort2');
164 my $rrp = $input->param('rrp');
165 my $ecost = $input->param('ecost');
166 my $gst = $input->param('GST');
167 my $budget = $input->param('budget');
168 my $cost = $input->param('cost');
169 my $sub = $input->param('sub');
170 my $invoice = $input->param('invoice');
171 my $publishercode = $input->param('publishercode');
172 my $suggestionid = $input->param('suggestionid');
173 my $user = $input->remote_user;
175 #warn "CREATEBIBITEM = $input->param('createbibitem')";
176 #warn Dumper $input->param('createbibitem');
177 my $createbibitem = $input->param('createbibitem');
179 # create, modify or delete biblio
180 # create if $quantity>=0 and $existing='no'
181 # modify if $quantity>=0 and $existing='yes'
182 # delete if $quantity has been se to 0 by the librarian
183 my $biblionumber=$input->param('biblionumber');
185 if ( $quantity ne '0' ) {
186 #check to see if biblio exists
187 if ( $existing eq 'no' ) {
189 #if it doesnt create it
190 my $record = Koha2Marc(
192 "biblio.title" => "$title",
193 "biblio.author" => "$author",
194 "biblio.copyrightdate" => $copyrightdate ? $copyrightdate : "",
195 "biblio.series" => $series ? $series : "",
196 "biblioitems.itemtype" => $itemtype ? $itemtype : "",
197 "biblioitems.isbn" => $isbn ? $isbn : "",
198 "biblioitems.publishercode" => $publishercode ? $publishercode : "",
200 # create the record in catalogue, with framework ''
201 ($biblionumber,$bibitemnum) = AddBiblio($record,'');
203 # change suggestion status if applicable
205 ModStatus( $suggestionid, 'ORDERED', '', $biblionumber );
208 # if we already have $ordnum, then it's an ordermodif
211 $title, $ordnum, $quantity, $listprice,
212 $biblionumber, $basketno, $booksellerid, $loggedinuser,
213 $notes, $bookfund, $bibitemnum, $rrp,
214 $ecost, $gst, $budget, $cost,
215 $invoice, $sort1, $sort2
218 else { # else, it's a new line
219 ( $basketno, $ordnum ) = NewOrder(
220 $basketno, $biblionumber, $title, $quantity,
221 $listprice, $booksellerid, $loggedinuser, $notes,
222 $bookfund, $bibitemnum, $rrp, $ecost,
223 $gst, $budget, $cost, $sub,
224 $invoice, $sort1, $sort2
228 else { # qty=0, delete the line
229 $biblionumber = $input->param('biblionumber');
230 DelOrder( $biblionumber, $ordnum );
232 print $input->redirect("basket.pl?basketno=$basketno");