You are here

function merci_checked_out_reservations_for_item_nid in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2

Same name and namespace in other branches
  1. 7.2 includes/database.inc \merci_checked_out_reservations_for_item_nid()
1 call to merci_checked_out_reservations_for_item_nid()
merci_validate_status in includes/api.inc

File

includes/database.inc, line 230
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function merci_checked_out_reservations_for_item_nid($nid, $exclude_nid) {

  // Determine CCK table and columns the date data is stored in.
  // Pull any incomplete reservations that use the item in question
  $reservations = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {merci_reservation_detail} md ON n.vid = md.vid WHERE n.nid != %d AND md.merci_item_nid = %d AND (md.merci_item_status = %d)"), $exclude_nid, $nid, MERCI_ITEM_STATUS_CHECKED_OUT);
  $bad_reservations = array();
  while ($reservation = db_fetch_object($reservations)) {
    $bad_reservations[] = l($reservation->title, "node/{$reservation->nid}/edit", array(
      'query' => drupal_get_destination(),
    ));
  }
  return $bad_reservations;
}