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
31 use C4::Interface::CGI::Output;
35 my $supplierid=$input->param('supplierid');
36 my $dbh = C4::Context->dbh;
38 my $search=$input->param('recieve');
39 my $invoice=$input->param('invoice');
40 my $freight=$input->param('freight');
41 my $biblio=$input->param('biblio');
42 my $catview=$input->param('catview');
43 my $gst=$input->param('gst');
44 my ($count,@results)=ordersearch($search,$supplierid,$biblio,$catview);
45 # warn "C:$count for ordersearch($search,$supplierid,$biblio,$catview);";
46 my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
47 my $date = $results[0]->{'entrydate'};
49 my ($template, $loggedinuser, $cookie)
50 = get_template_and_user({template_name => "acqui/acquire.tmpl",
54 flagsrequired => {acquisition => 1},
57 $template->param($count);
58 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
59 $sthtemp->execute($loggedinuser);
60 my ($flags, $homebranch)=$sthtemp->fetchrow;
65 my $branches = getbranches;
67 foreach my $thisbranch (sort keys %$branches) {
68 my %row =(value => $thisbranch,
69 branchname => $branches->{$thisbranch}->{'branchname'},
71 push @branchloop, \%row;
74 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
75 # See whether barcodes should be automatically allocated.
76 # Defaults to 0, meaning "no".
78 if ($auto_barcode eq '1') {
79 $sth=$dbh->prepare("Select max(barcode) from items");
81 my $data=$sth->fetchrow_hashref;
82 $barcode = $results[0]->{'barcode'}+1;
86 if ($results[0]->{'quantityreceived'} == 0){
87 $results[0]->{'quantityreceived'}='';
89 if ($results[0]->{'unitprice'} == 0){
90 $results[0]->{'unitprice'}='';
93 branchloop => \@branchloop,
95 biblionumber => $results[0]->{'biblionumber'},
96 ordernumber => $results[0]->{'ordernumber'},
97 biblioitemnumber => $results[0]->{'biblioitemnumber'},
98 supplierid => $results[0]->{'booksellerid'},
101 catview => ($catview ne 'yes'?1:0),
102 name => $booksellers[0]->{'name'},
103 date => format_date($date),
104 title => $results[0]->{'title'},
105 author => $results[0]->{'author'},
106 copyrightdate => format_date($results[0]->{'copyrightdate'}),
107 itemtype => $results[0]->{'itemtype'},
108 isbn => $results[0]->{'isbn'},
109 seriestitle => $results[0]->{'seriestitle'},
111 bookfund => $results[0]->{'bookfundid'},
112 quantity => $results[0]->{'quantity'},
113 quantityreceived => $results[0]->{'quantityreceived'},
114 rrp => $results[0]->{'rrp'},
115 ecost => $results[0]->{'ecost'},
116 unitprice => $results[0]->{'unitprice'},
118 notes => $results[0]->{'notes'},
122 for (my $i=0;$i<$count;$i++){
124 $line{isbn} = $results[$i]->{'isbn'};
125 $line{basketno} = $results[$i]->{'basketno'};
126 $line{quantity} = $results[$i]->{'quantity'};
127 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
128 $line{ordernumber} = $results[$i]->{'ordernumber'};
129 $line{biblionumber} = $results[$i]->{'biblionumber'};
130 $line{invoice} = $invoice;
131 $line{freight} = $freight;
133 $line{title} = $results[$i]->{'title'};
134 $line{author} = $results[$i]->{'author'};
135 $line{supplierid} = $supplierid;
138 $template->param( loop => \@loop,
139 date => format_date($date),
140 name => $booksellers[0]->{'name'},
141 supplierid => $supplierid,
146 output_html_with_http_headers $input, $cookie, $template->output;