|
Lines 88-94
BEGIN {
Link Here
|
| 88 |
&GetSoonestRenewDate |
88 |
&GetSoonestRenewDate |
| 89 |
&GetLatestAutoRenewDate |
89 |
&GetLatestAutoRenewDate |
| 90 |
&GetItemIssue |
90 |
&GetItemIssue |
| 91 |
&GetItemIssues |
|
|
| 92 |
&GetIssuingCharges |
91 |
&GetIssuingCharges |
| 93 |
&GetBranchBorrowerCircRule |
92 |
&GetBranchBorrowerCircRule |
| 94 |
&GetBranchItemRule |
93 |
&GetBranchItemRule |
|
Lines 2573-2625
sub GetIssues {
Link Here
|
| 2573 |
return $rv ? $sth->fetchall_arrayref({}) : undef; |
2572 |
return $rv ? $sth->fetchall_arrayref({}) : undef; |
| 2574 |
} |
2573 |
} |
| 2575 |
|
2574 |
|
| 2576 |
=head2 GetItemIssues |
|
|
| 2577 |
|
| 2578 |
$issues = &GetItemIssues($itemnumber, $history); |
| 2579 |
|
| 2580 |
Returns patrons that have issued a book |
| 2581 |
|
| 2582 |
C<$itemnumber> is the itemnumber |
| 2583 |
C<$history> is false if you just want the current "issuer" (if any) |
| 2584 |
and true if you want issues history from old_issues also. |
| 2585 |
|
| 2586 |
Returns reference to an array of hashes |
| 2587 |
|
| 2588 |
=cut |
| 2589 |
|
| 2590 |
sub GetItemIssues { |
| 2591 |
my ( $itemnumber, $history ) = @_; |
| 2592 |
|
| 2593 |
my $today = DateTime->now( time_zome => C4::Context->tz); # get today date |
| 2594 |
$today->truncate( to => 'minute' ); |
| 2595 |
my $sql = "SELECT * FROM issues |
| 2596 |
JOIN borrowers USING (borrowernumber) |
| 2597 |
JOIN items USING (itemnumber) |
| 2598 |
WHERE issues.itemnumber = ? "; |
| 2599 |
if ($history) { |
| 2600 |
$sql .= "UNION ALL |
| 2601 |
SELECT * FROM old_issues |
| 2602 |
LEFT JOIN borrowers USING (borrowernumber) |
| 2603 |
JOIN items USING (itemnumber) |
| 2604 |
WHERE old_issues.itemnumber = ? "; |
| 2605 |
} |
| 2606 |
$sql .= "ORDER BY date_due DESC"; |
| 2607 |
my $sth = C4::Context->dbh->prepare($sql); |
| 2608 |
if ($history) { |
| 2609 |
$sth->execute($itemnumber, $itemnumber); |
| 2610 |
} else { |
| 2611 |
$sth->execute($itemnumber); |
| 2612 |
} |
| 2613 |
my $results = $sth->fetchall_arrayref({}); |
| 2614 |
foreach (@$results) { |
| 2615 |
my $date_due = dt_from_string($_->{date_due},'sql'); |
| 2616 |
$date_due->truncate( to => 'minute' ); |
| 2617 |
|
| 2618 |
$_->{overdue} = (DateTime->compare($date_due, $today) == -1) ? 1 : 0; |
| 2619 |
} |
| 2620 |
return $results; |
| 2621 |
} |
| 2622 |
|
| 2623 |
=head2 GetBiblioIssues |
2575 |
=head2 GetBiblioIssues |
| 2624 |
|
2576 |
|
| 2625 |
$issues = GetBiblioIssues($biblionumber); |
2577 |
$issues = GetBiblioIssues($biblionumber); |