You are here

function merci_load in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 merci.module \merci_load()
  2. 7.2 merci.module \merci_load()

Implementation of hook_load().

1 call to merci_load()
merci_token_values in ./merci.module
Implementation of hook_token_values().

File

./merci.module, line 2144
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function merci_load($node) {
  if ($node->type == 'merci_reservation') {
    $return = new stdClass();
    $return->merci = db_fetch_array(db_query("SELECT status FROM {merci_reservation} WHERE vid = %d", $node->vid));
    $reservation_items = array();

    // Pull both the general placeholder node and the item nid so we
    // can use whichever we need.
    $items = db_query("SELECT m.did, m.item_status, pn.nid AS pnid, pn.title AS ptitle, tn.nid AS tnid, tn.title AS ttitle, nt.type, nt.name FROM {merci_reservation_detail} m INNER JOIN {node} pn ON m.placeholder_nid = pn.nid INNER JOIN {node_type} nt ON pn.type = nt.type LEFT JOIN {node} tn ON m.item_nid = tn.nid WHERE m.vid = %d", $node->vid);
    while ($item = db_fetch_object($items)) {
      $reservation_items[$item->did] = $item;
    }
    $return->merci['reservation_items'] = $reservation_items;
    return $return;
  }
}