Source for file deletedbookings.php

Documentation is available at deletedbookings.php

  1. <?php
  2. /**
  3. * View a list of deleted bookings for an instrument over a given time period
  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 Actions
  11. *
  12. *  path (bumblebee root)/inc/actions/deletedbookings.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** list of choices */
  19. require_once 'inc/formslib/anchortablelist.php';
  20. /** date manipulation routines */
  21. require_once 'inc/date.php';
  22. /** DateRange object */
  23. require_once 'inc/bb/daterange.php';
  24. /** parent object */
  25. require_once 'inc/actions/actionaction.php';
  26.  
  27. /**
  28. * View a list of deleted bookings for an instrument over a given time period
  29. * @package    Bumblebee
  30. * @subpackage Actions
  31. */
  32.  
  33.   /**
  34.   * Initialising the class
  35.   *
  36.   * @param  BumblebeeAuth $auth  Authorisation object
  37.   * @param  array $pdata   extra state data from the call path
  38.   * @return void nothing
  39.   */
  40.   function ActionDeletedBookings($auth, $PDATA) {
  41.     parent::ActionAction($auth, $PDATA);
  42.     $this->mungeInputData();
  43.   }
  44.  
  45.   function go() {
  46.     if (! isset($this->PD['instrid'])
  47.           || $this->PD['instrid'] < 1
  48.           || $this->PD['instrid'] == '') {
  49.       $this->selectInstrument();
  50.       return;
  51.     }
  52.     $daterange = new DateRange('daterange', T_('Select date range'),
  53.                       T_('Enter the dates over which you want to report deleted bookings'));
  54.     $daterange->update($this->PD);
  55.     $daterange->checkValid();
  56.     if ($daterange->newObject) {
  57.       $daterange->setDefaults(DR_PREVIOUS, DR_MONTH);
  58.       echo $daterange->display($this->PD);
  59.       echo "<br /><br /><a href='".makeURL('deletedbookings')."'>"
  60.                   .T_('Return to instrument list')."</a>";
  61.     } else {
  62.       $this->showDeleted($daterange);
  63.       echo "<br /><br /><a href='".makeURL('deletedbookings', array('instrid'=>$this->PD['instrid']))."'>".T_('Choose different dates')."</a>";
  64.     }
  65.   }
  66.  
  67. /*  function mungeInputData() {
  68.     $this->PD = array();
  69.     foreach ($_POST as $k => $v) {
  70.       $this->PD[$k] = $v;
  71.     }
  72.     if (isset($this->PDATA[1]) && $this->PDATA[1] !== '') {
  73.       $this->PD['instrid'] = $this->PDATA[1];
  74.     }
  75.     echoData($this->PD, 0);
  76.   }
  77.   */
  78.   /**
  79.   * Select which instrument the listing should be generated for
  80.   */
  81.   function selectInstrument() {
  82.     $instrselect = new AnchorTableList(T_('Instrument'), T_('Select which instrument to view'));
  83.     $instrselect->connectDB('instruments',
  84.                             array('id', 'name', 'longname')
  85.                             );
  86.     $instrselect->hrefbase = makeURL('deletedbookings', array('instrid'=>'__id__'));;
  87.     $instrselect->setFormat('id', '%s', array('name'), ' %50.50s', array('longname'));
  88.     echo $instrselect->display();
  89.   }
  90.  
  91.   /**
  92.   * Display the deleted bookings
  93.   */
  94.   function showDeleted($daterange) {
  95.     $start = $daterange->getStart();
  96.     $stop  = $daterange->getStop();
  97.     $stop->addDays(1);
  98.     $instrument = $this->PD['instrid'];
  99.     $bookings = new AnchorTableList(T_('Bookings'), T_('Select deleted bookings'));
  100.     $bookings->setTableHeadings(array(T_('Date'), T_('Duration'), T_('User'), T_('Log Entry')));
  101.     $bookings->numcols = 4;
  102.     $bookings->deleted = true;
  103.     $bookings->connectDB('bookings',
  104.                             array('bookings.id', 'username', 'bookwhen', 'duration','log'),
  105.                                     'bookwhen >= '.qw($start->dateTimeString())
  106.                               .' AND bookwhen < ' .qw($stop->dateTimeString())
  107.                               .' AND instrument = '.qw($instrument),
  108.                             'bookwhen',
  109.                             'bookings.id',
  110.                             NULL,
  111.                             array('users'=>'userid=users.id'));
  112.     $bookings->hrefbase = makeURL('view', array('bookid'=>'__id__', 'instrid'=>$instrument));
  113.     $bookings->setFormat('id', '%s', array('bookwhen'),
  114.                                '%s', array('duration'),
  115.                                '%s', array('username'),
  116.                                '%s', array('log'));
  117.     echo $bookings->display();
  118.   }
  119.  
  120. } // class ActionDeletedBookings
  121. ?>

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