5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
30 use C4::Interface::CGI::Output;
34 my $supplierid = $input->param('supplierid');
35 my $dbh = C4::Context->dbh;
37 my $search = $input->param('recieve');
38 my $invoice = $input->param('invoice');
39 my $freight = $input->param('freight');
40 my $biblio = $input->param('biblio');
41 my $catview = $input->param('catview');
42 my $gst = $input->param('gst');
43 my ( $count, @results ) =
44 ordersearch( $search, $supplierid, $biblio, $catview );
46 # warn "C:$count for ordersearch($search,$supplierid,$biblio,$catview);";
47 my ( $count2, @booksellers ) = bookseller( $results[0]->{'booksellerid'} );
48 my $date = $results[0]->{'entrydate'};
50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
52 template_name => "acqui/acquire.tmpl",
56 flagsrequired => { acquisition => 1 },
60 $template->param($count);
63 "Select flags, branchcode from borrowers where borrowernumber = ?");
64 $sthtemp->execute($loggedinuser);
65 my ( $flags, $homebranch ) = $sthtemp->fetchrow;
70 my $branches = getbranches;
72 foreach my $thisbranch ( sort keys %$branches ) {
75 branchname => $branches->{$thisbranch}->{'branchname'},
77 push @branchloop, \%row;
80 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
82 # See whether barcodes should be automatically allocated.
83 # Defaults to 0, meaning "no".
85 if ( $auto_barcode eq '1' ) {
86 $sth = $dbh->prepare("Select max(barcode) from items");
88 my $data = $sth->fetchrow_hashref;
89 $barcode = $results[0]->{'barcode'} + 1;
93 if ( $results[0]->{'quantityreceived'} == 0 ) {
94 $results[0]->{'quantityreceived'} = '';
96 if ( $results[0]->{'unitprice'} == 0 ) {
97 $results[0]->{'unitprice'} = '';
100 branchloop => \@branchloop,
102 biblionumber => $results[0]->{'biblionumber'},
103 ordernumber => $results[0]->{'ordernumber'},
104 biblioitemnumber => $results[0]->{'biblioitemnumber'},
105 supplierid => $results[0]->{'booksellerid'},
108 catview => ( $catview ne 'yes' ? 1 : 0 ),
109 name => $booksellers[0]->{'name'},
110 date => format_date($date),
111 title => $results[0]->{'title'},
112 author => $results[0]->{'author'},
113 copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
114 itemtype => $results[0]->{'itemtype'},
115 isbn => $results[0]->{'isbn'},
116 seriestitle => $results[0]->{'seriestitle'},
118 bookfund => $results[0]->{'bookfundid'},
119 quantity => $results[0]->{'quantity'},
120 quantityreceived => $results[0]->{'quantityreceived'},
121 rrp => $results[0]->{'rrp'},
122 ecost => $results[0]->{'ecost'},
123 unitprice => $results[0]->{'unitprice'},
125 notes => $results[0]->{'notes'},
130 for ( my $i = 0 ; $i < $count ; $i++ ) {
132 $line{isbn} = $results[$i]->{'isbn'};
133 $line{basketno} = $results[$i]->{'basketno'};
134 $line{quantity} = $results[$i]->{'quantity'};
135 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
136 $line{ordernumber} = $results[$i]->{'ordernumber'};
137 $line{biblionumber} = $results[$i]->{'biblionumber'};
138 $line{invoice} = $invoice;
139 $line{freight} = $freight;
141 $line{title} = $results[$i]->{'title'};
142 $line{author} = $results[$i]->{'author'};
143 $line{supplierid} = $supplierid;
148 date => format_date($date),
149 name => $booksellers[0]->{'name'},
150 supplierid => $supplierid,
155 output_html_with_http_headers $input, $cookie, $template->output;