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