Source for file vacancy.php

Documentation is available at vacancy.php

  1. <?php
  2. /**
  3. * Vacancy object
  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. /** parent object */
  19. require_once 'timeslot.php';
  20.  
  21. /**
  22. * Vacancy object
  23. *
  24. * @package    Bumblebee
  25. * @subpackage Bookings
  26. */
  27. class Vacancy extends TimeSlot {
  28.  
  29.   /**
  30.   *  Create a new vacancy slot
  31.   *
  32.   * @param array  $arr   field => value
  33.   */
  34.   function Vacancy($arr='') {
  35.     if (is_array($arr)) {
  36.       $this->TimeSlot($arr['bookwhen'], $arr['stoptime'], $arr['duration']);
  37.       #echo "Vacancy from ".$this->start->dateTimeString()." to ".$this->stop->dateTimeString()."<br />\n";
  38.     }
  39.     $this->isVacant = true;
  40.     $this->baseclass='vacancy';
  41.   }
  42.  
  43.   /**
  44.   * Set the times for the slot
  45.   *
  46.   * @param SimpleDate  $start  start time/date
  47.   * @param SimpleDate  $stop   stop time/date
  48.   */
  49.   function setTimes($start, $stop) {
  50.     $duration = new SimpleTime($stop->subtract($start));
  51.     $this->_TimeSlot_SimpleDate($start, $stop, $duration);
  52.   }
  53.  
  54.   /**
  55.   * display the vacancy as a list of settings
  56.   *
  57.   * @return string html representation of the slot
  58.   */
  59.   function display() {
  60.     return $this->displayInTable();
  61.   }
  62.  
  63.   /**
  64.   * display the vacancy as a list of settings
  65.   *
  66.   * @return string html representation of the slot
  67.   */
  68.   function displayInTable() {
  69.     return '<tr><td>Vacant'
  70.             .'</td><td>'.$this->start->getShortDateTimeString()
  71.             .'</td><td>'.$this->stop->getShortDateTimeString()
  72.             .'</td><td>'
  73.             .'</td></tr>'."\n";
  74.   }
  75.  
  76.   /**
  77.   * display the vacancy in a table calendar cell
  78.   *
  79.   * @return string html representation of the slot
  80.   */
  81.   function displayInCell($isadmin=0) {
  82.     $conf = ConfigReader::getInstance();
  83.     $t = '';
  84.     #echo $this->isDisabled ? 'disabled ' : 'active ';
  85.     if ($isadmin || ! $this->isDisabled) {
  86.       $start = isset($this->displayStart) ? $this->displayStart : $this->start;
  87.       $stop  = isset($this->displayStop)  ? $this->displayStop  : $this->stop;
  88.       $startticks = $start->ticks;
  89.       $stopticks = $stop->ticks;
  90.  
  91.       static $timeDescStr = null;
  92.       if ($timeDescStr === null) $timeDescStr = T_('Make booking from %s to %s');
  93.  
  94.       $timedescription = sprintf($timeDescStr, $start->getShortDateTimeString(), $stop->getShortDateTimeString());
  95.       //$timedescription = $this->start->timeString().' - '.$this->stop->timeString();
  96.       $isodate = $start->dateString();
  97.       $t .= '<div style="float:right;">'
  98.               .'<a href="'
  99.                   .$this->href.'&amp;isodate='.$isodate.'&amp;startticks='.$startticks.'&amp;stopticks='.$stopticks.'" '
  100.                   .'class="but" title="'.$timedescription.'">'
  101.                       .'<img src="'.$conf->BasePath.'/theme/images/book.png" '
  102.                           .'alt="'.$timedescription.'" '
  103.                           .'class="calicon" />'
  104.               .'</a>'
  105.             .'</div>';
  106.     }
  107.     //echo 'Comment: '.$this->slotRule->comment.'<br/>';
  108.     if ($this->slotRule->comment) {
  109.       $t .= '<div class="calcomment" title="'.xssqw($this->slotRule->comment).'">'
  110.                 //.xssqw(sprintf('%20.20s',$this->slotRule->comment))
  111.                 .xssqw($this->slotRule->comment)
  112.           .'</div>';
  113.     } else {
  114.       $t .= '&nbsp;';   // make sure there is some non-floating content in the table.
  115.     }
  116.     return $t;
  117.   }
  118.  
  119.   /**
  120.   * work out the title (start and stop times) for the vacancy for display
  121.   *
  122.   * @return string title
  123.   */
  124.   function generateBookingTitle() {
  125.     $start = isset($this->displayStart) ? $this->displayStart : $this->original->start;
  126.     $stop  = isset($this->displayStop)  ? $this->displayStop  : $this->original->stop;
  127.     if ($this->isDisabled) {
  128.       static $unavailableStr =  null;
  129.       if ($unavailableStr === null) $unavailableStr = T_('Unavailable from %s to %s');
  130.       $t = sprintf($unavailableStr, $start->getShortDateTimeString(), $stop->getShortDateTimeString());
  131.     } else {
  132.       static $vacantStr =  null;
  133.       if ($vacantStr === null) $vacantStr = T_('Vacant from %s to %s');
  134.       $t = sprintf($vacantStr, $start->getShortDateTimeString(), $stop->getShortDateTimeString());
  135.     }
  136.     return $t;
  137.   }
  138.  

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