Source for file costs.php

Documentation is available at costs.php

  1. <?php
  2. /**
  3. * Edit and create costs for using instruments
  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/costs.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** Costs object */
  19. require_once 'inc/bb/costs.php';
  20. /** list of choices */
  21. require_once 'inc/formslib/anchortablelist.php';
  22. /** parent object */
  23. require_once 'inc/actions/actionaction.php';
  24.  
  25. /**
  26. *  Edit and create costs for using instruments
  27. *
  28. * Costs for instrument usage are calculated using a matrix of the instrument class
  29. * and the user class. See { @link http://bumblebeeman.sf.net/ } for further details.
  30. @package    Bumblebee
  31. @subpackage Actions
  32. */
  33. class ActionCosts extends ActionAction {
  34.  
  35.   /**
  36.   * Initialising the class
  37.   *
  38.   * @param  BumblebeeAuth $auth  Authorisation object
  39.   * @param  array $pdata   extra state data from the call path
  40.   * @return void nothing
  41.   */
  42.   function ActionCosts($auth$pdata{
  43.     parent::ActionAction($auth$pdata);
  44.     $this->mungeInputData();
  45.   }
  46.  
  47.   function go({
  48.     if (isset($this->PD['userclass'])) {
  49.       $this->selectUserClass();
  50.     else {
  51.       if ($this->readOnly$this->_dataCleanse('userclass');
  52.       $this->edit();
  53.     }
  54.     echo "<br /><br /><a href='".makeURL('costs')."'>"
  55.                               .T_('Return to costs list')      ."</a><br /><br />";
  56.     echo "<a href='".makeURL('specialcosts')."'>"
  57.                               .T_('Edit special costs')        ."</a><br />";
  58.     echo "<a href='".makeURL('instrumentclass')."'>"
  59.                               .T_('Edit instrument classes')   ."</a><br />";
  60.     echo "<a href='".makeURL('userclass')."'>"
  61.                               .T_('Edit user classes')         ."</a><br />";
  62.   }
  63.  
  64. //   function mungeInputData() {
  65. //     $this->PD = array();
  66. //     foreach ($_POST as $k => $v) {
  67. //       $this->PD[$k] = $v;
  68. //     }
  69. //     if (isset($this->PDATA[1]) && ! empty($this->PDATA[1])) {
  70. //       $this->PD['userclass'] = $this->PDATA[1];
  71. //     }
  72. //     echoData($this->PD, 0);
  73. //   }
  74.  
  75.   
  76.   /**
  77.   * Generate an HTML form for the user to select which class of user to edit costs
  78.   *
  79.   * - do DB look-ups on what instruments exist
  80.   * - construct a table of links to allow the user to select which userclass to edit
  81.   *
  82.   * @return void nothing
  83.   */
  84.   function selectUserClass({
  85.     $select new AnchorTableList(T_('Cost')T_('Select which user class to view usage costs')1);
  86.     $select->connectDB('userclass'array('id''name'));
  87.     //$select->list->prepend(array("-1","Create new user class"));
  88.     $select->hrefbase makeURL('costs'array('userclass'=>'__id__'));
  89.     $select->setFormat('id''%s'array('name'));
  90.     //echo $select->list->text_dump();
  91.     echo $select->display();
  92.   }
  93.  
  94.   /**
  95.   * Sync the user's changes with the db and provide feedback
  96.   *
  97.   * @return void nothing
  98.   */
  99.   function edit({
  100.     $classCost new ClassCost($this->PD['userclass']);
  101.     $classCost->update($this->PD);
  102.     $classCost->checkValid();
  103.     echo $this->reportAction($classCost->sync(),
  104.           array(
  105.               STATUS_OK =>   ($this->PD['userclass'0
  106.                                     ? T_('Cost schedule created')
  107.                                     : T_('Cost schedule updated')),
  108.               STATUS_ERR =>  T_('Cost schedule could not be changed:').' '.$classCost->errorMessage
  109.           )
  110.         );
  111.     echo $classCost->display();
  112.     echo '<input type="submit" name="submit" value="'.T_('Update entry').'" />';
  113.   }
  114.  
  115. }
  116.  
  117. ?>

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