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/;
72 use C4::Bookseller qw/ GetBookSellerFromId /;
73 use C4::Budgets qw/ GetBudget /;
75 use C4::Branch; # GetBranches
82 my $dbh = C4::Context->dbh;
83 my $supplierid = $input->param('supplierid');
84 my $ordernumber = $input->param('ordernumber');
85 my $search = $input->param('receive');
86 my $invoice = $input->param('invoice');
87 my $freight = $input->param('freight');
88 my $datereceived = $input->param('datereceived');
91 $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93 my $bookseller = GetBookSellerFromId($supplierid);
94 my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
95 my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
96 my $results = SearchOrder($ordernumber,$search);
99 my $count = scalar @$results;
100 my $order = GetOrder($ordernumber);
103 my $date = @$results[0]->{'entrydate'};
105 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
107 template_name => "acqui/orderreceive.tmpl",
110 authnotrequired => 0,
111 flagsrequired => {acquisition => 'order_receive'},
116 # prepare the form for receiving
118 if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
119 # prepare empty item form
120 my $cell = PrepareItemrecordDisplay('','','','ACQ');
122 $cell = PrepareItemrecordDisplay('','','','');
123 $template->param('NoACQframework' => 1);
126 push @itemloop,$cell;
128 $template->param(items => \@itemloop);
131 if ( @$results[0]->{'quantityreceived'} == 0 ) {
132 @$results[0]->{'quantityreceived'} = '';
134 if ( @$results[0]->{'unitprice'} == 0 ) {
135 @$results[0]->{'unitprice'} = '';
138 my $authorisedby = @$results[0]->{'authorisedby'};
139 my $member = GetMember( borrowernumber => $authorisedby );
141 my $budget = GetBudget( @$results[0]->{'budget_id'} );
145 biblionumber => @$results[0]->{'biblionumber'},
146 ordernumber => @$results[0]->{'ordernumber'},
147 biblioitemnumber => @$results[0]->{'biblioitemnumber'},
148 supplierid => @$results[0]->{'booksellerid'},
151 name => $bookseller->{'name'},
152 date => format_date($date),
153 title => @$results[0]->{'title'},
154 author => @$results[0]->{'author'},
155 copyrightdate => @$results[0]->{'copyrightdate'},
156 isbn => @$results[0]->{'isbn'},
157 seriestitle => @$results[0]->{'seriestitle'},
158 bookfund => $budget->{budget_name},
159 quantity => @$results[0]->{'quantity'},
160 quantityreceivedplus1 => @$results[0]->{'quantityreceived'} + 1,
161 quantityreceived => @$results[0]->{'quantityreceived'},
162 rrp => @$results[0]->{'rrp'},
163 ecost => @$results[0]->{'ecost'},
164 unitprice => @$results[0]->{'unitprice'},
165 memberfirstname => $member->{firstname} || "",
166 membersurname => $member->{surname} || "",
168 datereceived => $datereceived->output(),
169 datereceived_iso => $datereceived->output('iso'),
170 notes => $order->{notes}
175 for ( my $i = 0 ; $i < $count ; $i++ ) {
176 my %line = %{ @$results[$i] };
178 $line{invoice} = $invoice;
179 $line{datereceived} = $datereceived->output();
180 $line{freight} = $freight;
182 $line{title} = @$results[$i]->{'title'};
183 $line{author} = @$results[$i]->{'author'};
184 $line{supplierid} = $supplierid;
190 supplierid => $supplierid,
193 my $op = $input->param('op');
195 $template->param(edit => 1);
197 output_html_with_http_headers $input, $cookie, $template->output;