5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
35 use C4::Interface::CGI::Output;
40 my $id=$input->param('id');
41 my $dbh = C4::Context->dbh;
43 my $search=$input->param('recieve');
44 my $invoice=$input->param('invoice');
45 my $freight=$input->param('freight');
46 my $biblio=$input->param('biblio');
47 my $catview=$input->param('catview');
48 my $gst=$input->param('gst');
49 my ($count,@results)=ordersearch($search,$id,$biblio,$catview);
50 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
51 my @date=split('-',$results[0]->{'entrydate'});
52 my $date="$date[2]/$date[1]/$date[0]";
54 my ($template, $loggedinuser, $cookie)
55 = get_template_and_user({template_name => "acqui/acquire.tmpl",
59 flagsrequired => {acquisition => 1},
63 $template->param($count);
65 my $query="Select itemtype,description from itemtypes order by description";
66 my $sth=$dbh->prepare($query);
71 $itemtypes{''} = "Please choose";
72 while (my ($value,$lib) = $sth->fetchrow_array) {
73 push @itemtype, $value;
74 $itemtypes{$value}=$lib;
77 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
78 -values => \@itemtype,
79 -default => $results[0]->{'itemtype'},
80 -labels => \%itemtypes,
88 my ($count2,@branches)=branches();
89 for (my $i=0;$i<$count2;$i++){
90 push @select_branch, $branches[$i]->{'branchcode'};#
91 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
93 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
94 -values => \@select_branch,
95 -default => $results[0]->{'branchcode'},
96 -labels => \%select_branches,
101 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
102 # See whether barcodes should be automatically allocated.
103 # Defaults to 0, meaning "no".
105 if ($auto_barcode eq '1') {
106 $sth=$dbh->prepare("Select max(barcode) from items");
108 my $data=$sth->fetchrow_hashref;
109 $barcode = $results[0]->{'barcode'}+1;
115 my %select_bookfunds;
116 ($count2,@bookfund)=bookfunds();
117 for (my $i=0;$i<$count2;$i++){
118 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
119 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
121 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
122 -values => \@select_bookfund,
123 -default => $results[0]->{'bookfundid'},
124 -labels => \%select_bookfunds,
128 my $rrp=$results[0]->{'rrp'};
129 if ($results[0]->{'quantityreceived'} == 0){
130 $results[0]->{'quantityreceived'}='';
132 if ($results[0]->{'unitprice'} == 0){
133 $results[0]->{'unitprice'}='';
137 biblionumber => $results[0]->{'biblionumber'},
138 ordernumber => $results[0]->{'ordernumber'},
139 biblioitemnumber => $results[0]->{'biblioitemnumber'},
140 booksellerid => $results[0]->{'booksellerid'},
143 catview => ($catview ne 'yes'?1:0),
144 name => $booksellers[0]->{'name'},
146 title => $results[0]->{'title'},
147 author => $results[0]->{'author'},
148 copyrightdate => $results[0]->{'copyrightdate'},
149 CGIitemtype => $CGIitemtype,
150 CGIbranch => $CGIbranch,
151 isbn => $results[0]->{'isbn'},
152 seriestitle => $results[0]->{'seriestitle'},
154 CGIbookfund => $CGIbookfund,
155 quantity => $results[0]->{'quantity'},
156 quantityreceived => $results[0]->{'quantityreceived'},
158 ecost => $results[0]->{'ecost'},
159 unitprice => $results[0]->{'unitprice'},
161 notes => $results[0]->{'notes'},
165 for (my $i=0;$i<$count;$i++){
167 $line{isbn} = $results[$i]->{'isbn'};
168 $line{basketno} = $results[$i]->{'basketno'};
169 $line{quantity} = $results[$i]->{'quantity'};
170 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
171 $line{ordernumber} = $results[$i]->{'ordernumber'};
172 $line{biblionumber} = $results[$i]->{'biblionumber'};
173 $line{invoice} = $invoice;
174 $line{freight} = $freight;
176 $line{title} = $results[$i]->{'title'};
177 $line{author} = $results[$i]->{'author'};
181 $template->param( loop => \@loop,
182 user => $loggedinuser,
184 name => $booksellers[0]->{'name'},
190 output_html_with_http_headers $input, $cookie, $template->output;