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
33 use C4::Interface::CGI::Output;
39 my $supplierid=$input->param('supplierid');
40 my $dbh = C4::Context->dbh;
42 my $search=$input->param('recieve');
43 my $invoice=$input->param('invoice');
44 my $freight=$input->param('freight');
45 my $biblio=$input->param('biblio');
46 my $catview=$input->param('catview');
47 my $gst=$input->param('gst');
48 my ($count,@results)=ordersearch($search,$supplierid,$biblio,$catview);
49 warn "C:$count for ordersearch($search,$supplierid,$biblio,$catview);";
50 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
51 my $date = $results[0]->{'entrydate'};
53 my ($template, $loggedinuser, $cookie)
54 = get_template_and_user({template_name => "acqui/acquire.tmpl",
58 flagsrequired => {acquisition => 1},
62 $template->param($count);
65 # my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
70 # $itemtypes{''} = "Please choose";
71 # while (my ($value,$lib) = $sth->fetchrow_array) {
72 # push @itemtype, $value;
73 # $itemtypes{$value}=$lib;
76 # my $CGIitemtype=CGI::scrolling_list( -name => 'format',
77 # -values => \@itemtype,
78 # -default => $results[0]->{'itemtype'},
79 # -labels => \%itemtypes,
87 my ($count2,@branches)=branches();
88 for (my $i=0;$i<$count2;$i++){
89 push @select_branch, $branches[$i]->{'branchcode'};#
90 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
92 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
93 -values => \@select_branch,
94 -default => $results[0]->{'branchcode'},
95 -labels => \%select_branches,
99 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
100 # See whether barcodes should be automatically allocated.
101 # Defaults to 0, meaning "no".
103 if ($auto_barcode eq '1') {
104 $sth=$dbh->prepare("Select max(barcode) from items");
106 my $data=$sth->fetchrow_hashref;
107 $barcode = $results[0]->{'barcode'}+1;
112 # my @select_bookfund;
113 # my %select_bookfunds;
114 # ($count2,@bookfund)=bookfunds();
115 # for (my $i=0;$i<$count2;$i++){
116 # push @select_bookfund, $bookfund[$i]->{'bookfundid'};
117 # $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
119 # my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
120 # -values => \@select_bookfund,
121 # -default => $results[0]->{'bookfundid'},
122 # -labels => \%select_bookfunds,
126 if ($results[0]->{'quantityreceived'} == 0){
127 $results[0]->{'quantityreceived'}='';
129 if ($results[0]->{'unitprice'} == 0){
130 $results[0]->{'unitprice'}='';
134 biblionumber => $results[0]->{'biblionumber'},
135 ordernumber => $results[0]->{'ordernumber'},
136 biblioitemnumber => $results[0]->{'biblioitemnumber'},
137 supplierid => $results[0]->{'booksellerid'},
140 catview => ($catview ne 'yes'?1:0),
141 name => $booksellers[0]->{'name'},
142 date => format_date($date),
143 title => $results[0]->{'title'},
144 author => $results[0]->{'author'},
145 copyrightdate => format_date($results[0]->{'copyrightdate'}),
146 itemtype => $results[0]->{'itemtype'},
147 CGIbranch => $CGIbranch,
148 isbn => $results[0]->{'isbn'},
149 seriestitle => $results[0]->{'seriestitle'},
151 bookfund => $results[0]->{'bookfundid'},
152 quantity => $results[0]->{'quantity'},
153 quantityreceived => $results[0]->{'quantityreceived'},
154 rrp => $results[0]->{'rrp'},
155 ecost => $results[0]->{'ecost'},
156 unitprice => $results[0]->{'unitprice'},
158 notes => $results[0]->{'notes'},
162 for (my $i=0;$i<$count;$i++){
164 $line{isbn} = $results[$i]->{'isbn'};
165 $line{basketno} = $results[$i]->{'basketno'};
166 $line{quantity} = $results[$i]->{'quantity'};
167 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
168 $line{ordernumber} = $results[$i]->{'ordernumber'};
169 $line{biblionumber} = $results[$i]->{'biblionumber'};
170 $line{invoice} = $invoice;
171 $line{freight} = $freight;
173 $line{title} = $results[$i]->{'title'};
174 $line{author} = $results[$i]->{'author'};
175 $line{supplierid} = $supplierid;
178 $template->param( loop => \@loop,
179 date => format_date($date),
180 name => $booksellers[0]->{'name'},
181 supplierid => $supplierid,
186 output_html_with_http_headers $input, $cookie, $template->output;