* Resolve confilict.
This commit is contained in:
@@ -13,19 +13,6 @@
|
||||
<?php
|
||||
class programplanModel extends model
|
||||
{
|
||||
/**
|
||||
* Set menu.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function setMenu($projectID, $productID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plan by id.
|
||||
*
|
||||
@@ -150,6 +137,7 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取甘特图页面数据。
|
||||
* Get gantt data.
|
||||
*
|
||||
* @param int $executionID
|
||||
@@ -160,27 +148,14 @@ class programplanModel extends model
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDataForGantt($executionID, $productID, $baselineID = 0, $selectCustom = '', $returnJson = true)
|
||||
public function getDataForGantt(int $executionID, int $productID, int $baselineID = 0, string $selectCustom = '', bool $returnJson = true): string
|
||||
{
|
||||
$this->loadModel('stage');
|
||||
$this->loadModel('execution');
|
||||
|
||||
$plans = $this->getStage($executionID, $productID, 'all', 'order');
|
||||
if($baselineID)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
if($baselineID) $plans = $this->getBaselineData($baselineID, $plans);
|
||||
|
||||
$today = helper::today();
|
||||
$datas = array();
|
||||
@@ -380,6 +355,33 @@ class programplanModel extends model
|
||||
return $returnJson ? json_encode($datas) : $datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取基线数据。
|
||||
* Get baseline data.
|
||||
*
|
||||
* @param int $baselineID
|
||||
* @param array $plans
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function getBaselineData(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.
|
||||
*
|
||||
@@ -617,11 +619,11 @@ class programplanModel extends model
|
||||
/**
|
||||
* Process plans.
|
||||
*
|
||||
* @param int $plans
|
||||
* @param array $plans
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processPlans($plans)
|
||||
private function processPlans(array $plans)
|
||||
{
|
||||
foreach($plans as $planID => $plan) $plans[$planID] = $this->processPlan($plan);
|
||||
return $plans;
|
||||
@@ -683,42 +685,60 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plan.
|
||||
* 创建/设置一个项目阶段。
|
||||
* Create/Set a project plan/phase.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param int $parentID
|
||||
* @param array $formData
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param int $parentID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function create($projectID = 0, $productID = 0, $parentID = 0)
|
||||
public function create(array $formData, int $projectID = 0, int $productID = 0, int $parentID = 0): bool
|
||||
{
|
||||
$data = (array)fixer::input('post')->get();
|
||||
extract($data);
|
||||
/* Get every value from formData without use extract(). */
|
||||
$planIDList = $formData['planIDList'];
|
||||
$names = $formData['names'];
|
||||
$PM = $formData['PM'];
|
||||
$percents = $formData['percents'];
|
||||
$attributes = $formData['attributes'];
|
||||
$acl = $formData['acl'];
|
||||
$milestone = $formData['milestone'];
|
||||
$begin = $formData['begin'];
|
||||
$end = $formData['end'];
|
||||
$realBegan = $formData['realBegan'];
|
||||
$realEnd = $formData['realEnd'];
|
||||
$desc = $formData['desc'];
|
||||
$orders = $formData['orders'];
|
||||
$type = $formData['type'];
|
||||
$codes = $formData['codes'];
|
||||
$output = $formData['output'];
|
||||
|
||||
/* Determine if a task has been created under the parent phase. */
|
||||
if(!$this->isCreateTask($parentID)) return dao::$errors['message'][] = $this->lang->programplan->error->createdTask;
|
||||
|
||||
/* The child phase type setting is the same as the parent phase. */
|
||||
$parentAttribute = '';
|
||||
$parentPercent = 0;
|
||||
if($parentID)
|
||||
{
|
||||
$parentStage = $this->getByID($parentID);
|
||||
$parentAttribute = $parentStage->attribute;
|
||||
$parentPercent = $parentStage->percent;
|
||||
$parentACL = $parentStage->acl;
|
||||
}
|
||||
|
||||
/* Remove empty items and get same items in array. */
|
||||
$names = array_filter($names);
|
||||
$sameNames = array_diff_assoc($names, array_unique($names));
|
||||
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
/* Check weather need to set code and compute same code. */
|
||||
$setCode = (isset($this->config->setCode) and $this->config->setCode == 1) ? true : false;
|
||||
$sameCodes = $setCode ? $this->checkCodeUnique($codes, isset($planIDList) ? $planIDList : '') : false;
|
||||
|
||||
/* Prepare the plans user inputted. Process the plan which names not empty only. */
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
$setPercent = (isset($this->config->setPercent) and $this->config->setPercent == 1) ? true : false;
|
||||
$datas = array();
|
||||
$plans = array();
|
||||
foreach($names as $key => $name)
|
||||
{
|
||||
if(empty($name)) continue;
|
||||
@@ -729,8 +749,6 @@ class programplanModel extends model
|
||||
$plan->project = $projectID;
|
||||
$plan->parent = $parentID ? $parentID : $projectID;
|
||||
$plan->name = $names[$key];
|
||||
if($setCode) $plan->code = $codes[$key];
|
||||
if($setPercent) $plan->percent = $percents[$key];
|
||||
$plan->attribute = (empty($parentID) or $parentAttribute == 'mix') ? $attributes[$key] : $parentAttribute;
|
||||
$plan->milestone = $milestone[$key];
|
||||
$plan->output = empty($output[$key]) ? '' : implode(',', $output[$key]);
|
||||
@@ -738,25 +756,26 @@ class programplanModel extends model
|
||||
$plan->PM = empty($PM[$key]) ? '' : $PM[$key];
|
||||
$plan->desc = empty($desc[$key]) ? '' : $desc[$key];
|
||||
$plan->hasProduct = $project->hasProduct;
|
||||
if($setCode) $plan->code = $codes[$key];
|
||||
if($setPercent) $plan->percent = $percents[$key];
|
||||
|
||||
if(!empty($begin[$key])) $plan->begin = $begin[$key];
|
||||
if(!empty($end[$key])) $plan->end = $end[$key];
|
||||
if(!empty($realBegan[$key])) $plan->realBegan = $realBegan[$key];
|
||||
if(!empty($realEnd[$key])) $plan->realEnd = $realEnd[$key];
|
||||
|
||||
$datas[] = $plan;
|
||||
$plans[] = $plan;
|
||||
}
|
||||
|
||||
if(empty($datas))
|
||||
if(empty($plans))
|
||||
{
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->programplan->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
$totalPercent = 0;
|
||||
$totalDevType = 0;
|
||||
$milestone = 0;
|
||||
foreach($datas as $index => $plan)
|
||||
foreach($plans as $index => $plan)
|
||||
{
|
||||
if(!empty($sameNames) and in_array($plan->name, $sameNames)) dao::$errors[$index]['name'] = empty($type) ? $this->lang->programplan->error->sameName : str_replace($this->lang->execution->stage, '', $this->lang->programplan->error->sameName);
|
||||
if($setCode and $sameCodes !== true and !empty($sameCodes) and in_array($plan->code, $sameCodes)) dao::$errors[$index]['code'] = sprintf($this->lang->error->repeat, $plan->type == 'stage' ? $this->lang->execution->code : $this->lang->code, $plan->code);
|
||||
@@ -838,7 +857,7 @@ class programplanModel extends model
|
||||
|
||||
if(!isset($orders)) $orders = array();
|
||||
asort($orders);
|
||||
if(count($orders) < count($datas))
|
||||
if(count($orders) < count($plans))
|
||||
{
|
||||
$orderIndex = empty($orders) ? 0 : count($orders);
|
||||
$lastID = $this->dao->select('id')->from(TABLE_EXECUTION)->orderBy('id_desc')->fetch('id');
|
||||
@@ -1602,13 +1621,14 @@ class programplanModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阶段同一层级信息。
|
||||
* Get plan's siblings.
|
||||
*
|
||||
* @param string|int|array $planIdList
|
||||
* @param string|int|array $planIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSiblings($planIdList)
|
||||
public function getSiblings(array|string|int $planIdList): array
|
||||
{
|
||||
if(is_numeric($planIdList)) $planIdList = (array)$planIdList;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user