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.
63 use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
70 use C4::Branch; # GetBranches
73 my $supplierid = $input->param('supplierid');
74 my $dbh = C4::Context->dbh;
76 my $search = $input->param('recieve');
77 my $invoice = $input->param('invoice');
78 my $freight = $input->param('freight');
79 my $biblionumber = $input->param('biblionumber');
80 my $daterecieved = $input->param('daterecieved') || format_date(join "-",Date::Calc::Today());
81 my $catview = $input->param('catview');
82 my $gst = $input->param('gst');
84 my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
85 my $count = scalar @results;
87 my @booksellers = GetBookSeller( $results[0]->{'booksellerid'} );
89 my $date = $results[0]->{'entrydate'};
91 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
93 template_name => "acqui/orderreceive.tmpl",
97 flagsrequired => { acquisition => 1 },
101 $template->param($count);
105 my $itemtypes = GetItemTypes;
107 foreach my $thisitemtype (sort keys %$itemtypes) {
109 value => $thisitemtype,
110 description => $itemtypes->{$thisitemtype}->{'description'},
112 push @itemtypesloop, \%row;
115 $template->param(itemtypeloop => \@itemtypesloop);
118 my $locations = GetKohaAuthorisedValues( 'items.location' );
120 my @location_codes = keys %$locations;
121 my $CGIlocation = CGI::scrolling_list(
124 -values => \@location_codes,
125 -default => $results[0]->{'itemtype'},
126 -labels => $locations,
131 $template->param( CGIlocation => $CGIlocation );
133 my $onlymine=C4::Context->preference('IndependantBranches') &&
134 C4::Context->userenv &&
135 C4::Context->userenv->{flags} !=1 &&
136 C4::Context->userenv->{branch};
137 my $branches = GetBranches($onlymine);
139 foreach my $thisbranch ( sort keys %$branches ) {
141 value => $thisbranch,
142 branchname => $branches->{$thisbranch}->{'branchname'},
144 push @branchloop, \%row;
147 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
149 # See whether barcodes should be automatically allocated.
150 # Defaults to 0, meaning "no".
152 if ( $auto_barcode ) {
153 my $sth = $dbh->prepare("Select max(barcode) from items");
155 my $data = $sth->fetchrow_hashref;
156 $barcode = $results[0]->{'barcode'} + 1;
160 if ( $results[0]->{'quantityreceived'} == 0 ) {
161 $results[0]->{'quantityreceived'} = '';
163 if ( $results[0]->{'unitprice'} == 0 ) {
164 $results[0]->{'unitprice'} = '';
166 $results[0]->{'copyrightdate'} =
167 format_date( $results[0]->{'copyrightdate'} );
169 branchloop => \@branchloop,
171 biblionumber => $results[0]->{'biblionumber'},
172 ordernumber => $results[0]->{'ordernumber'},
173 biblioitemnumber => $results[0]->{'biblioitemnumber'},
174 supplierid => $results[0]->{'booksellerid'},
177 catview => ( $catview ne 'yes' ? 1 : 0 ),
178 name => $booksellers[0]->{'name'},
179 date => format_date($date),
180 title => $results[0]->{'title'},
181 author => $results[0]->{'author'},
182 copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
183 itemtype => $results[0]->{'itemtype'},
184 isbn => $results[0]->{'isbn'},
185 seriestitle => $results[0]->{'seriestitle'},
187 bookfund => $results[0]->{'bookfundid'},
188 quantity => $results[0]->{'quantity'},
189 quantityreceivedplus1 => $results[0]->{'quantityreceived'} + 1,
190 quantityreceived => $results[0]->{'quantityreceived'},
191 rrp => $results[0]->{'rrp'},
192 ecost => $results[0]->{'ecost'},
193 unitprice => $results[0]->{'unitprice'},
195 daterecieved => $daterecieved,
196 intranetcolorstylesheet =>
197 C4::Context->preference("intranetcolorstylesheet"),
198 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
199 IntranetNav => C4::Context->preference("IntranetNav"),
204 for ( my $i = 0 ; $i < $count ; $i++ ) {
205 my %line = %{ $results[$i] };
207 $line{invoice} = $invoice;
208 $line{daterecieved} = $daterecieved;
209 $line{freight} = $freight;
211 $line{title} = $results[$i]->{'title'};
212 $line{author} = $results[$i]->{'author'};
213 $line{supplierid} = $supplierid;
218 date => format_date($date),
219 daterecieved => $daterecieved,
220 name => $booksellers[0]->{'name'},
221 supplierid => $supplierid,
223 daterecieved => $daterecieved,
224 intranetcolorstylesheet =>
225 C4::Context->preference("intranetcolorstylesheet"),
226 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
227 IntranetNav => C4::Context->preference("IntranetNav"),
231 output_html_with_http_headers $input, $cookie, $template->output;