You are here

function library_get_transactions_by_item in Library 6

Same name and namespace in other branches
  1. 5.2 library.module \library_get_transactions_by_item()
  2. 6.2 library.module \library_get_transactions_by_item()
  3. 7 library.module \library_get_transactions_by_item()
2 calls to library_get_transactions_by_item()
library_get_last_transaction_by_item in ./library.module
library_get_transactions_by_node in ./library.module

File

./library.module, line 1000

Code

function library_get_transactions_by_item($item) {
  $result = db_query('SELECT lt.created, lt.tid, la.aid, la.name as "action_name",
                      la.status_change, lt.patron_id, lt.item_id, lt.duedate, lt.notes, l.in_circulation, l.barcode, n.title as "item_name", n.nid
                      FROM {library_transactions} lt, {library_actions} la, {library} l, {node} n
                      WHERE la.aid = lt.action_aid AND n.nid = l.nid AND lt.item_id = l.id AND l.id = %d
                      ORDER BY lt.created DESC', $item->id);
  while ($transaction = db_fetch_object($result)) {
    $transaction->library_status = isset($item->library_status) ? $item->library_status : LIBRARY_ITEM_AVAILABLE;
    $transactions[] = $transaction;
  }
  if (!empty($transactions)) {
    return $transactions;
  }
  else {
    return NULL;
  }
}