|
Lines 23-30
use strict;
Link Here
|
| 23 |
use C4::Context; |
23 |
use C4::Context; |
| 24 |
use C4::Stats; |
24 |
use C4::Stats; |
| 25 |
use C4::Members; |
25 |
use C4::Members; |
| 26 |
use C4::Items; |
26 |
use C4::Circulation qw(ReturnLostItem); |
| 27 |
use C4::Circulation qw(MarkIssueReturned); |
|
|
| 28 |
|
27 |
|
| 29 |
use vars qw($VERSION @ISA @EXPORT); |
28 |
use vars qw($VERSION @ISA @EXPORT); |
| 30 |
|
29 |
|
|
Lines 218-224
sub makepayment {
Link Here
|
| 218 |
|
217 |
|
| 219 |
#check to see what accounttype |
218 |
#check to see what accounttype |
| 220 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
219 |
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) { |
| 221 |
returnlost( $borrowernumber, $data->{'itemnumber'} ); |
220 |
ReturnLostItem( $borrowernumber, $data->{'itemnumber'} ); |
| 222 |
} |
221 |
} |
| 223 |
} |
222 |
} |
| 224 |
|
223 |
|
|
Lines 278-341
EOT
Link Here
|
| 278 |
|
277 |
|
| 279 |
=cut |
278 |
=cut |
| 280 |
|
279 |
|
| 281 |
sub returnlost{ |
|
|
| 282 |
my ( $borrowernumber, $itemnum ) = @_; |
| 283 |
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum ); |
| 284 |
my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber ); |
| 285 |
my @datearr = localtime(time); |
| 286 |
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; |
| 287 |
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}"; |
| 288 |
ModItem({ paidfor => "Paid for by $bor $date" }, undef, $itemnum); |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
sub chargelostitem{ |
280 |
sub chargelostitem{ |
| 293 |
# lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for |
281 |
# lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for |
| 294 |
# FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that |
282 |
# FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that |
| 295 |
# a charge has been added |
283 |
# a charge has been added |
| 296 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
284 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
| 297 |
|
|
|
| 298 |
my $dbh = C4::Context->dbh(); |
285 |
my $dbh = C4::Context->dbh(); |
| 299 |
my ($itemnumber) = @_; |
286 |
my ($borrowernumber, $itemnumber, $amount, $description) = @_; |
| 300 |
my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title |
287 |
|
| 301 |
FROM issues |
288 |
# first make sure the borrower hasn't already been charged for this item |
| 302 |
JOIN items USING (itemnumber) |
289 |
my $sth1=$dbh->prepare("SELECT * from accountlines |
| 303 |
JOIN biblio USING (biblionumber) |
290 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); |
| 304 |
WHERE issues.itemnumber=?"); |
291 |
$sth1->execute($borrowernumber,$itemnumber); |
| 305 |
$sth->execute($itemnumber); |
292 |
my $existing_charge_hashref=$sth1->fetchrow_hashref(); |
| 306 |
my $issues=$sth->fetchrow_hashref(); |
293 |
|
| 307 |
|
294 |
# OK, they haven't |
| 308 |
# if a borrower lost the item, add a replacement cost to the their record |
295 |
unless ($existing_charge_hashref) { |
| 309 |
if ( $issues->{borrowernumber} ){ |
296 |
# This item is on issue ... add replacement cost to the borrower's record and mark it returned |
| 310 |
|
297 |
# Note that we add this to the account even if there's no replacement price, allowing some other |
| 311 |
# first make sure the borrower hasn't already been charged for this item |
298 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
| 312 |
my $sth1=$dbh->prepare("SELECT * from accountlines |
299 |
my $accountno = getnextacctno($borrowernumber); |
| 313 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); |
300 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
| 314 |
$sth1->execute($issues->{'borrowernumber'},$itemnumber); |
301 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) |
| 315 |
my $existing_charge_hashref=$sth1->fetchrow_hashref(); |
302 |
VALUES (?,?,now(),?,?,'L',?,?)"); |
| 316 |
|
303 |
$sth2->execute($borrowernumber,$accountno,$amount, |
| 317 |
# OK, they haven't |
304 |
$description,$amount,$itemnumber); |
| 318 |
unless ($existing_charge_hashref) { |
305 |
$sth2->finish; |
| 319 |
# This item is on issue ... add replacement cost to the borrower's record and mark it returned |
306 |
# FIXME: Log this ? |
| 320 |
# Note that we add this to the account even if there's no replacement price, allowing some other |
|
|
| 321 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
| 322 |
my $accountno = getnextacctno($issues->{'borrowernumber'}); |
| 323 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
| 324 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) |
| 325 |
VALUES (?,?,now(),?,?,'L',?,?)"); |
| 326 |
$sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'}, |
| 327 |
"Lost Item $issues->{'title'} $issues->{'barcode'}", |
| 328 |
$issues->{'replacementprice'},$itemnumber); |
| 329 |
$sth2->finish; |
| 330 |
# FIXME: Log this ? |
| 331 |
} |
| 332 |
#FIXME : Should probably have a way to distinguish this from an item that really was returned. |
| 333 |
#warn " $issues->{'borrowernumber'} / $itemnumber "; |
| 334 |
C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber); |
| 335 |
# Shouldn't MarkIssueReturned do this? |
| 336 |
C4::Items::ModItem({ onloan => undef }, undef, $itemnumber); |
| 337 |
} |
307 |
} |
| 338 |
$sth->finish; |
|
|
| 339 |
} |
308 |
} |
| 340 |
|
309 |
|
| 341 |
=head2 manualinvoice |
310 |
=head2 manualinvoice |