You are here

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

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

Implementation of hook_cron().

File

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

Code

function merci_cron() {

  //print('merci cron running<br />');

  //find all autocheckouts that have started and set their stauts to checked out

  //only change status for unconfirmed and pending reservations
  $old_timezone = date_default_timezone_get();
  date_default_timezone_set('UTC');
  $time = date('Y-m-j H:m:s');

  //2009-05-22 20:45:00
  date_default_timezone_set($old_timezone);

  //print('localized time: ' . $time . '<br />');

  //print('set to checked out <br />');

  // Reservation status options.

  //define('MERCI_STATUS_UNCONFIRMED', 1);

  //define('MERCI_STATUS_PENDING', 2);

  //define('MERCI_STATUS_CHECKED_OUT', 3);

  //define('MERCI_STATUS_CHECKED_IN', 4);

  //define('MERCI_STATUS_CANCELLED', 5);

  //define('MERCI_STATUS_DENIED', 6);

  //define('MERCI_STATUS_NO_SHOW', 7);
  $reservations = db_query("SELECT ctmr.nid FROM {content_type_merci_reservation} ctmr JOIN {merci_reservation_detail} mrd ON ctmr.nid = mrd.nid JOIN {merci_reservation} mr ON ctmr.nid = mr.nid WHERE mr.status < 3 AND field_merci_date_value < '%s'", $time);
  while ($reservation = db_fetch_object($reservations)) {

    //print($reservation->nid . '<br />');
  }

  //find all autocheckins that have ended and set their stauts to checkedin

  //only change status for checked reservations

  //print('set to checked in <br />');
  $reservations = db_query("SELECT * FROM {content_type_merci_reservation} WHERE field_merci_date_value2 > '%s'", $time);
  while ($reservation = db_fetch_object($reservations)) {

    //print($reservation->nid . '<br />');
  }

  //find all unconfirmed and pending reservations that have started and set their stauts to no show
}