Source for file consumables.php

Documentation is available at consumables.php

  1. <?php
  2. /**
  3. * Edit/create/delete consumables
  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/consumables.php
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** Consumable object */
  19. require_once 'inc/bb/consumable.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/create/delete consumables
  27. @package    Bumblebee
  28. @subpackage Actions
  29. */
  30. class ActionConsumables extends ActionAction {
  31.  
  32.   /**
  33.   * Initialising the class
  34.   *
  35.   * @param  BumblebeeAuth $auth  Authorisation object
  36.   * @param  array $pdata   extra state data from the call path
  37.   * @return void nothing
  38.   */
  39.   function ActionConsumables($auth$PDATA{
  40.     parent::ActionAction($auth$PDATA);
  41.     $this->mungeInputData();
  42.   }
  43.  
  44.   function go({
  45.     if (isset($this->PD['id'])) {
  46.       $this->select(issetSet($this->PD'showdeleted'false));
  47.     elseif (isset($this->PD['delete'])) {
  48.       if ($this->readOnly{
  49.         $this->readOnlyError();
  50.       else {
  51.         $this->delete();
  52.       }
  53.     else {
  54.       if ($this->readOnly$this->_dataCleanse('id');
  55.       $this->edit();
  56.     }
  57.     echo "<br /><br /><a href='".makeURL('consumables')."'>"
  58.               .T_('Return to consumables list')."</a>";
  59.   }
  60.  
  61.   function select($deleted=false{
  62.     $select new AnchorTableList(T_('Consumables')T_('Select which Consumables to view'));
  63.     $select->deleted $deleted;
  64.     $select->connectDB('consumables'array('id''name''longname'));
  65.     $select->list->prepend(array('-1'T_('Create new consumable')));
  66.     $select->list->append(array('showdeleted'T_('Show deleted consumables')));
  67.     $select->hrefbase makeURL('consumables'array('id'=>'__id__'));
  68.     $select->setFormat('id''%s'array('name')' %50.50s'array('longname'));
  69.     echo $select->display();
  70.   }
  71.  
  72.   function edit({
  73.     $consumable new Consumable($this->PD['id']);
  74.     $consumable->update($this->PD);
  75.     $consumable->checkValid();
  76.     echo $this->reportAction($consumable->sync(),
  77.           array(
  78.               STATUS_OK =>   ($this->PD['id'0
  79.                                 ? T_('Consumable created'T_('Consumable updated')),
  80.               STATUS_ERR =>  T_('Consumable could not be changed:').' '.$consumable->errorMessage
  81.           )
  82.         );
  83.     echo $consumable->display();
  84.     if ($consumable->id 0{
  85.       $submit T_('Create new consumable');
  86.       $delete '0';
  87.     else {
  88.       $submit T_('Update entry');
  89.       $delete $consumable->isDeleted T_('Undelete entry'T_('Delete entry');
  90.     }
  91.     echo "<input type='submitname='submitvalue='$submit' />";
  92.     if ($deleteecho "<input type='submitname='deletevalue='$delete' />";
  93.     echo '<p>'.sprintf(T_('<a href="%s">View listing</a> for selected consumable'),
  94.                 makeURL('consume'array('consumableid'=>$consumable->id'list'=>1)))."</p>\n";
  95.   }
  96.  
  97.   function delete({
  98.     $consumable new Consumable($this->PD['id']);
  99.     echo $this->reportAction($consumable->delete(),
  100.               array(
  101.                   STATUS_OK =>   $consumable->isDeleted T_('Consumable undeleted')
  102.                                                         : T_('Consumable deleted'),
  103.                   STATUS_ERR =>  T_('Consumable could not be deleted:')
  104.                                  .'<br/><br/>'.$consumable->errorMessage
  105.               )
  106.             );
  107.   }
  108. }
  109.  
  110. ?>

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