* auto set stage.
This commit is contained in:
@@ -77,9 +77,11 @@ class productplanModel extends model
|
||||
/* 关联需求。*/
|
||||
public function linkStory($planID)
|
||||
{
|
||||
$this->loadModel('story');
|
||||
foreach($this->post->stories as $storyID)
|
||||
{
|
||||
$this->dao->update(TABLE_STORY)->set('plan')->eq((int)$planID)->where('id')->eq((int)$storyID)->exec();
|
||||
$this->story->setStage($storyID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,5 +89,6 @@ class productplanModel extends model
|
||||
public function unlinkStory($storyID)
|
||||
{
|
||||
$this->dao->update(TABLE_STORY)->set('plan')->eq(0)->where('id')->eq((int)$storyID)->exec();
|
||||
$this->loadModel('story')->setStage($storyID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ class projectModel extends model
|
||||
public function linkStory($projectID)
|
||||
{
|
||||
if($this->post->stories == false) return false;
|
||||
$this->loadModel('story');
|
||||
foreach($this->post->stories as $key => $storyID)
|
||||
{
|
||||
$productID = $this->post->products[$key];
|
||||
@@ -187,6 +188,7 @@ class projectModel extends model
|
||||
->set('product')->eq($productID)
|
||||
->set('story')->eq($storyID)
|
||||
->exec();
|
||||
$this->story->setStage($storyID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +196,7 @@ class projectModel extends model
|
||||
public function unlinkStory($projectID, $storyID)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('story')->eq($storyID)->limit(1)->exec();
|
||||
$this->loadModel('story')->setStage($storyID);
|
||||
}
|
||||
|
||||
/* 获取团队成员。*/
|
||||
|
||||
@@ -222,6 +222,7 @@ class storyModel extends model
|
||||
$this->dao->delete()->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($oldStory->version)->exec();
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->eq($storyID)->andWhere('extra')->eq($oldStory->version)->exec();
|
||||
}
|
||||
$this->setStage($storyID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -274,6 +275,72 @@ class storyModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 设置需求的*/
|
||||
public function setStage($storyID, $customStage = '')
|
||||
{
|
||||
/* 指定了customStage,以其为准。*/
|
||||
if($customStage)
|
||||
{
|
||||
$this->dao->update(TABLE_STORY)->set('stage')->eq($customStage)->where('id')->eq((int)$storyID)->exec();
|
||||
return;
|
||||
}
|
||||
|
||||
/* 查找活动的项目。*/
|
||||
$projects = $this->dao->select('project')
|
||||
->from(TABLE_PROJECTSTORY)->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
|
||||
->where('t1.story')->eq((int)$storyID)
|
||||
->andWhere('t2.status')->eq('doing')
|
||||
->fetchPairs();
|
||||
|
||||
/* 如果没有项目,但有计划,则阶段为planned或wait。*/
|
||||
if(!$projects)
|
||||
{
|
||||
$this->dao->update(TABLE_STORY)->set('stage')->eq('planned')->where('id')->eq((int)$storyID)->andWhere('plan')->gt(0)->exec();
|
||||
$this->dao->update(TABLE_STORY)->set('stage')->eq('wait')->where('id')->eq((int)$storyID)->andWhere('plan')->eq(0)->andWhere('status')->eq('active')->exec();
|
||||
return;
|
||||
}
|
||||
/* 查找对应的任务。*/
|
||||
$tasks = $this->dao->select('type,status')->from(TABLE_TASK)->where('project')->in($projects)->andWhere('story')->eq($storyID)->fetchGroup('type');
|
||||
|
||||
/* 没有任务,则所处阶段为'已经立项'。*/
|
||||
if(!$tasks)
|
||||
{
|
||||
$this->dao->update(TABLE_STORY)->set('stage')->eq('projected')->where('id')->eq((int)$storyID)->exec();
|
||||
return;
|
||||
}
|
||||
|
||||
/* 如果有测试任务。*/
|
||||
if(isset($tasks['test']))
|
||||
{
|
||||
$stage = 'tested';
|
||||
foreach($tasks['test'] as $task)
|
||||
{
|
||||
if($task->status != 'done')
|
||||
{
|
||||
$stage = 'testing';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$stage = 'developed';
|
||||
foreach($tasks as $type => $typeTasks)
|
||||
{
|
||||
foreach($typeTasks as $task)
|
||||
{
|
||||
if($task->status != 'done')
|
||||
{
|
||||
$stage = 'developing';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->dao->update(TABLE_STORY)->set('stage')->eq($stage)->where('id')->eq((int)$storyID)->exec();
|
||||
return;
|
||||
}
|
||||
|
||||
/* 获得某一个产品某一个模块下面的所有需求列表。*/
|
||||
public function getProductStories($productID = 0, $moduleIds = 0, $status = 'all', $orderBy = 'id|desc', $pager = null)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ class taskModel extends model
|
||||
->check('name', 'notempty')
|
||||
->checkIF($task->estimate != '', 'estimate', 'float')
|
||||
->exec();
|
||||
if($this->post->story) $this->loadModel('story')->setStage($this->post->story);
|
||||
if(!dao::isError()) return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
@@ -69,13 +70,17 @@ class taskModel extends model
|
||||
->checkIF($task->left != false, 'left', 'float')
|
||||
->checkIF($task->consumed != false, 'consumed', 'float')
|
||||
->where('id')->eq((int)$taskID)->exec();
|
||||
if($this->post->story) $this->loadModel('story')->setStage($this->post->story);
|
||||
if(!dao::isError()) return common::createChanges($oldTask, $task);
|
||||
}
|
||||
|
||||
/* 删除一个任务。*/
|
||||
public function delete($taskID)
|
||||
{
|
||||
return $this->dao->delete()->from(TABLE_TASK)->where('id')->eq((int)$taskID)->limit(1)->exec();
|
||||
$story = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($taskID)->fetch('story');
|
||||
$this->dao->delete()->from(TABLE_TASK)->where('id')->eq((int)$taskID)->limit(1)->exec();
|
||||
if($story) $this->loadModel('story')->setStage($story);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 通过id获取一个任务信息。*/
|
||||
|
||||
Reference in New Issue
Block a user