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},
61 $template->param($count);
62 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
63 $sthtemp->execute($borrowernumber);
64 my ($flags, $homebranch)=$sthtemp->fetchrow;
68 # my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
73 # $itemtypes{''} = "Please choose";
74 # while (my ($value,$lib) = $sth->fetchrow_array) {
75 # push @itemtype, $value;
76 # $itemtypes{$value}=$lib;
79 # my $CGIitemtype=CGI::scrolling_list( -name => 'format',
80 # -values => \@itemtype,
81 # -default => $results[0]->{'itemtype'},
82 # -labels => \%itemtypes,
90 my ($count2,@branches)=branches();
91 for (my $i=0;$i<$count2;$i++){
92 push @select_branch, $branches[$i]->{'branchcode'};#
93 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
95 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
96 -values => \@select_branch,
97 -default => $results[0]->{'branchcode'},
98 -labels => \%select_branches,
102 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
103 # See whether barcodes should be automatically allocated.
104 # Defaults to 0, meaning "no".
106 if ($auto_barcode eq '1') {
107 $sth=$dbh->prepare("Select max(barcode) from items");
109 my $data=$sth->fetchrow_hashref;
110 $barcode = $results[0]->{'barcode'}+1;
115 # my @select_bookfund;
116 # my %select_bookfunds;
117 # ($count2,@bookfund)=bookfunds();
118 # for (my $i=0;$i<$count2;$i++){
119 # push @select_bookfund, $bookfund[$i]->{'bookfundid'};
120 # $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
122 # my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
123 # -values => \@select_bookfund,
124 # -default => $results[0]->{'bookfundid'},
125 # -labels => \%select_bookfunds,
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 supplierid => $results[0]->{'booksellerid'},
143 catview => ($catview ne 'yes'?1:0),
144 name => $booksellers[0]->{'name'},
145 date => format_date($date),
146 title => $results[0]->{'title'},
147 author => $results[0]->{'author'},
148 copyrightdate => format_date($results[0]->{'copyrightdate'}),
149 itemtype => $results[0]->{'itemtype'},
150 CGIbranch => $CGIbranch,
151 isbn => $results[0]->{'isbn'},
152 seriestitle => $results[0]->{'seriestitle'},
154 bookfund => $results[0]->{'bookfundid'},
155 quantity => $results[0]->{'quantity'},
156 quantityreceived => $results[0]->{'quantityreceived'},
157 rrp => $results[0]->{'rrp'},
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'};
178 $line{supplierid} = $supplierid;
181 $template->param( loop => \@loop,
182 date => format_date($date),
183 name => $booksellers[0]->{'name'},
184 supplierid => $supplierid,
189 output_html_with_http_headers $input, $cookie, $template->output;