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
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 This script shows all order already receive and all pendings orders.
31 It permit to write a new order as 'received'.
39 to know on what supplier this script has to display receive order.
45 the number of this invoice.
51 The biblionumber of this order.
64 #use warnings; FIXME - Bug 2505
67 use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
71 use C4::Dates qw/format_date/;
74 use C4::Branch; # GetBranches
81 my $dbh = C4::Context->dbh;
82 my $supplierid = $input->param('supplierid');
83 my $ordernumber = $input->param('ordernumber');
84 my $search = $input->param('receive');
85 my $invoice = $input->param('invoice');
86 my $freight = $input->param('freight');
87 my $datereceived = $input->param('datereceived');
90 $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
92 my $bookseller = GetBookSellerFromId($supplierid);
93 my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
94 my $results = SearchOrder($ordernumber,$search);
97 my $count = scalar @$results;
98 my $order = GetOrder($ordernumber);
101 my $date = @$results[0]->{'entrydate'};
103 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
105 template_name => "acqui/orderreceive.tmpl",
108 authnotrequired => 0,
109 flagsrequired => {acquisition => 'order_receive'},
114 # prepare the form for receiving
116 if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
117 # prepare empty item form
118 my $cell = PrepareItemrecordDisplay('','','','ACQ');
120 $cell = PrepareItemrecordDisplay('','','','');
121 $template->param('NoACQframework' => 1);
124 push @itemloop,$cell;
126 $template->param(items => \@itemloop);
129 if ( @$results[0]->{'quantityreceived'} == 0 ) {
130 @$results[0]->{'quantityreceived'} = '';
132 if ( @$results[0]->{'unitprice'} == 0 ) {
133 @$results[0]->{'unitprice'} = '';
137 biblionumber => @$results[0]->{'biblionumber'},
138 ordernumber => @$results[0]->{'ordernumber'},
139 biblioitemnumber => @$results[0]->{'biblioitemnumber'},
140 supplierid => @$results[0]->{'booksellerid'},
143 name => $bookseller->{'name'},
144 date => format_date($date),
145 title => @$results[0]->{'title'},
146 author => @$results[0]->{'author'},
147 copyrightdate => @$results[0]->{'copyrightdate'},
148 isbn => @$results[0]->{'isbn'},
149 seriestitle => @$results[0]->{'seriestitle'},
150 bookfund => @$results[0]->{'bookfundid'},
151 quantity => @$results[0]->{'quantity'},
152 quantityreceivedplus1 => @$results[0]->{'quantityreceived'} + 1,
153 quantityreceived => @$results[0]->{'quantityreceived'},
154 rrp => @$results[0]->{'rrp'},
155 ecost => @$results[0]->{'ecost'},
156 unitprice => @$results[0]->{'unitprice'},
158 datereceived => $datereceived->output(),
159 datereceived_iso => $datereceived->output('iso'),
160 notes => $order->{notes}
165 for ( my $i = 0 ; $i < $count ; $i++ ) {
166 my %line = %{ @$results[$i] };
168 $line{invoice} = $invoice;
169 $line{datereceived} = $datereceived->output();
170 $line{freight} = $freight;
172 $line{title} = @$results[$i]->{'title'};
173 $line{author} = @$results[$i]->{'author'};
174 $line{supplierid} = $supplierid;
180 supplierid => $supplierid,
183 my $op = $input->param('op');
185 $template->param(edit => 1);
187 output_html_with_http_headers $input, $cookie, $template->output;