Merge branch 'master' of github.com:easysoft/zentaopms

This commit is contained in:
wangyidong
2018-10-12 14:16:04 +08:00
29 changed files with 143 additions and 102 deletions
+54 -30
View File
@@ -270,6 +270,7 @@ class taskModel extends model
{
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($parentID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($parentID)->exec();
}
return $mails;
}
@@ -429,7 +430,6 @@ class taskModel extends model
$task->lastEditedBy = $this->app->user->account;
$task->lastEditedDate = $now;
$task->parent = -1;
$this->dao->update(TABLE_TASK)->data($task)->where('id')->eq($parentID)->exec();
if(!dao::isError())
{
@@ -932,6 +932,8 @@ class taskModel extends model
$task = $this->computeHours4Multiple($oldTask, $task);
}
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
$this->dao->update(TABLE_TASK)
->data($task)
@@ -1487,7 +1489,7 @@ class taskModel extends model
->leftJoin(TABLE_TEAM)->alias('t4')->on('t4.root = t1.id')
->leftJoin(TABLE_MODULE)->alias('t5')->on('t1.module = t5.id')
->where('t1.project')->eq((int)$projectID)
->beginIF($type =='all' || is_array($type))->andWhere('t1.parent')->lt(1)->fi()
->beginIF($type == 'all' || is_array($type))->andWhere('t1.parent')->lt(1)->fi()
->beginIF($type == 'myinvolved')
->andWhere("((t4.`account` = '{$this->app->user->account}' AND t4.`type` = 'task') OR t1.`assignedTo` = '{$this->app->user->account}' OR t1.`finishedby` = '{$this->app->user->account}')")
->fi()
@@ -1519,38 +1521,57 @@ class taskModel extends model
foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team;
}
/* Select children task. */
$children = $this->dao->select('DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')
->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->leftJoin(TABLE_MODULE)->alias('t4')->on('t1.module = t4.id')
->where('t1.project')->eq((int)$projectID)
->andWhere('t1.parent')->in($taskList)
->andWhere('t1.deleted')->eq(0)
->beginIF($productID)->andWhere("((t4.root=" . (int)$productID . " and t4.type='story') OR t2.product=" . (int)$productID . ")")->fi()
->beginIF($type == 'undone')->andWhere("(t1.status = 'wait' or t1.status ='doing')")->fi()
->beginIF($type == 'needconfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->fi()
->beginIF($type == 'assignedtome')->andWhere('t1.assignedTo')->eq($this->app->user->account)->fi()
->beginIF($type == 'finishedbyme')
->andWhere('t1.finishedby', 1)->eq($this->app->user->account)
->orWhere('t1.finishedList')->like("%,{$this->app->user->account},%")
->markRight(1)
->fi()
->beginIF($type == 'delayed')->andWhere('t1.deadline')->gt('1970-1-1')->andWhere('t1.deadline')->lt(date(DT_DATE1))->andWhere('t1.status')->in('wait,doing')->fi()
->beginIF(is_array($type) or strpos(',all,undone,needconfirm,assignedtome,delayed,finishedbyme,myinvolved,', ",$type,") === false)->andWhere('t1.status')->in($type)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->orderBy("t1.$orderBy")
->fetchAll('id');
if(!empty($children))
$parents = [];
foreach($tasks as $task)
{
foreach($children as $child)
if($task->parent == -1) $parents[] = $task->id;
}
if(!empty($parents))
{
/* Select children task. */
$children = $this->dao->select('DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')
->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->leftJoin(TABLE_MODULE)->alias('t4')->on('t1.module = t4.id')
->where('t1.parent')->in($parents)
->andWhere('t1.deleted')->eq(0)
->beginIF($productID)->andWhere("((t4.root=" . (int)$productID . " and t4.type='story') OR t2.product=" . (int)$productID . ")")->fi()
->beginIF($type == 'undone')->andWhere("(t1.status = 'wait' or t1.status ='doing')")->fi()
->beginIF($type == 'needconfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->fi()
->beginIF($type == 'assignedtome')->andWhere('t1.assignedTo')->eq($this->app->user->account)->fi()
->beginIF($type == 'finishedbyme')
->andWhere('t1.finishedby', 1)->eq($this->app->user->account)
->orWhere('t1.finishedList')->like("%,{$this->app->user->account},%")
->markRight(1)
->fi()
->beginIF($type == 'delayed')->andWhere('t1.deadline')->gt('1970-1-1')->andWhere('t1.deadline')->lt(date(DT_DATE1))->andWhere('t1.status')->in('wait,doing')->fi()
->beginIF(is_array($type) or strpos(',all,undone,needconfirm,assignedtome,delayed,finishedbyme,myinvolved,', ",$type,") === false)->andWhere('t1.status')->in($type)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->orderBy("t1.$orderBy")
->fetchAll('id');
if(!empty($children))
{
$tasks[$child->parent]->children[] = $child;
foreach($children as $child)
{
$tasks[$child->parent]->children[$child->id] = $child;
}
}
}
foreach($tasks as $task)
{
if($task->parent > 0)
{
if(isset($tasks[$task->parent]))
{
$tasks[$task->parent]->children[$task->id] = $task;
unset($tasks[$task->id]);
}
}
}
return $this->processTasks($tasks);
}
@@ -1870,7 +1891,10 @@ class taskModel extends model
$task = $this->processTask($task);
if(!empty($task->children))
{
foreach($task->children as $child) $task = $this->processTask($child);
foreach($task->children as $child)
{
$tasks[$task->id]->children[$child->id] = $this->processTask($child);
}
}
}
return $tasks;