Source for file project.php

Documentation is available at project.php

  1. <?php
  2. /**
  3. * Project object (extends dbo), with extra customisations for other links
  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/idfield.php';
  19. require_once 'inc/formslib/textfield.php';
  20. require_once 'inc/formslib/radiolist.php';
  21. require_once 'inc/formslib/droplist.php';
  22. require_once 'inc/formslib/joindata.php';
  23.  
  24. /**
  25. * Project object (extends dbo), with extra customisations for other links
  26. *
  27. * @package    Bumblebee
  28. * @subpackage DBObjects
  29. */
  30. class Project extends DBRow {
  31.  
  32.   function Project($id) {
  33.     $this->DBRow('projects', $id);
  34.     //$this->DEBUG=10;
  35.     $this->editable = 1;
  36.     $this->use2StepSync = 1;
  37.     $this->deleteFromTable = 0;
  38.     $f = new IdField('id', T_('Project ID'));
  39.     $f->editable = 0;
  40.     $this->addElement($f);
  41.     $f = new TextField('name', T_('Name'));
  42.     $attrs = array('size' => '48');
  43.     $f->required = 1;
  44.     $f->isValidTest = 'is_nonempty_string';
  45.     $f->setAttr($attrs);
  46.     $this->addElement($f);
  47.     $f = new TextField('longname', T_('Description'));
  48.     $f->required = 1;
  49.     $f->isValidTest = 'is_nonempty_string';
  50.     $f->setAttr($attrs);
  51.     $this->addElement($f);
  52.     $f = new RadioList('defaultclass', T_('Default charging band'));
  53.     $f->connectDB('userclass', array('id', 'name'));
  54.     $f->setFormat('id', '%s', array('name'));
  55.     $newchargename = new TextField('name','');
  56.     $newchargename->namebase = 'newcharge-';
  57.     $newchargename->setAttr(array('size' => 24));
  58.     $newchargename->isValidTest = 'is_nonempty_string';
  59.     $newchargename->suppressValidation = 0;
  60.     $f->list->append(array('-1', T_('Create new:').' '), $newchargename);
  61.     $f->setAttr($attrs);
  62.     $f->required = 1;
  63.     $f->extendable = 1;
  64.     $f->editable = 1;
  65.     $f->isValidTest = 'is_valid_radiochoice';
  66.     $this->addElement($f);
  67.     $f = new JoinData('projectgroups',
  68.                        'projectid', $this->id,
  69.                        'groups', T_('Group membership (%)'));
  70.     $groupfield = new DropList('groupid', 'Group');
  71.     $groupfield->connectDB('groups', array('id', 'name', 'longname'));
  72.     $groupfield->prepend(array('0', T_('(none)'), T_('no selection')));
  73.     $groupfield->setDefault(0);
  74.     $groupfield->setFormat('id', '%s', array('name'), ' (%30.30s)', array('longname'));
  75.     $f->addElement($groupfield);
  76.     $percentfield = new TextField('grouppc', '');
  77.     $percentfield->isValidTest = 'is_number';
  78.     $percentfield->setAttr(array('size' => '16', 'float' => true, 'precision' => 2));
  79.     $f->addElement($percentfield, 'sum_is_100');
  80.     $f->joinSetup('groupid', array('total' => 3));
  81.     $f->colspan = 2;
  82.     $this->addElement($f);
  83.     $this->fill();
  84.     $this->dumpheader = 'Project object';
  85.   }
  86.  
  87.   function display() {
  88.     return $this->displayAsTable();
  89.   }
  90.  
  91.  

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