function library_get_overdue_items in Library 7
Same name and namespace in other branches
- 5.2 library.module \library_get_overdue_items()
- 6.2 library.module \library_get_overdue_items()
- 6 library.module \library_get_overdue_items()
Returns a list of overdue library items.
Return value
array List of items grouped by patron, containing patron data if present.
3 calls to library_get_overdue_items()
- library_cron in ./
library.module - Implements hook_cron().
- library_notify_overdue in ./
library.admin.inc - Send email to patrons with overdue items.
- library_overdue_items in ./
library.pages.inc - Computes all overdue items.
File
- ./
library.module, line 765
Code
function library_get_overdue_items() {
// Select all the nodes that have ever had an item made unavailable.
$items = db_select('library', 'l')
->fields('l', array(
'id',
))
->condition('library_status', LIBRARY_ITEM_UNAVAILABLE, '=')
->execute();
$overdueitems = array();
foreach ($items as $result) {
$item = library_load($result->id);
if (!empty($item->last_patron_uid) && !empty($item->last_due_date) && REQUEST_TIME > $item->last_due_date) {
$patron = user_load($item->last_patron_uid);
if (!isset($overdueitems[$item->last_patron_uid]['patron']['patron_email'])) {
$overdueitems[$item->last_patron_uid]['patron']['patron_email'] = $patron->mail;
$overdueitems[$item->last_patron_uid]['patron']['patron_name'] = $patron->name;
}
$overdueitems[$item->last_patron_uid]['items'][$item->id] = array(
'item_name' => $item->title,
'nid' => $item->nid,
'due_date' => $item->last_due_date,
'in_circulation' => $item->in_circulation,
);
}
}
return $overdueitems;
}