4 #script to recieve orders
5 #written by chris@katipo.co.nz 24/2/2000
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
29 This script shows all order already receive and all pendings orders.
30 It permit to write a new order as 'received'.
37 to know on what supplier this script has to display receive order.
42 the number of this invoice.
47 The biblionumber of this order.
62 use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
69 use C4::Branch; # GetBranches
72 my $supplierid = $input->param('supplierid');
73 my $dbh = C4::Context->dbh;
75 my $search = $input->param('recieve');
76 my $invoice = $input->param('invoice');
77 my $freight = $input->param('freight');
78 my $biblionumber = $input->param('biblionumber');
79 my $daterecieved = $input->param('daterecieved') || format_date(join "-",Date::Calc::Today());
80 my $catview = $input->param('catview');
81 my $gst = $input->param('gst');
83 my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
84 my $count = scalar @results;
86 my @booksellers = GetBookSeller( $results[0]->{'booksellerid'} );
88 my $date = $results[0]->{'entrydate'};
90 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
92 template_name => "acqui/orderreceive.tmpl",
96 flagsrequired => { acquisition => 1 },
100 $template->param($count);
104 my $itemtypes = GetItemTypes;
106 foreach my $thisitemtype (sort keys %$itemtypes) {
108 value => $thisitemtype,
109 description => $itemtypes->{$thisitemtype}->{'description'},
111 push @itemtypesloop, \%row;
114 $template->param(itemtypeloop => \@itemtypesloop);
117 my $locations = GetKohaAuthorisedValues( 'items.location' );
119 my @location_codes = keys %$locations;
120 my $CGIlocation = CGI::scrolling_list(
123 -values => \@location_codes,
124 -default => $results[0]->{'itemtype'},
125 -labels => $locations,
130 $template->param( CGIlocation => $CGIlocation );
132 my $onlymine=C4::Context->preference('IndependantBranches') &&
133 C4::Context->userenv &&
134 C4::Context->userenv->{flags} !=1 &&
135 C4::Context->userenv->{branch};
136 my $branches = GetBranches($onlymine);
138 foreach my $thisbranch ( sort keys %$branches ) {
140 value => $thisbranch,
141 branchname => $branches->{$thisbranch}->{'branchname'},
143 push @branchloop, \%row;
146 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
148 # See whether barcodes should be automatically allocated.
149 # Defaults to 0, meaning "no".
151 if ( $auto_barcode ) {
152 my $sth = $dbh->prepare("Select max(barcode) from items");
154 my $data = $sth->fetchrow_hashref;
155 $barcode = $results[0]->{'barcode'} + 1;
159 if ( $results[0]->{'quantityreceived'} == 0 ) {
160 $results[0]->{'quantityreceived'} = '';
162 if ( $results[0]->{'unitprice'} == 0 ) {
163 $results[0]->{'unitprice'} = '';
165 $results[0]->{'copyrightdate'} =
166 format_date( $results[0]->{'copyrightdate'} );
168 branchloop => \@branchloop,
170 biblionumber => $results[0]->{'biblionumber'},
171 ordernumber => $results[0]->{'ordernumber'},
172 biblioitemnumber => $results[0]->{'biblioitemnumber'},
173 supplierid => $results[0]->{'booksellerid'},
176 catview => ( $catview ne 'yes' ? 1 : 0 ),
177 name => $booksellers[0]->{'name'},
178 date => format_date($date),
179 title => $results[0]->{'title'},
180 author => $results[0]->{'author'},
181 copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
182 itemtype => $results[0]->{'itemtype'},
183 isbn => $results[0]->{'isbn'},
184 seriestitle => $results[0]->{'seriestitle'},
186 bookfund => $results[0]->{'bookfundid'},
187 quantity => $results[0]->{'quantity'},
188 quantityreceivedplus1 => $results[0]->{'quantityreceived'} + 1,
189 quantityreceived => $results[0]->{'quantityreceived'},
190 rrp => $results[0]->{'rrp'},
191 ecost => $results[0]->{'ecost'},
192 unitprice => $results[0]->{'unitprice'},
194 daterecieved => $daterecieved,
199 for ( my $i = 0 ; $i < $count ; $i++ ) {
200 my %line = %{ $results[$i] };
202 $line{invoice} = $invoice;
203 $line{daterecieved} = $daterecieved;
204 $line{freight} = $freight;
206 $line{title} = $results[$i]->{'title'};
207 $line{author} = $results[$i]->{'author'};
208 $line{supplierid} = $supplierid;
213 date => format_date($date),
214 daterecieved => $daterecieved,
215 name => $booksellers[0]->{'name'},
216 supplierid => $supplierid,
218 daterecieved => $daterecieved,
222 output_html_with_http_headers $input, $cookie, $template->output;