* Revert commit.
This commit is contained in:
+24
-204
@@ -100,8 +100,7 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目中的阶段数据键值对。
|
||||
* Get plan pairs in the project.
|
||||
* Get pairs.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param int $productID
|
||||
@@ -109,7 +108,7 @@ class programplanModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPairs(int $executionID, int $productID = 0, string $type = 'all'): array
|
||||
public function getPairs($executionID, $productID = 0, $type = 'all')
|
||||
{
|
||||
$plans = $this->getStage($executionID, $productID, $type);
|
||||
|
||||
@@ -125,14 +124,12 @@ class programplanModel extends model
|
||||
{
|
||||
if(strpos($type, 'leaf') !== false and isset($parents[$plan->id])) continue;
|
||||
|
||||
$paths = array_slice(explode(',', trim($plan->path, ',')), 1);
|
||||
$paths = array_slice(explode(',', trim($plan->path, ',')), 1);
|
||||
$planName = '';
|
||||
|
||||
foreach($paths as $path)
|
||||
{
|
||||
if(isset($plans[$path])) $planName .= '/' . $plans[$path]->name;
|
||||
}
|
||||
|
||||
$pairs[$planID] = $planName;
|
||||
}
|
||||
|
||||
@@ -158,176 +155,34 @@ class programplanModel extends model
|
||||
|
||||
$plans = $this->getStage($executionID, $productID, 'all', 'order');
|
||||
|
||||
if($baselineID) $plans = $this->setBaseline($baselineID, $plans);
|
||||
|
||||
$today = helper::today();
|
||||
$datas = array();
|
||||
$planIdList = array();
|
||||
$isMilestone = "<icon class='icon icon-flag icon-sm red'></icon> ";
|
||||
$stageIndex = array();
|
||||
foreach($plans as $plan)
|
||||
if($baselineID)
|
||||
{
|
||||
$planIdList[$plan->id] = $plan->id;
|
||||
|
||||
$start = helper::isZeroDate($plan->begin) ? '' : $plan->begin;
|
||||
$end = helper::isZeroDate($plan->end) ? '' : $plan->end;
|
||||
$realBegan = helper::isZeroDate($plan->realBegan) ? '' : $plan->realBegan;
|
||||
$realEnd = helper::isZeroDate($plan->realEnd) ? '' : $plan->realEnd;
|
||||
|
||||
$data = new stdclass();
|
||||
$data->id = $plan->id;
|
||||
$data->type = 'plan';
|
||||
$data->text = empty($plan->milestone) ? $plan->name : $plan->name . $isMilestone ;
|
||||
$data->name = $plan->name;
|
||||
if(isset($this->config->setPercent) and $this->config->setPercent == 1) $data->percent = $plan->percent;
|
||||
$data->attribute = zget($this->lang->stage->typeList, $plan->attribute);
|
||||
$data->milestone = zget($this->lang->programplan->milestoneList, $plan->milestone);
|
||||
$data->owner_id = $plan->PM;
|
||||
$data->status = $this->processStatus('execution', $plan);
|
||||
$data->begin = $start;
|
||||
$data->deadline = $end;
|
||||
$data->realBegan = $realBegan ? substr($realBegan, 0, 10) : '';
|
||||
$data->realEnd = $realEnd ? substr($realEnd, 0, 10) : '';;
|
||||
$data->parent = $plan->grade == 1 ? 0 :$plan->parent;
|
||||
$data->open = true;
|
||||
$data->start_date = $realBegan ? $realBegan : $start;
|
||||
$data->endDate = $realEnd ? $realEnd : $end;
|
||||
$data->duration = 1;
|
||||
$data->color = $this->lang->execution->gantt->stage->color;
|
||||
$data->progressColor = $this->lang->execution->gantt->stage->progressColor;
|
||||
$data->textColor = $this->lang->execution->gantt->stage->textColor;
|
||||
$data->bar_height = $this->lang->execution->gantt->bar_height;
|
||||
|
||||
/* Determines if the object is delay. */
|
||||
$data->delay = $this->lang->programplan->delayList[0];
|
||||
$data->delayDays = 0;
|
||||
if($today > $end)
|
||||
{
|
||||
$data->delay = $this->lang->programplan->delayList[1];
|
||||
$data->delayDays = helper::diffDate($today, substr($end, 0, 10));
|
||||
}
|
||||
|
||||
if($data->endDate > $data->start_date) $data->duration = helper::diffDate(substr($data->endDate, 0, 10), substr($data->start_date, 0, 10)) + 1;
|
||||
if($data->start_date) $data->start_date = date('d-m-Y', strtotime($data->start_date));
|
||||
if($data->start_date == '' or $data->endDate == '') $data->duration = 1;
|
||||
|
||||
$datas['data'][$plan->id] = $data;
|
||||
$stageIndex[$plan->id] = array('planID' => $plan->id, 'parent' => $plan->parent, 'progress' => array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalReal' => 0));
|
||||
/* Set plan baseline. */
|
||||
$baseline = $this->loadModel('cm')->getByID($baselineID);
|
||||
$oldData = json_decode($baseline->data);
|
||||
$oldPlans = $oldData->stage;
|
||||
$plans = $this->programplanTao->setPlanBaseline($oldPlans, $plans);
|
||||
}
|
||||
|
||||
$taskPri = "<span class='label-pri label-pri-%s' title='%s'>%s</span> ";
|
||||
$datas = $planIdList = $stageIndex = array();
|
||||
|
||||
/* Set plan for gantt view. */
|
||||
$this->programplanTao->setPlan($plans, $datas, $stageIndex, $planIdList);
|
||||
|
||||
/* Judge whether to display tasks under the stage. */
|
||||
$owner = $this->app->user->account;
|
||||
$module = 'programplan';
|
||||
$section = 'browse';
|
||||
$object = 'stageCustom';
|
||||
$owner = $this->app->user->account;
|
||||
if(empty($selectCustom)) $selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module=programplan§ion=browse&key=stageCustom");
|
||||
|
||||
if(empty($selectCustom)) $selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('execution')->in($planIdList)->orderBy('execution_asc, order_asc, id_desc')->fetchAll('id');
|
||||
$taskTeams = $this->dao->select('task,account')->from(TABLE_TASKTEAM)->where('task')->in(array_keys($tasks))->fetchGroup('task', 'account');
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('execution')->in($planIdList)->orderBy('execution_asc, order_asc, id_desc')->fetchAll('id');
|
||||
|
||||
if($baselineID)
|
||||
{
|
||||
$oldTasks = $oldData->task;
|
||||
foreach($oldTasks as $id => $oldTask)
|
||||
{
|
||||
if(!isset($tasks[$id])) continue;
|
||||
$tasks[$id]->version = $oldTask->version;
|
||||
$tasks[$id]->name = $oldTask->name;
|
||||
$tasks[$id]->estStarted = $oldTask->estStarted;
|
||||
$tasks[$id]->deadline = $oldTask->deadline;
|
||||
}
|
||||
$this->programplanTao->setTaskBaseline($oldTasks, $tasks); // Set task baseline.
|
||||
}
|
||||
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
$execution = zget($plans, $task->execution, array());
|
||||
$priIcon = sprintf($taskPri, $task->pri, $task->pri, $task->pri);
|
||||
|
||||
$estStart = helper::isZeroDate($task->estStarted) ? '' : $task->estStarted;
|
||||
$estEnd = helper::isZeroDate($task->deadline) ? '' : $task->deadline;
|
||||
$realBegan = helper::isZeroDate($task->realStarted) ? '' : $task->realStarted;
|
||||
$realEnd = (in_array($task->status, array('done', 'closed')) and !helper::isZeroDate($task->finishedDate)) ? $task->finishedDate : '';
|
||||
|
||||
$start = $realBegan ? $realBegan : $estStart;
|
||||
$end = $realEnd ? $realEnd : $estEnd;
|
||||
if(empty($start) and $execution) $start = $execution->begin;
|
||||
if(empty($end) and $execution) $end = $execution->end;
|
||||
if($start > $end) $end = $start;
|
||||
|
||||
$data = new stdclass();
|
||||
$data->id = $task->execution . '-' . $task->id;
|
||||
$data->type = 'task';
|
||||
$data->text = $priIcon . $task->name;
|
||||
$data->percent = '';
|
||||
$data->status = $this->processStatus('task', $task);
|
||||
$data->owner_id = $task->assignedTo;
|
||||
$data->attribute = '';
|
||||
$data->milestone = '';
|
||||
$data->begin = $start;
|
||||
$data->deadline = $end;
|
||||
$data->realBegan = $realBegan ? substr($realBegan, 0, 10) : '';
|
||||
$data->realEnd = $realEnd ? substr($realEnd, 0, 10) : '';
|
||||
$data->pri = $task->pri;
|
||||
$data->parent = $task->parent > 0 ? $task->execution . '-' . $task->parent : $task->execution;
|
||||
$data->open = true;
|
||||
$progress = $task->consumed ? round($task->consumed / ($task->left + $task->consumed), 3) : 0;
|
||||
$data->progress = $progress;
|
||||
$data->taskProgress = ($progress * 100) . '%';
|
||||
$data->start_date = $start;
|
||||
$data->endDate = $end;
|
||||
$data->duration = 1;
|
||||
$data->estimate = $task->estimate;
|
||||
$data->consumed = $task->consumed;
|
||||
$data->color = zget($this->lang->execution->gantt->color, $task->pri, $this->lang->execution->gantt->defaultColor);
|
||||
$data->progressColor = zget($this->lang->execution->gantt->progressColor, $task->pri, $this->lang->execution->gantt->defaultProgressColor);
|
||||
$data->textColor = zget($this->lang->execution->gantt->textColor, $task->pri, $this->lang->execution->gantt->defaultTextColor);
|
||||
$data->bar_height = $this->lang->execution->gantt->bar_height;
|
||||
|
||||
/* Determines if the object is delay. */
|
||||
$data->delay = $this->lang->programplan->delayList[0];
|
||||
$data->delayDays = 0;
|
||||
if($today > $end)
|
||||
{
|
||||
$data->delay = $this->lang->programplan->delayList[1];
|
||||
$data->delayDays = helper::diffDate($today, substr($end, 0, 10));
|
||||
}
|
||||
|
||||
/* If multi task then show the teams. */
|
||||
if($task->mode == 'multi' and !empty($taskTeams[$task->id]))
|
||||
{
|
||||
$teams = array_keys($taskTeams[$task->id]);
|
||||
$assigneds = array();
|
||||
foreach($teams as $assignedTo) $assigneds[] = zget($users, $assignedTo);
|
||||
$data->owner_id = join(',', $assigneds);
|
||||
}
|
||||
|
||||
if($data->endDate > $data->start_date) $data->duration = helper::diffDate(substr($data->endDate, 0, 10), substr($data->start_date, 0, 10)) + 1;
|
||||
if($data->start_date) $data->start_date = date('d-m-Y', strtotime($data->start_date));
|
||||
if($data->start_date == '' or $data->endDate == '') $data->duration = 1;
|
||||
|
||||
if(strpos($selectCustom, 'task') !== false) $datas['data'][$data->id] = $data;
|
||||
foreach($stageIndex as $index => $stage)
|
||||
{
|
||||
if($stage['planID'] == $task->execution)
|
||||
{
|
||||
$stageIndex[$index]['progress']['totalEstimate'] += $task->estimate;
|
||||
$stageIndex[$index]['progress']['totalConsumed'] += $task->parent == '-1' ? 0 : $task->consumed;
|
||||
$stageIndex[$index]['progress']['totalReal'] += ($task->left + $task->consumed);
|
||||
|
||||
$parent = $stage['parent'];
|
||||
if(isset($stageIndex[$parent]))
|
||||
{
|
||||
$stageIndex[$parent]['progress']['totalEstimate'] += $task->estimate;
|
||||
$stageIndex[$parent]['progress']['totalConsumed'] += $task->parent == '-1' ? 0 : $task->consumed;
|
||||
$stageIndex[$parent]['progress']['totalReal'] += ($task->left + $task->consumed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Set task for gantt view. */
|
||||
$this->programplanTao->setTask($tasks, $plans, $selectCustom, $datas, $stageIndex);
|
||||
|
||||
/* Calculate the progress of the phase. */
|
||||
foreach($stageIndex as $index => $stage)
|
||||
@@ -341,50 +196,12 @@ class programplanModel extends model
|
||||
$datas['data'][$index]->consumed = $stage['progress']['totalConsumed'];
|
||||
}
|
||||
|
||||
$datas['links'] = array();
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$relations = $this->dao->select('*')->from(TABLE_RELATIONOFTASKS)->where('execution')->in($planIdList)->orderBy('task,pretask')->fetchAll();
|
||||
foreach($relations as $relation)
|
||||
{
|
||||
$link['source'] = $relation->execution . '-' . $relation->pretask;
|
||||
$link['target'] = $relation->execution . '-' . $relation->task;
|
||||
$link['type'] = $this->config->execution->gantt->linkType[$relation->condition][$relation->action];
|
||||
$datas['links'][] = $link;
|
||||
}
|
||||
}
|
||||
$datas = $this->setRelationTask($planIdList, $datas);
|
||||
|
||||
$datas['data'] = isset($datas['data']) ? array_values($datas['data']) : array();
|
||||
return $returnJson ? json_encode($datas) : $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取基线数据。
|
||||
* Get baseline data.
|
||||
*
|
||||
* @param int $baselineID
|
||||
* @param array $plans
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function setBaseline(int $baselineID, array $plans): array
|
||||
{
|
||||
$baseline = $this->loadModel('cm')->getByID($baselineID);
|
||||
$oldData = json_decode($baseline->data);
|
||||
$oldPlans = $oldData->stage;
|
||||
foreach($oldPlans as $id => $oldPlan)
|
||||
{
|
||||
if(!isset($plans[$id])) continue;
|
||||
$plans[$id]->version = $oldPlan->version;
|
||||
$plans[$id]->name = $oldPlan->name;
|
||||
$plans[$id]->milestone = $oldPlan->milestone;
|
||||
$plans[$id]->begin = $oldPlan->begin;
|
||||
$plans[$id]->end = $oldPlan->end;
|
||||
}
|
||||
|
||||
return $plans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gantt data group by assigned.
|
||||
*
|
||||
@@ -1253,6 +1070,8 @@ class programplanModel extends model
|
||||
common::printIcon('execution', 'delete', "planID=$plan->id&confirm=no", $plan, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -1546,13 +1365,14 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为顶级。
|
||||
* Check whether it is the top stage.
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkTopStage($planID)
|
||||
public function checkTopStage(int $planID): bool
|
||||
{
|
||||
$parentID = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($planID)->fetch('parent');
|
||||
$parentType = $this->dao->select('type')->from(TABLE_EXECUTION)->where('id')->eq($parentID)->fetch('type');
|
||||
|
||||
Reference in New Issue
Block a user