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');
56 my $existing = $input->param('existing'); # existing biblio, (not basket or order)
57 my $title = $input->param('title');
58 my $author = $input->param('author');
59 my $copyrightdate = $input->param('copyrightdate');
60 my $isbn = $input->param('ISBN');
61 my $itemtype = $input->param('format');
62 my $quantity = $input->param('quantity');
63 my $listprice = $input->param('list_price');
64 my $branch = $input->param('branch');
65 if ( $listprice eq '' ) {
68 my $series = $input->param('series');
69 my $notes = $input->param('notes');
70 my $bookfund = $input->param('bookfund');
71 my $sort1 = $input->param('sort1');
72 my $sort2 = $input->param('sort2');
73 my $rrp = $input->param('rrp');
74 my $ecost = $input->param('ecost');
75 my $gst = $input->param('GST');
76 my $budget = $input->param('budget');
77 my $cost = $input->param('cost');
78 my $sub = $input->param('sub');
79 my $invoice = $input->param('invoice');
80 my $publishercode = $input->param('publishercode');
81 my $suggestionid = $input->param('suggestionid');
82 my $donation = $input->param('donation');
83 my $user = $input->remote_user;
85 #warn "CREATEBIBITEM = $input->param('createbibitem')";
86 #warn Dumper $input->param('createbibitem');
87 my $createbibitem = $input->param('createbibitem');
89 # create, modify or delete biblio
90 # create if $quantity>=0 and $existing='no'
91 # modify if $quantity>=0 and $existing='yes'
92 # delete if $quantity has been se to 0 by the librarian
95 if ( $quantity ne '0' ) {
97 #check to see if biblio exists
98 if ( $existing eq 'no' ) {
100 #if it doesnt create it
101 $bibnum = &newbiblio(
103 title => $title ? $title : "",
104 author => $author ? $author : "",
105 copyrightdate => $copyrightdate ? $copyrightdate : "",
106 series => $series ? $series : "",
109 $bibitemnum = &newbiblioitem(
111 biblionumber => $bibnum,
112 itemtype => $itemtype ? $itemtype : "",
113 isbn => $isbn ? $isbn : "",
114 publishercode => $publishercode ? $publishercode : "",
118 # change suggestion status if applicable
120 ModStatus( $suggestionid, 'ORDERED', '', $bibnum );
124 elsif ( $createbibitem eq 'YES' ) {
125 $bibnum = $input->param('biblio');
126 $bibitemnum = $input->param('bibitemnum');
127 $bibitemnum = &newbiblioitem(
129 biblionumber => $bibnum,
130 itemtype => $itemtype ? $itemtype : "",
131 isbn => $isbn ? $isbn : "",
132 publishercode => $publishercode ? $publishercode : "",
137 biblionumber => $bibnum,
138 title => $title ? $title : "",
139 author => $author ? $author : "",
140 copyrightdate => $copyrightdate ? $copyrightdate : "",
141 series => $series ? $series : ""
146 # then attach it to an existing bib
149 warn "attaching to an existing bibitem";
151 $bibnum = $input->param('biblio');
153 # if we are moddig the bibitem, not creating it createbib wont be set,
155 if ($createbibitem) {
156 $bibitemnum = $createbibitem;
159 $bibitemnum = $input->param('bibitemnum');
162 my $oldtype = $input->param('oldtype');
165 biblioitemnumber => $bibitemnum,
167 publishercode => $publishercode,
169 $itemtype, # added itemtype, not prev. being changed.
174 biblionumber => $bibnum,
175 title => $title ? $title : "",
176 author => $author ? $author : "",
177 copyrightdate => $copyrightdate ? $copyrightdate : "",
178 series => $series ? $series : ""
184 # warn "MODORDER $title / $ordnum / $quantity / $bookfund";
186 $title, $ordnum, $quantity, $listprice,
187 $bibnum, $basketno, $booksellerid, $loggedinuser,
188 $notes, $bookfund, $bibitemnum, $rrp,
189 $ecost, $gst, $budget, $cost,
190 $invoice, $sort1, $sort2
194 ( $basketno, $ordnum ) = NewOrder(
195 $basketno, $bibnum, $title, $quantity,
196 $listprice, $booksellerid, $loggedinuser, $notes,
197 $bookfund, $bibitemnum, $rrp, $ecost,
198 $gst, $budget, $cost, $sub,
199 $invoice, $sort1, $sort2
203 my $barcode = $input->param('barcode');
204 my @barcodes = split( /\,| |\|/, $barcode );
205 my ($error) = newitems(
207 biblioitemnumber => $bibitemnum,
208 biblionumber => $bibnum,
209 replacementprice => $rrp,
211 booksellerid => $booksellerid,
212 homebranch => $branch,
218 $bibnum, $ordnum, $quantity, $user, $cost,
219 $invoice, 0, $bookfund, $rrp
224 $bibnum = $input->param('biblio');
225 DelOrder( $bibnum, $ordnum );
227 print $input->redirect("basket.pl?basket=$basketno");