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 This script shows all order already receive and all pendings orders.
31 It permit to write a new order as 'received'.
38 to know on what supplier this script has to display receive order.
43 the number of this invoice.
48 The biblionumber of this order.
64 use C4::Interface::CGI::Output;
70 my $supplierid = $input->param('supplierid');
71 my $dbh = C4::Context->dbh;
73 my $search = $input->param('recieve');
74 my $invoice = $input->param('invoice');
75 my $freight = $input->param('freight');
76 my $biblio = $input->param('biblio');
77 my $catview = $input->param('catview');
78 my $gst = $input->param('gst');
79 my @results = SearchOrder( $search, $supplierid, $biblio, $catview );
80 my $count = scalar @results;
82 # warn "C:$count for ordersearch($search,$supplierid,$biblio,$catview);";
83 my @booksellers = GetBookSeller( $results[0]->{'booksellerid'} );
85 my $date = $results[0]->{'entrydate'};
87 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
89 template_name => "acqui/orderreceive.tmpl",
93 flagsrequired => { acquisition => 1 },
97 $template->param($count);
98 my ($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser);
103 my $branches = GetBranches;
105 foreach my $thisbranch ( sort keys %$branches ) {
107 value => $thisbranch,
108 branchname => $branches->{$thisbranch}->{'branchname'},
110 push @branchloop, \%row;
113 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
115 # See whether barcodes should be automatically allocated.
116 # Defaults to 0, meaning "no".
118 if ( $auto_barcode eq '1' ) {
119 $sth = $dbh->prepare("Select max(barcode) from items");
121 my $data = $sth->fetchrow_hashref;
122 $barcode = $results[0]->{'barcode'} + 1;
126 if ( $results[0]->{'quantityreceived'} == 0 ) {
127 $results[0]->{'quantityreceived'} = '';
129 if ( $results[0]->{'unitprice'} == 0 ) {
130 $results[0]->{'unitprice'} = '';
133 branchloop => \@branchloop,
135 biblionumber => $results[0]->{'biblionumber'},
136 ordernumber => $results[0]->{'ordernumber'},
137 biblioitemnumber => $results[0]->{'biblioitemnumber'},
138 supplierid => $results[0]->{'booksellerid'},
141 catview => ( $catview ne 'yes' ? 1 : 0 ),
142 name => $booksellers[0]->{'name'},
143 date => format_date($date),
144 title => $results[0]->{'title'},
145 author => $results[0]->{'author'},
146 copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
147 itemtype => $results[0]->{'itemtype'},
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'},
163 for ( my $i = 0 ; $i < $count ; $i++ ) {
165 $line{isbn} = $results[$i]->{'isbn'};
166 $line{basketno} = $results[$i]->{'basketno'};
167 $line{quantity} = $results[$i]->{'quantity'};
168 $line{quantityrecieved} = $results[$i]->{'quantityreceived'};
169 $line{ordernumber} = $results[$i]->{'ordernumber'};
170 $line{biblionumber} = $results[$i]->{'biblionumber'};
171 $line{invoice} = $invoice;
172 $line{freight} = $freight;
174 $line{title} = $results[$i]->{'title'};
175 $line{author} = $results[$i]->{'author'};
176 $line{supplierid} = $supplierid;
181 date => format_date($date),
182 name => $booksellers[0]->{'name'},
183 supplierid => $supplierid,
188 output_html_with_http_headers $input, $cookie, $template->output;