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
31 use C4::Interface::CGI::Output;
40 # get_template_and_user used only to check auth & get user id
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "acqui/order.tmpl",
47 flagsrequired => { acquisition => 1 },
53 my $ordnum = $input->param('ordnum');
54 my $basketno = $input->param('basketno');
55 my $booksellerid = $input->param('booksellerid');
57 $input->param('existing'); # existing biblio, (not basket or order)
58 my $title = $input->param('title');
59 my $author = $input->param('author');
60 my $copyrightdate = $input->param('copyrightdate');
61 my $isbn = $input->param('ISBN');
62 my $itemtype = $input->param('format');
63 my $quantity = $input->param('quantity');
64 my $listprice = $input->param('list_price');
65 my $branch = $input->param('branch');
66 if ( $listprice eq '' ) {
69 my $series = $input->param('series');
71 # my $supplier=$input->param('supplier');
72 my $notes = $input->param('notes');
73 my $bookfund = $input->param('bookfund');
74 my $sort1 = $input->param('sort1');
75 my $sort2 = $input->param('sort2');
76 my $rrp = $input->param('rrp');
77 my $ecost = $input->param('ecost');
78 my $gst = $input->param('GST');
79 my $budget = $input->param('budget');
80 my $cost = $input->param('cost');
81 my $sub = $input->param('sub');
82 my $invoice = $input->param('invoice');
83 my $publishercode = $input->param('publishercode');
84 my $suggestionid = $input->param('suggestionid');
85 my $donation = $input->param('donation');
86 my $user = $input->remote_user;
88 #warn "CREATEBIBITEM = $input->param('createbibitem')";
89 #warn Dumper $input->param('createbibitem');
90 my $createbibitem = $input->param('createbibitem');
92 # create, modify or delete biblio
93 # create if $quantity>=0 and $existing='no'
94 # modify if $quantity>=0 and $existing='yes'
95 # delete if $quantity has been se to 0 by the librarian
98 if ( $quantity ne '0' ) {
100 #check to see if biblio exists
101 if ( $existing eq 'no' ) {
103 #if it doesnt create it
104 $bibnum = &newbiblio(
106 title => $title ? $title : "",
107 author => $author ? $author : "",
108 copyrightdate => $copyrightdate ? $copyrightdate : "",
109 series => $series ? $series : "",
112 $bibitemnum = &newbiblioitem(
114 biblionumber => $bibnum,
115 itemtype => $itemtype ? $itemtype : "",
116 isbn => $isbn ? $isbn : "",
117 publishercode => $publishercode ? $publishercode : "",
121 # change suggestion status if applicable
123 changestatus( $suggestionid, 'ORDERED', '', $bibnum );
127 elsif ( $createbibitem eq 'YES' ) {
128 $bibnum = $input->param('biblio');
129 $bibitemnum = $input->param('bibitemnum');
130 $bibitemnum = &newbiblioitem(
132 biblionumber => $bibnum,
133 itemtype => $itemtype ? $itemtype : "",
134 isbn => $isbn ? $isbn : "",
135 publishercode => $publishercode ? $publishercode : "",
140 biblionumber => $bibnum,
141 title => $title ? $title : "",
142 author => $author ? $author : "",
143 copyrightdate => $copyrightdate ? $copyrightdate : "",
144 series => $series ? $series : ""
149 # then attach it to an existing bib
152 warn "attaching to an existing bibitem";
154 $bibnum = $input->param('biblio');
156 # if we are moddig the bibitem, not creating it createbib wont be set,
158 if ($createbibitem) {
159 $bibitemnum = $createbibitem;
162 $bibitemnum = $input->param('bibitemnum');
165 my $oldtype = $input->param('oldtype');
168 biblioitemnumber => $bibitemnum,
170 publishercode => $publishercode,
172 $itemtype, # added itemtype, not prev. being changed.
177 biblionumber => $bibnum,
178 title => $title ? $title : "",
179 author => $author ? $author : "",
180 copyrightdate => $copyrightdate ? $copyrightdate : "",
181 series => $series ? $series : ""
187 # warn "MODORDER $title / $ordnum / $quantity / $bookfund";
189 $title, $ordnum, $quantity, $listprice,
190 $bibnum, $basketno, $booksellerid, $loggedinuser,
191 $notes, $bookfund, $bibitemnum, $rrp,
192 $ecost, $gst, $budget, $cost,
193 $invoice, $sort1, $sort2
197 ( $basketno, $ordnum ) = neworder(
198 $basketno, $bibnum, $title, $quantity,
199 $listprice, $booksellerid, $loggedinuser, $notes,
200 $bookfund, $bibitemnum, $rrp, $ecost,
201 $gst, $budget, $cost, $sub,
202 $invoice, $sort1, $sort2
206 my $barcode = $input->param('barcode');
207 my @barcodes = split( /\,| |\|/, $barcode );
208 my ($error) = newitems(
210 biblioitemnumber => $bibitemnum,
211 biblionumber => $bibnum,
212 replacementprice => $rrp,
214 booksellerid => $booksellerid,
215 homebranch => $branch,
221 $bibnum, $ordnum, $quantity, $user, $cost,
222 $invoice, 0, $bookfund, $rrp
227 $bibnum = $input->param('biblio');
228 delorder( $bibnum, $ordnum );
230 print $input->redirect("basket.pl?basket=$basketno");