Source for file specialcosts.php
Documentation is available at specialcosts.php
* Edit/create/delete special instrument usage costs
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* path (bumblebee root)/inc/actions/specialcosts.php
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
/** specialcosts object */
require_once 'inc/bb/specialcosts.php';
require_once 'inc/formslib/anchortablelist.php';
require_once 'inc/actions/actionaction.php';
* Edit/create/delete special instrument usage costs
* @param BumblebeeAuth $auth Authorisation object
* @param array $pdata extra state data from the call path
if (! isset
($this->PD['project'])) {
if ($this->PD['createnew']) {
} elseif (! isset
($this->PD['instrument'])) {
if ($this->PD['createnew']) {
} elseif (isset
($this->PD['delete'])) {
echo
"<br /><br /><a href='".
makeURL('specialcosts').
"'>".
T_('Return to special costs list').
"</a>";
$this->PD['createnew'] = isset
($this->PD['createnew']) &&
$this->PD['createnew'];
if (isset
($this->PD['project']) &&
$this->PD['project'] == -
1) {
$this->PD['createnew'] =
true;
unset
($this->PD['project']);
if (isset
($this->PD['instrument']) &&
$this->PD['instrument'] == -
1) {
$this->PD['createnew'] =
true;
unset
($this->PD['instrument']);
/* if (isset($this->PD[1]) && ($this->PDATA[1] == -1)) {
$this->PD['createnew'] = 1;
array_shift($this->PDATA);
if (isset($this->PDATA[1]) && ! empty($this->PDATA[1]) && is_numeric($this->PDATA[1])) {
$this->PD['project'] = $this->PDATA[1];
if (isset($this->PDATA[2]) && ! empty($this->PDATA[2]) && is_numeric($this->PDATA[2])) {
if ($this->PDATA[2] == -1) {
$this->PD['createnew'] = 1;
$this->PD['instrument'] = $this->PDATA[2];
if (isset($this->PD['delete']) && !empty($this->PD['delete'])) {
echoData($this->PD, 0);*/
* Select for which project the special costs should be displayed
$this->log("selectProject: which existing rate to edit");
$select->connectDB('projects', array('id', 'name', 'longname'),
array('projectrates'=>
'projectrates.projectid=projects.id'), true);
$select->list->prepend(array('-1', T_('Create new project rate')));
$select->hrefbase =
makeURL('specialcosts', array('project'=>
'__id__'));
$select->setFormat('id', '%s', array('name'), '%50.50s', array('longname'));
* Select for which project a special cost should be created
$this->log("selectProjectCreate: which project to create a new rate for");
$select->connectDB('projects', array('id', 'name', 'longname'));
$select->hrefbase =
makeURL('specialcosts', array('project'=>
'__id__', 'createnew'=>
1));
$select->setFormat('id', '%s', array('name'), '%50.50s', array('longname'));
* Select for which instrument the special costs should be displayed
$this->log("selectInstrument: which existing rate to edit");
$select->connectDB('instruments', array('id', 'name', 'longname'),
'projectid='.
qw($this->PD['project']),
array('projectrates'=>
'projectrates.instrid=instruments.id'), true);
$select->list->prepend(array('-1', T_('Create new project rate')));
$select->hrefbase =
makeURL('specialcosts', array('instrument'=>
'__id__', 'createnew'=>
$this->PD['createnew'], 'project'=>
$this->PD['project']));
$select->setFormat('id', '%s', array('name'), '%50.50s', array('longname'));
* Select for which instrument a special cost should be created
$this->log("selectInstrumentCreate: which instrument to create a new rate for");
$select->connectDB('instruments', array('id', 'name', 'longname'),
'projectid IS NULL', //find rows *not* in the join
array('projectrates'=>
'projectrates.instrid=instruments.id AND projectrates.projectid='.
qw($this->PD['project'])), true);
$select->hrefbase =
makeURL('specialcosts', array('instrument'=>
'__id__', 'createnew'=>
$this->PD['createnew'], 'project'=>
$this->PD['project']));
$select->setFormat('id', '%s', array('name'), '%50.50s', array('longname'));
$specCost->update($this->PD);
STATUS_OK =>
($id <
0 ?
T_('Cost schedule created') :
T_('Cost schedule updated')),
STATUS_ERR =>
T_('Cost schedule could not be changed:').
' '.
$specCost->errorMessage
echo
$specCost->display();
$submit =
T_('Create new project cost');
$submit =
T_('Update entry');
$delete =
T_('Delete entry');
//echo '<input type="hidden" name="project" value="'.$this->PD['project'].'" />';
//echo '<input type="hidden" name="instrument" value="'.$this->PD['instrument'].'" />';
echo
"<input type='submit' name='submit' value='$submit' />";
if ($delete) echo
"<input type='submit' name='delete' value='$delete' />";
STATUS_ERR =>
T_('Cost could not be deleted:').
'<br/><br/>'.
$cost->errorMessage
* Create a SpecialCost object
* @return array ($id, $special_cost)
if ($this->PD['createnew']) {
array($this->PD['project'], $this->PD['instrument']));
$id =
(is_array($row) && isset
($row['rate'])) ?
$row['rate'] : -
1;
$specCost =
new SpecialCost($id, $this->PD['project'], $this->PD['instrument']);
return array($id, $specCost);
Documentation generated on Tue, 06 Mar 2007 10:01:59 +0000 by phpDocumentor 1.3.0