Merge branch 'zentaopms_239'
This commit is contained in:
+328
-7
@@ -4959,7 +4959,7 @@ class upgradeModel extends model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function processMergedData($programID, $projectID, $lineID, $productIdList = array(), $sprintIdList = array())
|
||||
public function processMergedData($programID, $projectID, $lineID = 0, $productIdList = array(), $sprintIdList = array())
|
||||
{
|
||||
/* Product linked objects. */
|
||||
$this->dao->update(TABLE_RELEASE)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec();
|
||||
@@ -5027,12 +5027,12 @@ class upgradeModel extends model
|
||||
foreach($sprints as $sprint)
|
||||
{
|
||||
$data = new stdclass();
|
||||
$data->project = $projectID;
|
||||
$data->parent = $projectID;
|
||||
$data->grade = 1;
|
||||
$data->path = ",{$projectID},{$sprint->id},";
|
||||
$data->type = 'sprint';
|
||||
$data->acl = $sprint->acl == 'custom' ? 'private' : $sprint->acl;
|
||||
$data->project = $projectID;
|
||||
$data->parent = $projectID;
|
||||
$data->grade = 1;
|
||||
$data->path = ",{$projectID},{$sprint->id},";
|
||||
$data->type = 'sprint';
|
||||
$data->acl = $sprint->acl == 'custom' ? 'private' : $sprint->acl;
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($sprint->id)->exec();
|
||||
|
||||
@@ -7496,6 +7496,327 @@ class upgradeModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Historical projects are upgraded by project.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $fromMode
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function upgradeInProjectMode($programID, $fromMode = '')
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$now = helper::now();
|
||||
$account = isset($this->app->user->account) ? $this->app->user->account : '';
|
||||
|
||||
$noMergedSprints = $this->getNoMergedSprints();
|
||||
if(!$noMergedSprints) return true;
|
||||
|
||||
foreach($noMergedSprints as $sprint)
|
||||
{
|
||||
$project = new stdclass();
|
||||
$project->name = $sprint->name;
|
||||
$project->type = 'project';
|
||||
$project->model = 'scrum';
|
||||
$project->parent = $programID;
|
||||
$project->status = $sprint->status;
|
||||
$project->begin = $sprint->begin;
|
||||
$project->end = isset($sprint->end) ? $sprint->end : LONG_TIME;
|
||||
$project->realBegan = $sprint->realBegan;
|
||||
$project->realEnd = $sprint->realEnd;
|
||||
$project->days = $this->computeDaysDelta($project->begin, $project->end);
|
||||
$project->PM = $sprint->PM;
|
||||
$project->auth = 'extend';
|
||||
$project->openedBy = $account;
|
||||
$project->openedDate = $now;
|
||||
$project->openedVersion = $this->config->version;
|
||||
$project->lastEditedBy = $account;
|
||||
$project->lastEditedDate = $now;
|
||||
$project->grade = 2;
|
||||
$project->acl = $sprint->acl == 'open' ? 'open' : 'private';
|
||||
if($fromMode == 'classic') $project->multiple = '0';
|
||||
|
||||
$this->dao->insert(TABLE_PROJECT)->data($project)->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$projectID = $this->dao->lastInsertId();
|
||||
|
||||
$this->action->create('project', $projectID, 'openedbysystem');
|
||||
if($project->status == 'closed') $this->action->create('project', $projectID, 'closedbysystem');
|
||||
|
||||
$project->id = $projectID;
|
||||
$this->createProjectDocLib($project);
|
||||
|
||||
$productIdList = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($sprint->id)->fetchPairs();
|
||||
$this->processMergedData($programID, $projectID, '', $productIdList, array($sprint->id));
|
||||
|
||||
if($fromMode == 'classic') $this->dao->update(TABLE_PROJECT)->set('multiple')->eq('0')->where('id')->eq($sprint->id)->exec();
|
||||
}
|
||||
|
||||
$this->fixProjectPath($programID);
|
||||
|
||||
$productIdList = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq('0')->fetchPairs();
|
||||
$this->computeProductAcl($productIdList, $programID, 0);
|
||||
|
||||
if(dao::isError()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Historical projects are upgraded by execution.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function upgradeInExecutionMode($programID)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$now = helper::now();
|
||||
$account = isset($this->app->user->account) ? $this->app->user->account : '';
|
||||
|
||||
$noMergedSprints = $this->getNoMergedSprints();
|
||||
if(!$noMergedSprints) return true;
|
||||
|
||||
$projects = array();
|
||||
foreach($noMergedSprints as $sprint)
|
||||
{
|
||||
$year = date('Y', strtotime($sprint->openedDate));
|
||||
$projects[$year][$sprint->id] = $sprint;
|
||||
}
|
||||
|
||||
foreach($projects as $year => $sprints)
|
||||
{
|
||||
$project = new stdclass();
|
||||
$project->name = $year;
|
||||
$project->type = 'project';
|
||||
$project->model = 'scrum';
|
||||
$project->parent = $programID;
|
||||
$project->auth = 'extend';
|
||||
$project->begin = '';
|
||||
$project->end = '';
|
||||
$project->openedBy = $account;
|
||||
$project->openedDate = $now;
|
||||
$project->openedVersion = $this->config->version;
|
||||
$project->lastEditedBy = $account;
|
||||
$project->lastEditedDate = $now;
|
||||
$project->grade = 2;
|
||||
$project->acl = 'open';
|
||||
|
||||
$projectStatus = 'closed';
|
||||
foreach($sprints as $sprint)
|
||||
{
|
||||
if(!$project->begin || $sprint->begin < $project->begin) $project->begin = $sprint->begin;
|
||||
if(!$project->end || $sprint->end > $project->end) $project->end = $sprint->end;
|
||||
if($sprint->status != 'closed') $projectStatus = 'doing';
|
||||
}
|
||||
$project->status = $projectStatus;
|
||||
$project->days = $this->computeDaysDelta($project->begin, $project->end);
|
||||
|
||||
$this->dao->insert(TABLE_PROJECT)->data($project)->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$projectID = $this->dao->lastInsertId();
|
||||
|
||||
$this->action->create('project', $projectID, 'openedbysystem');
|
||||
if($project->status == 'closed') $this->action->create('project', $projectID, 'closedbysystem');
|
||||
|
||||
$project->id = $projectID;
|
||||
$this->createProjectDocLib($project);
|
||||
|
||||
$productIdList = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->in(array_keys($sprints))->fetchPairs();
|
||||
$this->processMergedData($programID, $projectID, '', $productIdList, array_keys($sprints));
|
||||
}
|
||||
|
||||
$this->fixProjectPath($programID);
|
||||
|
||||
$productIdList = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq('0')->fetchPairs();
|
||||
$this->computeProductAcl($productIdList, $programID, 0);
|
||||
|
||||
if(dao::isError()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sprints has not been merged.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getNoMergedSprints()
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PROJECT)
|
||||
->where('project')->eq(0)
|
||||
->andWhere('vision')->eq('rnd')
|
||||
->andWhere('type')->eq('sprint')
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create doc lib for project.
|
||||
*
|
||||
* @param object $project
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createProjectDocLib($project)
|
||||
{
|
||||
$this->app->loadLang('doc');
|
||||
|
||||
$lib = new stdclass();
|
||||
$lib->project = $project->id;
|
||||
$lib->name = $this->lang->doclib->main['project'];
|
||||
$lib->type = 'project';
|
||||
$lib->main = '1';
|
||||
$lib->acl = $project->acl != 'program' ? $project->acl : 'custom';
|
||||
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the project path under the program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function fixProjectPath($programID)
|
||||
{
|
||||
$this->dao->update(TABLE_PROJECT)
|
||||
->set("path = CONCAT(',{$programID},', id, ',')")->set("`order` = `id` * 5")
|
||||
->where('type')->eq('project')
|
||||
->andWhere('parent')->eq($programID)
|
||||
->andWhere('grade')->eq('2')
|
||||
->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relate default program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function relateDefaultProgram($programID)
|
||||
{
|
||||
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($programID)->where('program')->eq(0)->exec();
|
||||
|
||||
$this->dao->update(TABLE_MODULE)->set('root')->eq($programID)->where('type')->eq('line')->andWhere('root')->eq('0')->exec();
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->set('parent')->eq($programID)->set("path = CONCAT(',{$programID}', path)")->set('grade = grade + 1')->where('type')->eq('project')->andWhere('parent')->eq(0)->andWhere('grade')->eq(1)->exec();
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check history data form light mode.
|
||||
* 检查轻量管理模式历史数据是否存在
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function checkHistoryDataForLightMode()
|
||||
{
|
||||
$returnData = array(
|
||||
'ur' => false,
|
||||
'cmmi' => false,
|
||||
'waterfall' => false,
|
||||
'assetlib' => false,
|
||||
);
|
||||
|
||||
if($this->config->systemMode == 'ALM')
|
||||
{
|
||||
/* User requriement */
|
||||
$requirementStory = $this->dao->select('count(1) as total')->from(TABLE_STORY)->where('type')->eq('requirement')->andWhere('deleted')->eq('0')->fetch('total');
|
||||
if($requirementStory > 0) $returnData['ur'] = true;
|
||||
if($this->config->edition == 'max')
|
||||
{
|
||||
/* issue,risk,opportunity,process,QA,meeting */
|
||||
$issue = $this->dao->select('count(1) as total')->from(TABLE_ISSUE)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($issue > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
$risk = $this->dao->select('count(1) as total')->from(TABLE_RISK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($risk > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
$opportunity = $this->dao->select('count(1) as total')->from(TABLE_OPPORTUNITY)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($opportunity > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
$process = $this->dao->select('count(1) as total')->from(TABLE_PROCESS)
|
||||
->where('deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($process > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
$auditplans = $this->dao->select('count(1) as total')->from(TABLE_AUDITPLAN)
|
||||
->where('deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($auditplans > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
|
||||
$meeting = $this->dao->select('count(1) as total')->from(TABLE_MEETING)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($meeting > 0)
|
||||
{
|
||||
$returnData['cmmi'] = true;
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
next:
|
||||
/* Waterfull mode */
|
||||
$waterfull = $this->dao->select('count(1) as total')->from(TABLE_PROJECT)
|
||||
->where('model')->eq('waterfall')
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($waterfull > 0) $returnData['waterfall'] = true;
|
||||
|
||||
if($this->config->edition == 'max')
|
||||
{
|
||||
/* assetlib */
|
||||
$assetlib = $this->dao->select('count(1) as total')->from(TABLE_ASSETLIB)
|
||||
->where('deleted')->eq(0)
|
||||
->fetch('total');
|
||||
if($assetlib > 0) $returnData['assetlib'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the owner of the program into the product view.
|
||||
*
|
||||
* @access public
|
||||
|
||||
Reference in New Issue
Block a user