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.
68 use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
72 use C4::Dates qw/format_date/;
73 use C4::Bookseller qw/ GetBookSellerFromId /;
74 use C4::Budgets qw/ GetBudget /;
76 use C4::Branch; # GetBranches
84 my $dbh = C4::Context->dbh;
85 my $booksellerid = $input->param('booksellerid');
86 my $ordernumber = $input->param('ordernumber');
87 my $search = $input->param('receive');
88 my $invoice = $input->param('invoice');
89 my $freight = $input->param('freight');
90 my $datereceived = $input->param('datereceived');
93 $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
95 my $bookseller = GetBookSellerFromId($booksellerid);
96 my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
97 my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
98 my $results = SearchOrder($ordernumber,$search);
100 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
102 template_name => "acqui/orderreceive.tmpl",
105 authnotrequired => 0,
106 flagsrequired => {acquisition => 'order_receive'},
111 my $count = scalar @$results;
112 # prepare the form for receiving
114 my $order = $results->[0];
115 if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
116 # Check if ACQ framework exists
117 my $marc = GetMarcStructure(1, 'ACQ');
119 $template->param('NoACQframework' => 1);
122 AcqCreateItemReceiving => 1,
123 UniqueItemFields => C4::Context->preference('UniqueItemFields'),
127 if ( $order->{'unitprice'} == 0 ) {
128 $order->{'unitprice'} = '';
131 my $suggestion = GetSuggestionInfoFromBiblionumber($order->{'biblionumber'});
133 my $authorisedby = $order->{'authorisedby'};
134 my $member = GetMember( borrowernumber => $authorisedby );
136 my $budget = GetBudget( $order->{'budget_id'} );
140 biblionumber => $order->{'biblionumber'},
141 ordernumber => $order->{'ordernumber'},
142 biblioitemnumber => $order->{'biblioitemnumber'},
143 booksellerid => $order->{'booksellerid'},
146 name => $bookseller->{'name'},
147 date => format_date($order->{entrydate}),
148 title => $order->{'title'},
149 author => $order->{'author'},
150 copyrightdate => $order->{'copyrightdate'},
151 isbn => $order->{'isbn'},
152 seriestitle => $order->{'seriestitle'},
153 bookfund => $budget->{budget_name},
154 quantity => $order->{'quantity'},
155 quantityreceivedplus1 => $order->{'quantityreceived'} + 1,
156 quantityreceived => $order->{'quantityreceived'},
157 rrp => $order->{'rrp'},
158 ecost => $order->{'ecost'},
159 unitprice => $order->{'unitprice'},
160 memberfirstname => $member->{firstname} || "",
161 membersurname => $member->{surname} || "",
163 datereceived => $datereceived->output(),
164 datereceived_iso => $datereceived->output('iso'),
165 notes => $order->{notes},
166 suggestionid => $suggestion->{suggestionid},
167 surnamesuggestedby => $suggestion->{surnamesuggestedby},
168 firstnamesuggestedby => $suggestion->{firstnamesuggestedby},
173 for ( my $i = 0 ; $i < $count ; $i++ ) {
174 my %line = %{ @$results[$i] };
176 $line{invoice} = $invoice;
177 $line{datereceived} = $datereceived->output();
178 $line{freight} = $freight;
180 $line{title} = @$results[$i]->{'title'};
181 $line{author} = @$results[$i]->{'author'};
182 $line{booksellerid} = $booksellerid;
188 booksellerid => $booksellerid,
191 my $op = $input->param('op');
192 if ($op and $op eq 'edit'){
193 $template->param(edit => 1);
195 output_html_with_http_headers $input, $cookie, $template->output;