Merge branch 'master' into zentaopms_239
This commit is contained in:
@@ -169,6 +169,7 @@ class programplanModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$today = helper::today();
|
||||
$datas = array();
|
||||
$planIdList = array();
|
||||
$isMilestone = "<icon class='icon icon-flag icon-sm red'></icon> ";
|
||||
@@ -205,6 +206,15 @@ class programplanModel extends model
|
||||
$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;
|
||||
@@ -285,6 +295,15 @@ class programplanModel extends model
|
||||
$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]))
|
||||
{
|
||||
@@ -683,7 +702,15 @@ class programplanModel extends model
|
||||
return false;
|
||||
}
|
||||
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
$setCode = (!isset($this->config->setCode) or $this->config->setCode == 1) ? true : false;
|
||||
$checkCode = $this->checkCodeUnique($codes, isset($planIDList) ? $planIDList : '');
|
||||
if($setCode and $checkCode !== true)
|
||||
{
|
||||
if($checkCode) dao::$errors['message'][] = sprintf($this->lang->error->repeat, $this->lang->execution->code, $checkCode);
|
||||
else dao::$errors['message'][] = $this->lang->programplan->error->sameCode;
|
||||
return false;
|
||||
}
|
||||
|
||||
$datas = array();
|
||||
foreach($names as $key => $name)
|
||||
@@ -696,6 +723,7 @@ class programplanModel extends model
|
||||
$plan->project = $projectID;
|
||||
$plan->parent = $parentID ? $parentID : $projectID;
|
||||
$plan->name = $names[$key];
|
||||
if($setCode) $plan->code = $codes[$key];
|
||||
$plan->percent = $percents[$key];
|
||||
$plan->attribute = empty($parentID) ? $attributes[$key] : $parentAttribute;
|
||||
$plan->milestone = $milestone[$key];
|
||||
@@ -765,6 +793,11 @@ class programplanModel extends model
|
||||
|
||||
if(helper::isZeroDate($plan->begin)) $plan->begin = '';
|
||||
if(helper::isZeroDate($plan->end)) $plan->end = '';
|
||||
if($setCode and empty($plan->code))
|
||||
{
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->execution->code);
|
||||
return false;
|
||||
}
|
||||
foreach(explode(',', $this->config->programplan->create->requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
@@ -996,6 +1029,13 @@ class programplanModel extends model
|
||||
if($projectID) $this->loadModel('execution')->checkBeginAndEndDate($projectID, $plan->begin, $plan->end);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$setCode = (!isset($this->config->setCode) or $this->config->setCode == 1) ? true : false;
|
||||
if($setCode and empty($plan->code))
|
||||
{
|
||||
dao::$errors['code'][] = sprintf($this->lang->error->notempty, $this->lang->execution->code);
|
||||
return false;
|
||||
}
|
||||
|
||||
$planChanged = ($oldPlan->name != $plan->name || $oldPlan->milestone != $plan->milestone || $oldPlan->begin != $plan->begin || $oldPlan->end != $plan->end);
|
||||
|
||||
if($plan->parent > 0)
|
||||
@@ -1035,15 +1075,19 @@ class programplanModel extends model
|
||||
if($planChanged) $plan->version = $oldPlan->version + 1;
|
||||
if(empty($plan->parent)) $plan->parent = $projectID;
|
||||
|
||||
$parentStage = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($plan->parent)->andWhere('type')->eq('stage')->fetch();
|
||||
|
||||
/* Fix bug #22030. Reset field name for show dao error. */
|
||||
$this->lang->project->name = $this->lang->programplan->name;
|
||||
$this->lang->project->code = $this->lang->execution->code;
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->data($plan)
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->programplan->edit->requiredFields, 'notempty')
|
||||
->checkIF($plan->end != '0000-00-00', 'end', 'ge', $plan->begin)
|
||||
->checkIF($plan->percent != false, 'percent', 'float')
|
||||
->checkIF(!empty($plan->name), 'name', 'unique', "id != {$planID} and type in ('sprint','stage') and `project` = {$oldPlan->project}")
|
||||
->checkIF(!empty($plan->name), 'name', 'unique', "id != {$planID} and type in ('sprint','stage') and `project` = {$oldPlan->project} and `deleted` = '0'" . ($parentStage ? " and `parent` = {$oldPlan->parent}" : ''))
|
||||
->checkIF(!empty($plan->code) and $setCode, 'code', 'unique', "id != $planID and type in ('sprint','stage','kanban') and `deleted` = '0'")
|
||||
->where('id')->eq($planID)
|
||||
->exec();
|
||||
|
||||
@@ -1222,6 +1266,29 @@ class programplanModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check code unique.
|
||||
*
|
||||
* @param array $codes
|
||||
* @param array $planIDList
|
||||
* @access public
|
||||
* @return mix
|
||||
*/
|
||||
public function checkCodeUnique($codes, $planIDList)
|
||||
{
|
||||
$codes = array_filter($codes);
|
||||
if(count(array_unique($codes)) != count($codes)) return false;
|
||||
|
||||
$code = $this->dao->select('code')->from(TABLE_EXECUTION)
|
||||
->where('type')->in('sprint,stage,kanban')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('code')->in($codes)
|
||||
->beginIF($planIDList)->andWhere('id')->notin($planIDList)->fi()
|
||||
->fetch('code');
|
||||
if($code) return $code;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stage set to milestone.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user