|
Lines 101-106
BEGIN {
Link Here
|
| 101 |
&GetMessagesCount |
101 |
&GetMessagesCount |
| 102 |
|
102 |
|
| 103 |
&IssueSlip |
103 |
&IssueSlip |
|
|
104 |
&FineSlip |
| 104 |
GetBorrowersWithEmail |
105 |
GetBorrowersWithEmail |
| 105 |
|
106 |
|
| 106 |
HasOverdues |
107 |
HasOverdues |
|
Lines 2405-2410
sub IssueSlip {
Link Here
|
| 2405 |
); |
2406 |
); |
| 2406 |
} |
2407 |
} |
| 2407 |
|
2408 |
|
|
|
2409 |
|
| 2410 |
sub GetBorrowerFines { |
| 2411 |
my ($borrowernumber) = @_; |
| 2412 |
my $dbh = C4::Context->dbh; |
| 2413 |
my $query = qq{ |
| 2414 |
SELECT * FROM accountlines |
| 2415 |
LEFT JOIN borrowers ON borrowers.borrowernumber = accountlines.borrowernumber |
| 2416 |
LEFT JOIN items ON accountlines.itemnumber = items.itemnumber |
| 2417 |
WHERE accountlines.borrowernumber = ? |
| 2418 |
ORDER BY accountlines.timestamp |
| 2419 |
}; |
| 2420 |
my $sth = $dbh->prepare( $query ); |
| 2421 |
$sth->execute( $borrowernumber ); |
| 2422 |
my $data = $sth->fetchall_arrayref({}); |
| 2423 |
return $data; |
| 2424 |
} |
| 2425 |
|
| 2426 |
sub FineSlip { |
| 2427 |
my ($borrowernumber, $branch) = @_; |
| 2428 |
|
| 2429 |
#my $now = POSIX::strftime("%Y-%m-%d", localtime); |
| 2430 |
|
| 2431 |
my $issueslist = GetBorrowerFines($borrowernumber); |
| 2432 |
|
| 2433 |
my $total = 0.0; |
| 2434 |
|
| 2435 |
foreach my $it (@$issueslist){ |
| 2436 |
my $dt = dt_from_string( $it->{'date'} ); |
| 2437 |
$it->{'date_due'} = output_pref({ dt => $dt, dateonly => 1 }); |
| 2438 |
$it->{'amount'} = sprintf('%.2f', $it->{'amount'}); |
| 2439 |
$total = $total + $it->{'amount'}; |
| 2440 |
$it->{'barcode'} = '-' if (!defined($it->{'barcode'})); |
| 2441 |
} |
| 2442 |
my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist; |
| 2443 |
|
| 2444 |
my %repeat = ( |
| 2445 |
'fines' => [ map { |
| 2446 |
'fines' => $_, |
| 2447 |
'borrowers' => $_, |
| 2448 |
'items' => $_ |
| 2449 |
}, @issues ], |
| 2450 |
); |
| 2451 |
|
| 2452 |
return C4::Letters::GetPreparedLetter ( |
| 2453 |
module => 'circulation', |
| 2454 |
letter_code => 'FINESLIP', |
| 2455 |
branchcode => $branch, |
| 2456 |
tables => { |
| 2457 |
'branches' => $branch, |
| 2458 |
'borrowers' => $borrowernumber, |
| 2459 |
}, |
| 2460 |
substitute => { |
| 2461 |
'total.amount' => sprintf('%.2f', $total), |
| 2462 |
'total.fines' => scalar(@issues) |
| 2463 |
}, |
| 2464 |
repeat => \%repeat, |
| 2465 |
message_transport_type => 'print', |
| 2466 |
); |
| 2467 |
} |
| 2468 |
|
| 2469 |
|
| 2408 |
=head2 GetBorrowersWithEmail |
2470 |
=head2 GetBorrowersWithEmail |
| 2409 |
|
2471 |
|
| 2410 |
([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com'); |
2472 |
([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com'); |