You are here

function library_overdue_items in Library 6

Same name and namespace in other branches
  1. 5.2 library.pages.inc \library_overdue_items()
  2. 6.2 library.pages.inc \library_overdue_items()
  3. 7 library.pages.inc \library_overdue_items()
1 string reference to 'library_overdue_items'
library_menu in ./library.module
Implementation of hook_menu().

File

./library.pages.inc, line 384
Functions for generating page displays related to the library module

Code

function library_overdue_items() {
  if (library_duedates_enabled()) {
    $records = library_get_overdue_items();
    if (empty($records)) {
      return "<p>No overdue items at this time.</p>";
    }
    else {
      $header = array(
        t('Title'),
        t('Patron'),
        t('Due Date'),
        t('Actions'),
      );
      $rows = array();
      foreach ($records as $patron_id => $record) {
        $patron_name = $record['patron']['patron_name'];
        $patron_email = $record['patron']['patron_email'];
        foreach ($record['items'] as $id => $values) {
          $item = array(
            'library_status' => LIBRARY_ITEM_UNAVAILABLE,
            'id' => $id,
            'last_patron_id' => $patron_id,
            'in_circulation' => $values['in_circulation'],
          );
          $links = implode(" | ", library_get_action_links($item));
          $rows[] = array(
            $values['item_name'],
            $patron_name,
            format_date($values['due_date'], 'small'),
            l('Item Details', 'node/' . $values['nid']) . ' | ' . $links,
          );
          $item = array();
        }
      }
      $output = theme('table', $header, $rows);
      $output .= theme('pager', NULL, LIBRARY_RESULTS_PER_PAGE, 0);
      return $output;
    }
  }
  else {
    return "<p>Library due dates are not enabled.</p>";
  }
}