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];
116 # Check if ACQ framework exists
117 my $acq_fw = GetMarcStructure
(1, 'ACQ');
119 $template->param('NoACQframework' => 1);
122 my $AcqCreateItem = C4
::Context
->preference('AcqCreateItem');
123 if ($AcqCreateItem eq 'receiving') {
125 AcqCreateItemReceiving
=> 1,
126 UniqueItemFields
=> C4
::Context
->preference('UniqueItemFields'),
128 } elsif ($AcqCreateItem eq 'ordering') {
129 my $fw = ($acq_fw) ?
'ACQ' : '';
130 my @itemnumbers = GetItemnumbersFromOrder
($order->{ordernumber
});
132 foreach (@itemnumbers) {
133 my $item = GetItem
($_);
134 if($item->{homebranch
}) {
135 $item->{homebranchname
} = GetBranchName
($item->{homebranch
});
137 if($item->{holdingbranch
}) {
138 $item->{holdingbranchname
} = GetBranchName
($item->{holdingbranch
});
140 if(my $code = GetAuthValCode
("items.notforloan", $fw)) {
141 $item->{notforloan
} = GetKohaAuthorisedValueLib
($code, $item->{notforloan
});
143 if(my $code = GetAuthValCode
("items.restricted", $fw)) {
144 $item->{restricted
} = GetKohaAuthorisedValueLib
($code, $item->{restricted
});
146 if(my $code = GetAuthValCode
("items.location", $fw)) {
147 $item->{location
} = GetKohaAuthorisedValueLib
($code, $item->{location
});
149 if(my $code = GetAuthValCode
("items.ccode", $fw)) {
150 $item->{collection
} = GetKohaAuthorisedValueLib
($code, $item->{ccode
});
152 if(my $code = GetAuthValCode
("items.materials", $fw)) {
153 $item->{materials
} = GetKohaAuthorisedValueLib
($code, $item->{materials
});
155 my $itemtype = getitemtypeinfo
($item->{itype
});
156 $item->{itemtype
} = $itemtype->{description
};
159 $template->param(items
=> \
@items);
162 if ( $order->{'unitprice'} == 0 ) {
163 $order->{'unitprice'} = '';
166 my $suggestion = GetSuggestionInfoFromBiblionumber
($order->{'biblionumber'});
168 my $authorisedby = $order->{'authorisedby'};
169 my $member = GetMember
( borrowernumber
=> $authorisedby );
171 my $budget = GetBudget
( $order->{'budget_id'} );
174 AcqCreateItem
=> $AcqCreateItem,
176 biblionumber
=> $order->{'biblionumber'},
177 ordernumber
=> $order->{'ordernumber'},
178 biblioitemnumber
=> $order->{'biblioitemnumber'},
179 booksellerid
=> $order->{'booksellerid'},
182 name
=> $bookseller->{'name'},
183 date
=> format_date
($order->{entrydate
}),
184 title
=> $order->{'title'},
185 author
=> $order->{'author'},
186 copyrightdate
=> $order->{'copyrightdate'},
187 isbn
=> $order->{'isbn'},
188 seriestitle
=> $order->{'seriestitle'},
189 bookfund
=> $budget->{budget_name
},
190 quantity
=> $order->{'quantity'},
191 quantityreceivedplus1
=> $order->{'quantityreceived'} + 1,
192 quantityreceived
=> $order->{'quantityreceived'},
193 rrp
=> $order->{'rrp'},
194 ecost
=> $order->{'ecost'},
195 unitprice
=> $order->{'unitprice'},
196 memberfirstname
=> $member->{firstname
} || "",
197 membersurname
=> $member->{surname
} || "",
199 datereceived
=> $datereceived->output(),
200 datereceived_iso
=> $datereceived->output('iso'),
201 notes
=> $order->{notes
},
202 suggestionid
=> $suggestion->{suggestionid
},
203 surnamesuggestedby
=> $suggestion->{surnamesuggestedby
},
204 firstnamesuggestedby
=> $suggestion->{firstnamesuggestedby
},
209 for ( my $i = 0 ; $i < $count ; $i++ ) {
210 my %line = %{ @
$results[$i] };
212 $line{invoice
} = $invoice;
213 $line{datereceived
} = $datereceived->output();
214 $line{freight
} = $freight;
216 $line{title
} = @
$results[$i]->{'title'};
217 $line{author
} = @
$results[$i]->{'author'};
218 $line{booksellerid
} = $booksellerid;
224 booksellerid
=> $booksellerid,
227 my $op = $input->param('op');
228 if ($op and $op eq 'edit'){
229 $template->param(edit
=> 1);
231 output_html_with_http_headers
$input, $cookie, $template->output;