* Distinguish program/project/execution in stakeholder.
This commit is contained in:
@@ -45,6 +45,7 @@ ALTER TABLE `zt_testreport` ADD `project` mediumint(8) unsigned NOT NULL AFTER `
|
||||
ALTER TABLE `zt_testsuite` ADD `project` mediumint(8) unsigned NOT NULL AFTER `id`;
|
||||
ALTER TABLE `zt_build` ADD `project` mediumint(8) unsigned NOT NULL AFTER `id`;
|
||||
ALTER TABLE `zt_release` ADD `project` mediumint(8) unsigned NOT NULL AFTER `id`;
|
||||
ALTER TABLE `zt_expect` ADD `project` mediumint(8) unsigned NOT NULL AFTER `id`;
|
||||
|
||||
ALTER TABLE `zt_product` ADD `bind` enum('0','1') NOT NULL DEFAULT '0' AFTER `code`;
|
||||
ALTER TABLE `zt_product` ADD `program` mediumint(8) unsigned NOT NULL AFTER `id`;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class stakeholderModel extends model
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Create a stakeholder.
|
||||
*
|
||||
* @param int programID
|
||||
@@ -14,37 +14,37 @@ class stakeholderModel extends model
|
||||
$data = fixer::input('post')
|
||||
->setIF($programID == 0, 'objectType', 'project')
|
||||
->setIF($programID != 0, 'objectType', 'program')
|
||||
->setIF($programID == 0, 'objectID', $this->session->PRJ)
|
||||
->setIF($programID == 0, 'objectID', $this->session->project)
|
||||
->setIF($programID != 0, 'objectID', $programID)
|
||||
->setDefault('createdBy', $this->app->user->account)
|
||||
->setDefault('createdDate', helper::today())
|
||||
->stripTags($this->config->stakeholder->editor->create['id'], $this->config->allowedTags)
|
||||
->stripTags($this->config->stakeholder->editor->create['id'], $this->config->allowedTags)
|
||||
->remove('uid')
|
||||
->get();
|
||||
->get();
|
||||
|
||||
$account = isset($data->user) ? $data->user : '';
|
||||
$account = isset($data->user) ? $data->user : '';
|
||||
$stakeholder->user = $account;
|
||||
if($data->from != 'outside')
|
||||
{
|
||||
if(!$account)
|
||||
if(!$account)
|
||||
{
|
||||
dao::$errors[] = $this->lang->stakeholder->userEmpty;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If it's an outsider and it's added for the first time, insert to user table. */
|
||||
if(!$account)
|
||||
if(!$account)
|
||||
{
|
||||
if(!$data->name)
|
||||
{
|
||||
dao::$errors[] = $this->lang->stakeholder->nameEmpty;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
$companyID = $data->company;
|
||||
if($data->company and isset($data->new))
|
||||
if($data->company and isset($data->new))
|
||||
{
|
||||
$company = new stdclass();
|
||||
$company->name = $data->company;
|
||||
@@ -53,10 +53,10 @@ class stakeholderModel extends model
|
||||
$companyID = $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
if(!$companyID)
|
||||
if(!$companyID)
|
||||
{
|
||||
dao::$errors[] = $this->lang->stakeholder->companyEmpty;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = new stdclass();
|
||||
@@ -105,25 +105,25 @@ class stakeholderModel extends model
|
||||
/**
|
||||
* Batch create stakeholders for a project.
|
||||
*
|
||||
* @access public
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchCreate()
|
||||
public function batchCreate()
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$data = (array)fixer::input('post')->get();
|
||||
$data = (array)fixer::input('post')->get();
|
||||
|
||||
$members = $this->loadModel('project')->getTeamMemberPairs($this->session->PRJ);
|
||||
$members = $this->loadModel('execution')->getTeamMemberPairs($this->session->project);
|
||||
$accounts = array_unique($data['accounts']);
|
||||
$oldJoin = $this->dao->select('`user`, createdDate')->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->PRJ)->andWhere('objectType')->eq('project')->fetchPairs();
|
||||
$this->dao->delete()->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->PRJ)->andWhere('objectType')->eq('project')->exec();
|
||||
$oldJoin = $this->dao->select('`user`, createdDate')->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->project)->andWhere('objectType')->eq('project')->fetchPairs();
|
||||
$this->dao->delete()->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->project)->andWhere('objectType')->eq('project')->exec();
|
||||
|
||||
foreach($accounts as $key => $account)
|
||||
{
|
||||
{
|
||||
if(empty($account)) continue;
|
||||
|
||||
$stakeholder = new stdclass();
|
||||
$stakeholder->objectID = $this->session->PRJ;
|
||||
$stakeholder->objectID = $this->session->project;
|
||||
$stakeholder->objectType = 'project';
|
||||
$stakeholder->user = $account;
|
||||
$stakeholder->type = in_array($account, array_keys($members)) ? 'inside' : 'outside';
|
||||
@@ -134,7 +134,7 @@ class stakeholderModel extends model
|
||||
|
||||
$stakeholderID = $this->dao->lastInsertId();
|
||||
$this->action->create('stakeholder', $stakeholderID, 'added');
|
||||
}
|
||||
}
|
||||
|
||||
/* Only changed account update userview. */
|
||||
$oldAccounts = array_keys($oldJoin);
|
||||
@@ -142,23 +142,23 @@ class stakeholderModel extends model
|
||||
$changedAccounts = array_merge($changedAccounts, array_diff($oldAccounts, $accounts));
|
||||
$changedAccounts = array_unique($changedAccounts);
|
||||
|
||||
$this->loadModel('user')->updateUserView($this->session->PRJ, 'project', $changedAccounts);
|
||||
$this->loadModel('user')->updateUserView($this->session->project, 'project', $changedAccounts);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Edit a stakeholder.
|
||||
*
|
||||
* @param int $stakeholder
|
||||
* @param int $stakeholder
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($stakeholderID)
|
||||
{
|
||||
$oldStakeholder = $this->getByID($stakeholderID);
|
||||
$oldStakeholder = $this->getByID($stakeholderID);
|
||||
$data = fixer::input('post')
|
||||
->stripTags($this->config->stakeholder->editor->edit['id'], $this->config->allowedTags)
|
||||
->stripTags($this->config->stakeholder->editor->edit['id'], $this->config->allowedTags)
|
||||
->remove('uid')
|
||||
->get();
|
||||
->get();
|
||||
|
||||
$user = new stdclass();
|
||||
if($oldStakeholder->from == 'outside')
|
||||
@@ -206,7 +206,7 @@ class stakeholderModel extends model
|
||||
->leftJoin(TABLE_COMPANY)->alias('t3')->on('t2.company=t3.id')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t4')->on('t1.objectID=t4.id')
|
||||
->where('t1.deleted')->eq('0')
|
||||
->andWhere('t1.objectID')->eq($this->session->PRJ)
|
||||
->andWhere('t1.objectID')->eq($this->session->project)
|
||||
->beginIF($browseType == 'inside')->andWhere('t1.type')->eq('inside')->fi()
|
||||
->beginIF($browseType == 'outside')->andWhere('t1.type')->eq('outside')->fi()
|
||||
->beginIF($browseType == 'key')->andWhere('t1.key')->ne('0')->fi()
|
||||
@@ -230,7 +230,7 @@ class stakeholderModel extends model
|
||||
{
|
||||
$stakeholders = $this->dao->select('id, user')->from(TABLE_STAKEHOLDER)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('objectID')->eq($this->session->PRJ)
|
||||
->andWhere('objectID')->eq($this->session->project)
|
||||
->orderBy('id_desc')
|
||||
->fetchPairs();
|
||||
|
||||
@@ -239,11 +239,11 @@ class stakeholderModel extends model
|
||||
|
||||
/**
|
||||
* Get self stakeholders by object id list.
|
||||
*
|
||||
* @param array $objectIdList
|
||||
* @param string $objectType
|
||||
*
|
||||
* @param array $objectIdList
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function getStakeholderGroup($objectIdList)
|
||||
{
|
||||
@@ -251,8 +251,8 @@ class stakeholderModel extends model
|
||||
|
||||
$stakeholderGroup = array();
|
||||
foreach($stakeholders as $stakeholder)
|
||||
{
|
||||
$stakeholderGroup[$stakeholder->objectID][$stakeholder->user] = $stakeholder->user;
|
||||
{
|
||||
$stakeholderGroup[$stakeholder->objectID][$stakeholder->user] = $stakeholder->user;
|
||||
}
|
||||
|
||||
return $stakeholderGroup;
|
||||
@@ -260,11 +260,11 @@ class stakeholderModel extends model
|
||||
|
||||
/**
|
||||
* Get parent stakeholder group by object id list.
|
||||
*
|
||||
* @param array $objectIdList
|
||||
* @param string $objectType
|
||||
*
|
||||
* @param array $objectIdList
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function getParentStakeholderGroup($objectIdList)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ class stakeholderModel extends model
|
||||
$stakeholders = $this->dao->select('t2.realname as name, t2.account, t1.type, t2.role')->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.user=t2.account')
|
||||
->where('t1.deleted')->eq('0')
|
||||
->andWhere('t1.objectID')->eq($this->session->PRJ)
|
||||
->andWhere('t1.objectID')->eq($this->session->project)
|
||||
->fetchGroup('type');
|
||||
|
||||
return $stakeholders;
|
||||
@@ -329,7 +329,7 @@ class stakeholderModel extends model
|
||||
->leftJoin(TABLE_COMPANY)->alias('t3')->on('t2.company=t3.id')
|
||||
->where('t1.id')->eq($userID)
|
||||
->andWhere('t1.deleted')->eq('0')
|
||||
->andWhere('t1.objectID')->eq($this->session->PRJ)
|
||||
->andWhere('t1.objectID')->eq($this->session->project)
|
||||
->fetch();
|
||||
|
||||
return $stakeholder;
|
||||
@@ -342,9 +342,9 @@ class stakeholderModel extends model
|
||||
* @return array
|
||||
*/
|
||||
public function getProcessGroup()
|
||||
{
|
||||
{
|
||||
$group = $this->dao->select('process, activity')->from(TABLE_PROGRAMACTIVITY)
|
||||
->where('PRJ')->eq($this->session->PRJ)
|
||||
->where('project')->eq($this->session->project)
|
||||
->andWhere('result')->eq('yes')
|
||||
->fetchGroup('process');
|
||||
|
||||
@@ -361,7 +361,7 @@ class stakeholderModel extends model
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_PROCESS)
|
||||
->where('deleted')->eq(0)
|
||||
->fetchPairs();
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,8 +374,8 @@ class stakeholderModel extends model
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_INTERVENTION)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->fetchAll('activity');
|
||||
->andWhere('project')->eq($this->session->project)
|
||||
->fetchAll('activity');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,7 +389,7 @@ class stakeholderModel extends model
|
||||
$stakeholders = $this->getStakeHolderPairs();
|
||||
return $this->dao->select('*')->from(TABLE_ISSUE)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('project')->eq($this->session->project)
|
||||
->andWhere('owner')->in(array_values($stakeholders))
|
||||
->orWhere('activity')->ne('')
|
||||
->orderBy('id_desc')
|
||||
@@ -406,7 +406,7 @@ class stakeholderModel extends model
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_ACTIVITY)
|
||||
->where('deleted')->eq(0)
|
||||
->fetchPairs();
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,7 +440,7 @@ class stakeholderModel extends model
|
||||
->add('userID', $userID)
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', date('Y-m-d'))
|
||||
->add('PRJ', $this->session->PRJ)
|
||||
->add('project', $this->session->project)
|
||||
->stripTags($this->config->stakeholder->editor->expect['id'], $this->config->allowedTags)
|
||||
->get();
|
||||
|
||||
@@ -492,7 +492,7 @@ class stakeholderModel extends model
|
||||
$expects = $this->dao->select('t1.*,t2.key,t3.realname')->from(TABLE_EXPECT)->alias('t1')
|
||||
->leftJoin(TABLE_STAKEHOLDER)->alias('t2')->on('t1.userID=t2.id')
|
||||
->leftJoin(TABLE_USER)->alias('t3')->on('t2.user=t3.account')
|
||||
->where('t1.PRJ')->eq($this->session->PRJ)
|
||||
->where('t1.project')->eq($this->session->project)
|
||||
->beginIF($browseType == 'bysearch')
|
||||
->andWhere($stakeholderQuery)
|
||||
->fi()
|
||||
@@ -565,7 +565,7 @@ class stakeholderModel extends model
|
||||
$users = $this->dao->select("t1.id, CONCAT_WS('/', t3.name,t2.realname) as realname")->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.user=t2.account')
|
||||
->leftJoin(TABLE_COMPANY)->alias('t3')->on('t2.company=t3.id')
|
||||
->where('t1.objectID')->eq($this->session->PRJ)
|
||||
->where('t1.objectID')->eq($this->session->project)
|
||||
->andWhere('t1.deleted')->eq('0')
|
||||
->fetchPairs('id', 'realname');
|
||||
|
||||
@@ -583,7 +583,7 @@ class stakeholderModel extends model
|
||||
$users = $this->dao->select("t1.user, CONCAT_WS('/', t3.name,t2.realname) as realname")->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.user=t2.account')
|
||||
->leftJoin(TABLE_COMPANY)->alias('t3')->on('t2.company=t3.id')
|
||||
->where('t1.objectID')->eq($this->session->PRJ)
|
||||
->where('t1.objectID')->eq($this->session->project)
|
||||
->andWhere('t1.deleted')->eq('0')
|
||||
->fetchPairs('user', 'realname');
|
||||
|
||||
@@ -602,7 +602,7 @@ class stakeholderModel extends model
|
||||
return $this->dao->select('*')->from(TABLE_EXPECT)->where('id')->eq($expectID)->andWhere('deleted')->eq('0')->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Build search form.
|
||||
*
|
||||
* @param int $queryID
|
||||
@@ -644,7 +644,7 @@ class stakeholderModel extends model
|
||||
public function getStakeholderIssue($account)
|
||||
{
|
||||
$issueList = $this->dao->select('*')->from(TABLE_ISSUE)
|
||||
->where('PRJ')->eq($this->session->PRJ)
|
||||
->where('project')->eq($this->session->project)
|
||||
->andWhere('owner')->eq($account)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->orderBy('id_desc')
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
<?php echo html::a($this->createLink('stakeholder', 'batchcreate', "projectID={$projectID}"), "<span class='text'> {$lang->program->createStakeholder}</span>");?>
|
||||
</span>
|
||||
<div class='input-group space w-200px'>
|
||||
<span class='input-group-addon'><?php echo $lang->project->selectDept?></span>
|
||||
<?php echo html::select('dept', $depts, $dept, "class='form-control chosen' onchange='setDeptUsers(this)' data-placeholder='{$lang->project->selectDeptTitle}'");?>
|
||||
<span class='input-group-addon'><?php echo $lang->execution->selectDept?></span>
|
||||
<?php echo html::select('dept', $depts, $dept, "class='form-control chosen' onchange='setDeptUsers(this)' data-placeholder='{$lang->execution->selectDeptTitle}'");?>
|
||||
</div>
|
||||
<?php if($project->parent and $config->systemMode == 'new'):?>
|
||||
<?php echo html::a($this->createLink('stakeholder', 'batchcreate', "dept=&parent=$project->parent"), $lang->program->importStakeholder, '', 'class="btn btn-primary"');?>
|
||||
|
||||
Reference in New Issue
Block a user