Source for file consumable.php

Documentation is available at consumable.php

  1. <?php
  2. /**
  3. * Consumables object
  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 DBObjects
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. require_once 'inc/bb/configreader.php';
  17.  
  18. /** parent object */
  19. require_once 'inc/formslib/dbrow.php';
  20. /** uses fields */
  21. require_once 'inc/formslib/idfield.php';
  22. require_once 'inc/formslib/textfield.php';
  23.  
  24. /**
  25. * Consumables object
  26. *
  27. * @package    Bumblebee
  28. * @subpackage DBObjects
  29. */
  30. class Consumable extends DBRow {
  31.  
  32.   function Consumable($id) {
  33.     $this->DBRow('consumables', $id);
  34.     $this->editable = 1;
  35.     $this->deleteFromTable = 0;
  36.  
  37.     $conf = ConfigReader::getInstance();
  38.  
  39.     $f = new IdField('id', T_('Consumable ID'));
  40.     $f->editable = 0;
  41.     $this->addElement($f);
  42.     $f = new TextField('name', T_('Item Code'));
  43.     $attrs = array('size' => '48');
  44.     $f->required = 1;
  45.     $f->isValidTest = 'is_nonempty_string';
  46.     $f->setAttr($attrs);
  47.     $this->addElement($f);
  48.     $f = new TextField('longname', T_('Description'));
  49.     $f->required = 1;
  50.     $f->isValidTest = 'is_nonempty_string';
  51.     $f->setAttr($attrs);
  52.     $this->addElement($f);
  53.     $f = new CurrencyField('cost',
  54.                            sprintf(T_('Unit cost (%s)'),
  55.                                     sprintf($conf->value('language', 'money_format', '$%s'), '')),
  56.                             T_('Cost per item'));
  57.     $f->required = 1;
  58.     $f->setAttr(array_merge($attrs,
  59.                 array('float' => true,
  60.                       'precision' => $conf->value('language', 'money_decimal_places', 2))));
  61.     $this->addElement($f);
  62.     $this->fill();
  63.     $this->dumpheader = 'Consumables object';
  64.   }
  65.  
  66.   function display() {
  67.     return $this->displayAsTable();
  68.   }
  69.  
  70.   function displayAsTable($cols=2) {
  71.     $t = '<table class="tabularobject">';
  72.     foreach ($this->fields as $k => $v) {
  73.       $t .= $v->displayInTable($cols);
  74.     }
  75.     $t .= '</table>';
  76.     return $t;
  77.   }
  78.  

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