Source for file booking.php

Documentation is available at booking.php

  1. <?php
  2. /**
  3. * Object for an individual 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. require_once 'inc/bb/configreader.php';
  17.  
  18. /** date manipulation routines */
  19. require_once 'inc/date.php';
  20. /** parent object */
  21. require_once 'timeslot.php';
  22.  
  23. /**
  24. * Object for an individual booking
  25. *
  26. @package    Bumblebee
  27. @subpackage Bookings
  28. */
  29. class Booking extends TimeSlot {
  30.   /** @var integer    booking id number  */
  31.   var $id;
  32.   /** @var integer    percentage discount to be applied to the booking  */
  33.   var $discount;
  34.   /** @var string     log message for the instrument log book  */
  35.   var $log;
  36.   /** @var string     log message for the booking calendar  */
  37.   var $comments;
  38.   /** @var integer    project id number  */
  39.   var $project;
  40.   /** @var integer    user id number for user that will use instrument */
  41.   var $userid;
  42.   /** @var string     username of user for user that will use instrument */
  43.   var $username;
  44.   /** @var string     full name of user for user that will use instrument */
  45.   var $name;
  46.   /** @var string     email address for user that will use instrument */
  47.   var $useremail;
  48.   /** @var string     phone number for user that will use instrument */
  49.   var $userphone;
  50.   /** @var integer    user id number for user that booked the instrument */
  51.   var $masquserid;
  52.   /** @var integer    full name of user for user that booked the instrument */
  53.   var $masquser;
  54.   /** @var string     username of user for user that booked the instrument */
  55.   var $masqusername;
  56.   /** @var string     email address for user that booked the instrument */
  57.   var $masqemail;
  58.   /** @var string     instrument name */
  59.   var $instrumentName;
  60.   /** @var string     instrument description */
  61.  
  62.   /**
  63.   *  Create a booking object
  64.   *
  65.   * @param array  $arr  key => value paids
  66.   */
  67.   function Booking($arr{
  68.     $this->TimeSlot($arr['bookwhen']$arr['stoptime']$arr['duration']);
  69.     $isVacant false;
  70.     $this->id = $arr['bookid'];
  71.     $this->discount = $arr['discount'];
  72.     $this->log = $arr['log'];
  73.     $this->comments = $arr['comments'];
  74.     $this->project = $arr['project'];
  75.     $this->userid = $arr['userid'];
  76.     $this->username = $arr['username'];
  77.     $this->name = $arr['name'];
  78.     $this->useremail = $arr['email'];
  79.     $this->userphone = $arr['phone'];
  80.     $this->masquserid = $arr['masquserid'];
  81.     $this->masquser = $arr['masquser'];
  82.     $this->masqusername = $arr['masqusername'];
  83.     $this->masqemail = $arr['masqemail'];
  84.     $this->instrumentName = $arr['instrumentname'];
  85.     $this->instrumentDescription = $arr['instrumentdescription'];
  86.  
  87.     #echo "Booking from ".$this->start->dateTimeString()." to ".$this->stop->dateTimeString()."<br />\n";
  88.     $this->baseclass='booking';
  89.   }
  90.  
  91.   /**
  92.   * display the booking as a list of settings
  93.   *
  94.   * @param boolean   $displayAdmin   show admin-only information (discount etc)
  95.   * @param boolean   $displayOwner   show owner-only information (project etc)
  96.   * @return string html representation of booking
  97.   */
  98.   function display($displayAdmin$displayOwner{
  99.     return $this->displayInTable(2$displayAdmin$displayOwner);
  100.   }
  101.  
  102.   /**
  103.   * display the booking as a list of settings
  104.   *
  105.   * @param boolean   $displayAdmin   show admin-only information (discount etc)
  106.   * @param boolean   $displayOwner   show owner-only information (project etc)
  107.   * @return string html representation of booking
  108.   */
  109.   function displayInTable($cols$displayAdmin$displayOwner{
  110.     $t '<tr><td>'.T_('Booking ID').'</td><td>'.$this->id.'</td></tr>'."\n"
  111.        . '<tr><td>'.T_('Start').'</td><td>'.$this->start->getShortDateTimeString().'</td></tr>'."\n"
  112.         . '<tr><td>'.T_('Stop').'</td><td>'.$this->stop->getShortDateTimeString().'</td></tr>'."\n"
  113.         . '<tr><td>'.T_('Duration').'</td><td>'.$this->duration->getShortString()/*.$bookinglength*/.'</td></tr>'."\n"
  114.        . '<tr><td>'.T_('User').'</td><td><a href="mailto:'.xssqw($this->useremail).'">'.xssqw($this->name).'</a> ('.xssqw($this->username).')</td></tr>'."\n"
  115.        . '<tr><td>'.T_('Comments').'</td><td>'.xssqw($this->comments).'</td></tr>'."\n"
  116.        . '<tr><td>'.T_('Log').'</td><td>'.xssqw($this->log).'</td></tr>'."\n";
  117.     if ($displayAdmin{
  118.       if ($this->masquser{
  119.         $t .= '<tr><td>'.T_('Booked by').'</td><td><a href="mailto:'.xssqw($this->masqemail).'">'.xssqw($this->masquser).'</a> ('.xssqw($this->masqusername).')</td></tr>'."\n";
  120.       }
  121.     }
  122.     if ($displayAdmin || $displayOwner{
  123.       $t .= '<tr><td>'.T_('Project').'</td><td>'.xssqw($this->project).'</td></tr>'."\n";
  124.       if ($this->discount{
  125.         $t .= '<tr><td>'.T_('Discount').'</td><td>'.xssqw($this->discount).'</td></tr>'."\n";
  126.       }
  127.     }
  128.     return $t;
  129.   }
  130.  
  131.   /**
  132.   * display the booking as a single cell in a calendar
  133.   *
  134.   * @return string html representation of booking
  135.   */
  136.   function displayInCell(/*$isadmin=0*/{
  137.     $conf ConfigReader::getInstance();
  138.     $BasePath $conf->BasePath;
  139.     $start = isset($this->displayStart$this->displayStart : $this->start;
  140.     $stop  = isset($this->displayStop)  $this->displayStop  : $this->stop;
  141.     if ($this->freeBusyOnly{
  142.       static $freeBusyStr null;
  143.       static $busyStr null;
  144.       if ($freeBusyStr === null{
  145.         $freeBusyStr T_('Busy from %s to %s');
  146.         $busyStr     T_('busy');
  147.       }
  148.       $timedescription sprintf($freeBusyStr$start->getShortDateTimeString()$stop->shortDateTimeString());
  149.       return "<div title='$timedescription'>$busyStr</div>";
  150.     }
  151.     static $viewEditStr null;
  152.     if ($viewEditStr === null$viewEditStr T_('View or edit booking from %s to %s');
  153.     $timedescription sprintf($viewEditStr$start->getShortDateTimeString()$stop->getShortDateTimeString());
  154.     //$timedescription = $this->start->timeString().' - '.$this->stop->timeString();
  155.     $isodate $start->dateString();
  156.     $t '';
  157.     $t .= "<div style='float:right;'><a href='$this->href&amp;isodate=$isodate&amp;bookid=$this->id"
  158.               ."title='$timedescriptionclass='but'><img src='$BasePath/theme/images/editbooking.png"
  159.               ."alt='$timedescriptionclass='calicon' /></a></div>";
  160.     // Finally include details of the booking:
  161.     $t .= '<div class="calbookperson">'
  162.          .'<a href="mailto:'.xssqw($this->useremail).'">'
  163.          .xssqw($this->name).'</a></div>';
  164.     if ($conf->value('calendar''showphone'false)) {
  165.       $t .= '<div class="calphone">'
  166.           .xssqw($this->userphone)
  167.           .'</div>';
  168.     }
  169.     if ($this->comments{
  170.       $t .= '<div class="calcomment">'
  171.           .xssqw($this->comments)
  172.           .'</div>';
  173.     }
  174.     return $t;
  175.   }
  176.  
  177.   /**
  178.   * work out the title (start and stop times) for the booking for display
  179.   *
  180.   * @return string title
  181.   */
  182.   function generateBookingTitle({
  183.     static $bookingStr null;
  184.     if ($bookingStr === null$bookingStr T_('Booking from %s - %s');
  185.  
  186.     $start = isset($this->displayStart$this->displayStart $this->start;
  187.     $stop  = isset($this->displayStop)  $this->displayStop  $this->stop;
  188.     return sprintf($bookingStr$start->getShortDateTimeString()$stop->getShortDateTimeString());
  189.   }
  190.  
  191.   /**
  192.   * construct a long description of the time slot for pop-ups
  193.   *
  194.   * @return string description
  195.   */
  196.   function generateLongDescription($short=false{
  197.     $s '';
  198.     if ($short && isset($this->children&& is_array($this->children)) {
  199.       $list array();
  200.       foreach ($this->children as $b{
  201.         $list[$b->generateLongDescription(true);
  202.       }
  203.       #print $s;
  204.       $s '<table class="popup">'join($list"".'</table>';
  205.     elseif ($short{
  206.       $instrument $this->instrumentName;
  207.       $user $this->name;
  208.       $start = isset($this->displayStart$this->displayStart : $this->start;
  209.       $stop  = isset($this->displayStop)  $this->displayStop  : $this->stop;
  210.       $starttime $start->getShortTimeString();
  211.       $stoptime  $stop->getShortTimeString();
  212.       $s "<tr><td>$instrument</td><td>$user</td><td>$starttime</td><td>$stoptime</td></tr>";
  213.     else {
  214.       $s '<table class="popup">'$this->displayInTable(2falsefalse.'</table>';
  215.     }
  216.  
  217.     #print $s;
  218.     return $s;
  219.   }
  220.  

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