Source for file consumableuse.php

Documentation is available at consumableuse.php

  1. <?php
  2. /**
  3. * Use of 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. /** parent object */
  17. require_once 'inc/formslib/dbrow.php';
  18. require_once 'inc/formslib/textfield.php';
  19. require_once 'inc/formslib/referencefield.php';
  20.  
  21. /**
  22. * Use of Consumables object
  23. *
  24. @package    Bumblebee
  25. @subpackage DBObjects
  26. */
  27. class ConsumableUse extends DBRow {
  28.  
  29.   function ConsumableUse($id$userid=''$consumableid=''$uid=''$ip=''$today=''{
  30.     $this->DBRow('consumables_use'$id);
  31.     $this->editable = 1;
  32.     $f new IdField('id'T_('Record ID'));
  33.     $f->editable 0;
  34.     $this->addElement($f);
  35.     if ($userid!='' && $consumableid!='' && $uid!='' && $ip!='' && $today!=''{
  36.       $userid $this->_checkUserID($userid);
  37.       $f new ReferenceField('userid'T_('User'));
  38.       $f->extraInfo('users''id''name');
  39.       $f->defaultValue $userid;
  40.       $f->duplicateName 'user';
  41.       $f->editable 0;
  42.       $this->addElement($f);
  43.       $f new ReferenceField('consumable'T_('Consumable'));
  44.       $f->extraInfo('consumables''id''name');
  45.       $f->defaultValue $consumableid;
  46.       $f->duplicateName 'consumableid';
  47.       $f->editable 0;
  48.       $this->addElement($f);
  49.       $f new ReferenceField('addedby'T_('Recorded by'));
  50.       $f->extraInfo('users''id''name');
  51.       $f->value $uid;
  52.       $f->editable 0;
  53.       $this->addElement($f);
  54.       $f new TextField('ip'T_('Computer IP'));
  55.       $f->value $ip;
  56.       $f->editable 0;
  57.       $this->addElement($f);
  58.       $f new DropList('projectid'T_('Project'));
  59.       $f->connectDB('projects',
  60.                     array('id''name''longname'),
  61.                     'userid='.qw($userid),
  62.                     'name',
  63.                     'id',
  64.                     NULL,
  65.                     array('userprojects'=>'projectid=id'));
  66.       $f->setFormat('id''%s'array('name')' (%35.35s)'array('longname'));
  67.       $f->isValidTest 'is_valid_radiochoice';
  68.       $this->addElement($f);
  69.       $f new TextField('usewhen'T_('Date'));
  70.       $f->value $today;
  71.       $f->required 1;
  72.       $f->isValidTest 'is_valid_date';
  73.       $attrs array('size' => '48');
  74.       $f->setAttr($attrs);
  75.       $this->addElement($f);
  76.       $f new TextField('quantity'T_('Quantity'));
  77.       $f->required 1;
  78.       $f->isValidTest 'is_number';
  79.       $f->setAttr($attrs);
  80.       $this->addElement($f);
  81.       $f new TextField('comments'T_('Comments'));
  82.       $f->setAttr($attrs);
  83.       $this->addElement($f);
  84.       $f new TextField('log'T_('Log entry'));
  85.       $f->setAttr($attrs);
  86.       $this->addElement($f);
  87.     }
  88.     $this->fill();
  89.     $this->dumpheader = 'Consumables object';
  90.   }
  91.  
  92.   /**
  93.    *  check who we are recording if not set
  94.    */
  95.   function _checkUserID($userid{
  96.     if ($userid 0{
  97.       return $userid;
  98.     }
  99.     $row quickSQLSelect('consumables_use''id'$this->id);
  100.     return $row['userid'];
  101.   }
  102.  
  103.   function display({
  104.     return $this->displayAsTable();
  105.   }

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