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
66 use C4::Dates qw/format_date/;
69 use C4::Branch; # GetBranches
72 my $supplierid = $input->param('supplierid');
73 my $dbh = C4::Context->dbh;
75 my $search = $input->param('receive');
76 my $invoice = $input->param('invoice');
77 my $freight = $input->param('freight');
78 my $biblionumber = $input->param('biblionumber');
79 my $datereceived = C4::Dates->new($input->param('datereceived'),'iso') || C4::Dates->new();
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 (@itemtypesloop,@locationloop,@ccodeloop);
105 my $itemtypes = GetItemTypes;
106 foreach my $thisitemtype (sort keys %$itemtypes) {
108 value => $thisitemtype,
109 description => $itemtypes->{$thisitemtype}->{'description'},
110 selected => ($thisitemtype eq $results[0]->{itemtype}), # ifdef itemtype @ bibliolevel, use it as default for item level.
112 push @itemtypesloop, \%row;
115 my $locs = GetKohaAuthorisedValues( 'items.location' );
116 foreach my $thisloc (sort keys %$locs) {
120 description => $locs->{$thisloc},
122 push @locationloop, $row;
124 my $ccodes= GetKohaAuthorisedValues( 'items.ccode' );
125 foreach my $thisccode (sort keys %$ccodes) {
128 description => $ccodes->{$thisccode},
131 $template->param(itemtypeloop => \@itemtypesloop ,
132 locationloop => \@locationloop,
133 ccodeloop => \@ccodeloop,
134 itype => C4::Context->preference('item-level_itypes'),
137 my $onlymine=C4::Context->preference('IndependantBranches') &&
138 C4::Context->userenv &&
139 C4::Context->userenv->{flags} !=1 &&
140 C4::Context->userenv->{branch};
141 my $branches = GetBranches($onlymine);
143 foreach my $thisbranch ( sort keys %$branches ) {
145 value => $thisbranch,
146 description => $branches->{$thisbranch}->{'branchname'},
148 push @branchloop, \%row;
151 my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
153 # See whether barcodes should be automatically allocated.
154 # Defaults to 0, meaning "no".
156 if ( $auto_barcode ) {
157 my $sth = $dbh->prepare("Select max(barcode) from items");
159 my $data = $sth->fetchrow_hashref;
160 $barcode = $results[0]->{'barcode'} + 1;
164 if ( $results[0]->{'quantityreceived'} == 0 ) {
165 $results[0]->{'quantityreceived'} = '';
167 if ( $results[0]->{'unitprice'} == 0 ) {
168 $results[0]->{'unitprice'} = '';
170 $results[0]->{'copyrightdate'} =
171 format_date( $results[0]->{'copyrightdate'} );
173 branchloop => \@branchloop,
175 biblionumber => $results[0]->{'biblionumber'},
176 ordernumber => $results[0]->{'ordernumber'},
177 biblioitemnumber => $results[0]->{'biblioitemnumber'},
178 supplierid => $results[0]->{'booksellerid'},
181 catview => ( $catview ne 'yes' ? 1 : 0 ),
182 name => $booksellers[0]->{'name'},
183 date => format_date($date),
184 title => $results[0]->{'title'},
185 author => $results[0]->{'author'},
186 copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
187 itemtype => $results[0]->{'itemtype'},
188 isbn => $results[0]->{'isbn'},
189 seriestitle => $results[0]->{'seriestitle'},
191 bookfund => $results[0]->{'bookfundid'},
192 quantity => $results[0]->{'quantity'},
193 quantityreceivedplus1 => $results[0]->{'quantityreceived'} + 1,
194 quantityreceived => $results[0]->{'quantityreceived'},
195 rrp => $results[0]->{'rrp'},
196 ecost => $results[0]->{'ecost'},
197 unitprice => $results[0]->{'unitprice'},
199 datereceived => $datereceived->output(),
204 for ( my $i = 0 ; $i < $count ; $i++ ) {
205 my %line = %{ $results[$i] };
207 $line{invoice} = $invoice;
208 $line{datereceived} = $datereceived->output();
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 datereceived => $datereceived->output(),
220 name => $booksellers[0]->{'name'},
221 supplierid => $supplierid,
226 output_html_with_http_headers $input, $cookie, $template->output;