Source for file timeslot.php

Documentation is available at timeslot.php

  1. <?php
  2. /**
  3. * Booking/Vacancy base object -- designed to be inherited by Vacancy and Booking
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Bookings
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. /** date manipulation routines */
  17. require_once 'inc/date.php';
  18.  
  19. /**
  20. * Booking/Vacancy base object -- designed to be inherited by Vacancy and Booking
  21. *
  22. @package    Bumblebee
  23. @subpackage Bookings
  24. */
  25. class TimeSlot {
  26.   /** @var SimpleDate   start of the slot as used for calculating graphical representation   */
  27.   var $start;
  28.   /** @var SimpleDate   end of the slot as used for calculating graphical representation  */
  29.   var $stop;
  30.   /** @var SimpleDate   date the start is on (i.e. $start with time of 00:00:00)   */
  31.   var $_dayStart = NULL;
  32.   /** @var SimpleDate   date the end is on (i.e. $stop with time of 00:00:00)  */
  33.   var $_dayStop = NULL;
  34.   /** @var SimpleTime   unused?  */
  35.   var $duration;
  36.   /** @var string       href to current page */
  37.   var $href = '';
  38.   /** @var string       html/css class to use for display */
  39.   var $baseclass;
  40.   /** @var boolean      time slot is disabled (instrument is unavailable)  */
  41.   var $isDisabled=0;
  42.   /** @var boolean      instrument is vacant  */
  43.   var $isVacant = 0;
  44.   /** @var boolean      timeslot is the start of a booking (bookings can go fro mone day to another)  */
  45.   var $isStart = 0;
  46.   /** @var SimpleDate   start of the slot for when time should be displayed   */
  47.   var $displayStart;
  48.   /** @var SimpleDate   end of the slot for when time should be displayed  */
  49.   var $displayStop;
  50.   /** @var boolean      start time is arbitrary from truncation due to db lookup */
  51.   var $arb_start = false;
  52.   /** @var boolean      stop time is arbitrary from truncation due to db lookup */
  53.   var $arb_stop  = false;
  54.   /** @var TimeSlotRule timeslot definitions */
  55.   var $slotRule;
  56.   /** @var boolean      only show free/busy information for the slot */
  57.   var $freeBusyOnly = false;
  58.  
  59.   /**
  60.   *  Create a new timeslot to be superclassed by Booking or Vacancy object
  61.   *
  62.   * @param mixed  $start    start time and date (SimpleDate or string or ticks)
  63.   * @param mixed  $stop     stop time and date (SimpleDate or string or ticks)
  64.   * @param mixed  $duration duration of the slot (SimpleTime or string or ticks, 0 to autocalc)
  65.   */
  66.   function TimeSlot($start$stop$duration=0{
  67.     $this->start = new SimpleDate($start);
  68.     $this->stop = new SimpleDate($stop);
  69.     if ($duration==0{
  70.       $this->duration = new SimpleTime($this->stop->ticks - $this->start->ticks);
  71.     else {
  72.       $this->duration = new SimpleTime($duration);
  73.     }
  74.   }
  75.  
  76.   /**
  77.   *  Set the start/stop times of the slot
  78.   *
  79.   * @param SimpleDate  $start    start time and date
  80.   * @param SimpleDate  $stop     stop time and date
  81.   * @param SimpleTime  $duration duration of the slot
  82.   */
  83.   function _TimeSlot_SimpleDate($start$stop$duration{
  84.     $this->start = $start;
  85.     $this->stop = $stop;
  86.     $this->duration = $duration;
  87.   }
  88.  
  89.   /**
  90.   * display the timeslot as a short table row
  91.   */
  92.   function displayShort({
  93.     return '<tr><td>'.get_class($this)
  94.             .'</td><td>'.$this->start->dateTimeString()
  95.             .'</td><td>'.$this->stop->dateTimeString()
  96.             .'</td><td>'.(is_object($this->displayStart$this->displayStart->dateTimeString('NULL')
  97.             .'</td><td>'.(is_object($this->displayStop)  $this->displayStop->dateTimeString()  'NULL')
  98.             .'</td><td>'.$this->isStart
  99.             .'</td></tr>'."\n";
  100.   }
  101.  
  102.   function dayStart({
  103.     if ($this->_dayStart !== NULL{
  104.       #echo "start hit ";
  105.       return $this->_dayStart;
  106.     }
  107.       #echo "start miss ";
  108.     $this->_dayStart = clone($this->start);
  109.     $this->_dayStart->dayRound();
  110.     return $this->_dayStart;
  111.   }
  112.  
  113.   function dayStop({
  114.     if ($this->_dayStop !== NULL{
  115.       #echo "stop hit ";
  116.       return $this->_dayStop;
  117.     }
  118.       #echo "stop miss ";
  119.     $this->_dayStop = clone($this->stop);
  120.     $this->_dayStop->dayRound();
  121.     return $this->_dayStop;
  122.   }
  123.  
  124.   /**
  125.   * construct a long description of the time slot for pop-ups
  126.   *
  127.   * @return string description
  128.   */
  129.   function generateLongDescription({
  130.     return "";
  131.   }
  132.  
  133.   /**
  134.   * work out the title (start and stop times) for the vacancy for display
  135.   *
  136.   * @return string title
  137.   */
  138.   function generateBookingTitle({
  139.     return "";
  140.   }
  141.  

Documentation generated on Tue, 06 Mar 2007 10:02:03 +0000 by phpDocumentor 1.3.0