|
Lines 130-136
sub new {
Link Here
|
| 130 |
|
130 |
|
| 131 |
# FIXME: populate fine_items recall_items |
131 |
# FIXME: populate fine_items recall_items |
| 132 |
$ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber}); |
132 |
$ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber}); |
| 133 |
$ilspatron{items} = $patron->pending_checkouts->unblessed; |
133 |
$ilspatron{items} = _get_pending_issues($kp->{borrowernumber}); |
| 134 |
$self = \%ilspatron; |
134 |
$self = \%ilspatron; |
| 135 |
$debug and warn Dumper($self); |
135 |
$debug and warn Dumper($self); |
| 136 |
syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id}); |
136 |
syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id}); |
|
Lines 501-506
sub _get_outstanding_holds {
Link Here
|
| 501 |
return \@holds; |
501 |
return \@holds; |
| 502 |
} |
502 |
} |
| 503 |
|
503 |
|
|
|
504 |
sub _get_pending_issues { |
| 505 |
my @borrowernumbers = @_; |
| 506 |
unless (@borrowernumbers ) { # return a ref_to_array |
| 507 |
return \@borrowernumbers; # to not cause surprise to caller |
| 508 |
} |
| 509 |
# Borrowers part of the query |
| 510 |
my $bquery = ''; |
| 511 |
for (my $i = 0; $i < @borrowernumbers; $i++) { |
| 512 |
$bquery .= ' issues.borrowernumber = ?'; |
| 513 |
if ($i < $#borrowernumbers ) { |
| 514 |
$bquery .= ' OR'; |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
# must avoid biblioitems.* to prevent large marc and marcxml fields from killing performance |
| 519 |
# FIXME: namespace collision: each table has "timestamp" fields. Which one is "timestamp" ? |
| 520 |
# FIXME: circ/ciculation.pl tries to sort by timestamp! |
| 521 |
# FIXME: namespace collision: other collisions possible. |
| 522 |
# FIXME: most of this data isn't really being used by callers. |
| 523 |
my $query = |
| 524 |
"SELECT issues.*, |
| 525 |
items.*, |
| 526 |
biblio.*, |
| 527 |
biblioitems.volume, |
| 528 |
biblioitems.number, |
| 529 |
biblioitems.itemtype, |
| 530 |
biblioitems.isbn, |
| 531 |
biblioitems.issn, |
| 532 |
biblioitems.publicationyear, |
| 533 |
biblioitems.publishercode, |
| 534 |
biblioitems.volumedate, |
| 535 |
biblioitems.volumedesc, |
| 536 |
biblioitems.lccn, |
| 537 |
biblioitems.url, |
| 538 |
borrowers.firstname, |
| 539 |
borrowers.surname, |
| 540 |
borrowers.cardnumber, |
| 541 |
issues.timestamp AS timestamp, |
| 542 |
issues.renewals AS renewals, |
| 543 |
issues.borrowernumber AS borrowernumber, |
| 544 |
items.renewals AS totalrenewals |
| 545 |
FROM issues |
| 546 |
LEFT JOIN items ON items.itemnumber = issues.itemnumber |
| 547 |
LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber |
| 548 |
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber |
| 549 |
LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber |
| 550 |
WHERE |
| 551 |
$bquery |
| 552 |
ORDER BY issues.issuedate" |
| 553 |
; |
| 554 |
|
| 555 |
my $sth = C4::Context->dbh->prepare($query); |
| 556 |
$sth->execute(@borrowernumbers); |
| 557 |
my $data = $sth->fetchall_arrayref({}); |
| 558 |
my $today = dt_from_string; |
| 559 |
foreach (@{$data}) { |
| 560 |
if ($_->{issuedate}) { |
| 561 |
$_->{issuedate} = dt_from_string($_->{issuedate}, 'sql'); |
| 562 |
} |
| 563 |
$_->{date_due_sql} = $_->{date_due}; |
| 564 |
# FIXME no need to have this value |
| 565 |
$_->{date_due} or next; |
| 566 |
$_->{date_due_sql} = $_->{date_due}; |
| 567 |
# FIXME no need to have this value |
| 568 |
$_->{date_due} = dt_from_string($_->{date_due}, 'sql'); |
| 569 |
if ( DateTime->compare($_->{date_due}, $today) == -1 ) { |
| 570 |
$_->{overdue} = 1; |
| 571 |
} |
| 572 |
} |
| 573 |
return $data; |
| 574 |
} |
| 575 |
|
| 576 |
|
| 504 |
=head2 build_patron_attributes_string |
577 |
=head2 build_patron_attributes_string |
| 505 |
|
578 |
|
| 506 |
This method builds the part of the sip message for extended patron |
579 |
This method builds the part of the sip message for extended patron |
| 507 |
- |
|
|