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.
121 use C4::Interface::CGI::Output;
124 # get_template_and_user used only to check auth & get user id
125 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
127 template_name => "acqui/booksellers.tmpl",
130 authnotrequired => 0,
131 flagsrequired => { acquisition => 1 },
138 my $ordnum = $input->param('ordnum');
139 my $basketno = $input->param('basketno');
140 my $booksellerid = $input->param('booksellerid');
141 my $existing = $input->param('existing'); # existing biblio, (not basket or order)
142 my $title = $input->param('title');
143 my $author = $input->param('author');
144 my $copyrightdate = $input->param('copyrightdate');
145 my $isbn = $input->param('ISBN');
146 my $itemtype = $input->param('format');
147 my $quantity = $input->param('quantity');
148 my $listprice = $input->param('list_price');
149 my $branch = $input->param('branch');
150 my $discount=$input->param('discount');
151 if ( $listprice eq '' ) {
154 my $series = $input->param('series');
155 my $notes = $input->param('notes');
156 my $bookfundid = $input->param('bookfundid');
157 my $sort1 = $input->param('sort1');
158 my $sort2 = $input->param('sort2');
159 my $rrp = $input->param('rrp');
160 my $ecost = $input->param('ecost');
161 my $gst = $input->param('gstrate');
162 my $budget = $input->param('budget');
163 my $unitprice = $input->param('unitprice');
164 my $sub = $input->param('sub');
165 my $purchaseordernumber = $input->param('purchaseordernumber');
166 my $publishercode = $input->param('publishercode');
167 my $suggestionid = $input->param('suggestionid');
168 my $donation = $input->param('donation');
169 my $user = $input->remote_user;
170 my $biblionumber=$input->param('biblionumber');
171 my $createbibitem = $input->param('createbibitem');
173 # create, modify or delete biblio
174 # create if $quantity>=0 and $existing='no'
175 # modify if $quantity>=0 and $existing='yes'
176 # delete if $quantity has been se to 0 by the librarian
177 my $dbh=C4::Context->dbh;
179 if ($quantity ne '0'){
180 #check to see if biblio exists
181 if ( $existing eq 'no' ) {
182 #if it doesnt its created on template
183 # change suggestion status if applicable
185 my $data=GetSuggestion($suggestionid);
187 my $biblio={title=>$data->{title},author=>$data->{author},publishercode=>$data->{publishercode},copyrightdate=>$data->{copyrightdate},isbn=>$data->{isbn},place=>$data->{place},};
188 my $xmlhash=XMLkoha2marc($dbh,$biblio,"biblios");
189 $biblionumber = NEWnewbiblio($dbh,$xmlhash,"");
191 ModStatus( $suggestionid, 'ORDERED', '', $biblionumber,$input );
194 }## biblio didnot exist now created
201 # warn "MODORDER $title / $ordnum / $quantity / $bookfund";
203 $title, $ordnum, $quantity, $listprice,
204 $biblionumber, $basketno, $booksellerid, $loggedinuser,
205 $notes, $bookfundid, $rrp,
206 $ecost, $gst, $budget, $unitprice,
207 $purchaseordernumber, $sort1, $sort2,$discount,$branch
211 ( $basketno, $ordnum ) = NewOrder(
212 $basketno, $biblionumber, $title, $quantity,
213 $listprice, $booksellerid, $loggedinuser, $notes,
214 $bookfundid, $rrp, $ecost,
215 $gst, $budget, $unitprice, $sub,
216 $purchaseordernumber, $sort1, $sort2, $discount,$branch
222 # $biblionumber = $input->param('biblionumber');
223 DelOrder( $biblionumber, $ordnum,$loggedinuser );
226 print $input->redirect("basket.pl?basketno=$basketno");