Source for file bookinglist.php

Documentation is available at bookinglist.php

  1. <?php
  2. /**
  3. * View a list of bookings for a given user or instrument in tabular format
  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: bookinglist.php,v 1.3 2006/12/12 23:30:42 themill Exp $
  9. @package    Bumblebee
  10. @subpackage Actions
  11. *
  12. *  path (bumblebee root)/inc/actions/bookinglist.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** list of choices object */
  19. require_once 'inc/formslib/anchortablelist.php';
  20. /** parent object */
  21. require_once 'inc/actions/viewbase.php';
  22.  
  23. /**
  24. * View a list of bookings for a given user or instrument in tabular format
  25. @package    Bumblebee
  26. @subpackage Actions
  27. */
  28. class ActionBookingList extends ActionViewBase {
  29.  
  30.   var $restrictions = array();
  31.   var $startListing;
  32.   var $stopListing;
  33.  
  34.   //restrictions that might be placed on the listing
  35.     var $instrument;
  36.   var $user;
  37.   var $groups;
  38.   var $projects;
  39.  
  40.   var $showUser = true;
  41.  
  42.   var $tableCaption = '';
  43.   var $noneFoundNotice = '%s - %s';
  44.  
  45.   /**
  46.   * Initialising the class
  47.   *
  48.   * @param  BumblebeeAuth $auth  Authorisation object
  49.   * @param  array $pdata   extra state data from the call path
  50.   * @return void nothing
  51.   */
  52.   function ActionBookingList($auth$PDATA{
  53.     parent::ActionViewBase($auth$PDATA);
  54.     $this->mungeInputData();
  55.   }
  56.  
  57.   function go({
  58.     $this->selectInstrument();
  59.   }
  60.  
  61.   function setDefaultRestrictions($window{
  62.     $this->startListing = new SimpleDate(time());
  63.     $this->startListing->dayRound();
  64.     $this->stopListing = clone($this->startListing);
  65.     $this->stopListing->addDays($window);
  66.   }
  67.  
  68.  
  69.   function _makeRestrictions({
  70.     $this->restrictions['bookwhen >= '.qw($this->startListing->dateTimeString());
  71.     $this->restrictions['bookwhen <= '.qw($this->stopListing->dateTimeString());
  72.  
  73.     if (isset($this->user&& empty($this->user)) {
  74.       $this->restrictions['userid='.qw($this->user);
  75.       $this->showUser = false;
  76.     }
  77.  
  78.     if (isset($this->instrument&& empty($this->instrument)) {
  79.       $this->restrictions['instrument='.qw($this->instrument);
  80.     }
  81.  
  82. /*    if (is_array($this->groups)) {
  83.       if (count($this->groups) > 0) {
  84.         $this->restrictions[] = 'groupid in ('.join(',', array_qw($this->groups)).')';
  85.       } else {
  86.         $this->restrictions[] = '0';
  87.       }
  88.     }*/
  89.  
  90.     if (is_array($this->projects)) {
  91.       if (count($this->projects0{
  92.         $this->restrictions['projectid in ('.join(','array_qw($this->projects)).')';
  93.       else {
  94.         $this->restrictions['0';
  95.       }
  96.     }
  97.   }
  98.  
  99.   /**
  100.   *
  101.   */
  102.   function showBookings({
  103.  
  104.     $this-> _makeRestrictions();
  105.     $restriction join($this->restrictions' AND ');
  106.  
  107.     $blist new AnchorTableList('Bookings'T_('Upcoming bookings')4);
  108.     $blist->hrefbase makeURL('book'array('bookid'=>'__id__'));
  109.  
  110.     $blist->connectDB('bookings',
  111.                           array('bookings.id''bookwhen''duration',
  112.                                 'instruments.name AS instrumentname''username''users.name'),
  113.                           $restriction,
  114.                           'bookwhen',
  115.                           array('bookings.id''bookid'),
  116.                           NULL,
  117.                           array('users'       => 'userid=users.id',
  118.                                 'instruments' => 'instrument=instruments.id'));
  119.  
  120.     $headings array(T_('Date &amp; Time'),
  121.                       T_('Duration'),
  122.                       T_('Instrument')
  123.                       );
  124.  
  125.     if ($this->showUser{
  126.       $blist->setFormat('id',
  127.                         '%s'array('bookwhen'),
  128.                         '%s'array('duration'),
  129.                         '%s'array('instrumentname'),
  130.                         '%s (%s)'array('name''username'));
  131.       $headings[T_('User');
  132.     else {
  133.       $blist->setFormat('id',
  134.                         '%s'array('bookwhen'),
  135.                         '%s'array('duration'),
  136.                         '%s'array('instrumentname')
  137.                         );
  138.       $blist->numcols--;
  139.     }
  140.     $blist->setTableHeadings($headings);
  141.  
  142.     echo $this->tableCaption;
  143.  
  144.     if ($blist->list->length <=0{
  145.       printf($this->noneFoundNotice,
  146.                     $this->startListing->dateString(),
  147.                     $this->stopListing->dateString());
  148.     else {
  149.       echo $blist->display();
  150.     }
  151.   }
  152.  
  153. // class ActionView
  154.  
  155. ?>

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