|
Lines 89-95
BEGIN {
Link Here
|
| 89 |
&GetSoonestRenewDate |
89 |
&GetSoonestRenewDate |
| 90 |
&GetLatestAutoRenewDate |
90 |
&GetLatestAutoRenewDate |
| 91 |
&GetItemIssue |
91 |
&GetItemIssue |
| 92 |
&GetItemIssues |
|
|
| 93 |
&GetIssuingCharges |
92 |
&GetIssuingCharges |
| 94 |
&GetBranchBorrowerCircRule |
93 |
&GetBranchBorrowerCircRule |
| 95 |
&GetBranchItemRule |
94 |
&GetBranchItemRule |
|
Lines 2513-2565
sub GetOpenIssue {
Link Here
|
| 2513 |
|
2512 |
|
| 2514 |
} |
2513 |
} |
| 2515 |
|
2514 |
|
| 2516 |
=head2 GetItemIssues |
|
|
| 2517 |
|
| 2518 |
$issues = &GetItemIssues($itemnumber, $history); |
| 2519 |
|
| 2520 |
Returns patrons that have issued a book |
| 2521 |
|
| 2522 |
C<$itemnumber> is the itemnumber |
| 2523 |
C<$history> is false if you just want the current "issuer" (if any) |
| 2524 |
and true if you want issues history from old_issues also. |
| 2525 |
|
| 2526 |
Returns reference to an array of hashes |
| 2527 |
|
| 2528 |
=cut |
| 2529 |
|
| 2530 |
sub GetItemIssues { |
| 2531 |
my ( $itemnumber, $history ) = @_; |
| 2532 |
|
| 2533 |
my $today = DateTime->now( time_zome => C4::Context->tz); # get today date |
| 2534 |
$today->truncate( to => 'minute' ); |
| 2535 |
my $sql = "SELECT * FROM issues |
| 2536 |
JOIN borrowers USING (borrowernumber) |
| 2537 |
JOIN items USING (itemnumber) |
| 2538 |
WHERE issues.itemnumber = ? "; |
| 2539 |
if ($history) { |
| 2540 |
$sql .= "UNION ALL |
| 2541 |
SELECT * FROM old_issues |
| 2542 |
LEFT JOIN borrowers USING (borrowernumber) |
| 2543 |
JOIN items USING (itemnumber) |
| 2544 |
WHERE old_issues.itemnumber = ? "; |
| 2545 |
} |
| 2546 |
$sql .= "ORDER BY date_due DESC"; |
| 2547 |
my $sth = C4::Context->dbh->prepare($sql); |
| 2548 |
if ($history) { |
| 2549 |
$sth->execute($itemnumber, $itemnumber); |
| 2550 |
} else { |
| 2551 |
$sth->execute($itemnumber); |
| 2552 |
} |
| 2553 |
my $results = $sth->fetchall_arrayref({}); |
| 2554 |
foreach (@$results) { |
| 2555 |
my $date_due = dt_from_string($_->{date_due},'sql'); |
| 2556 |
$date_due->truncate( to => 'minute' ); |
| 2557 |
|
| 2558 |
$_->{overdue} = (DateTime->compare($date_due, $today) == -1) ? 1 : 0; |
| 2559 |
} |
| 2560 |
return $results; |
| 2561 |
} |
| 2562 |
|
| 2563 |
=head2 GetBiblioIssues |
2515 |
=head2 GetBiblioIssues |
| 2564 |
|
2516 |
|
| 2565 |
$issues = GetBiblioIssues($biblionumber); |
2517 |
$issues = GetBiblioIssues($biblionumber); |