* Fix bug#28983

This commit is contained in:
zenggang
2022-10-26 08:38:23 +00:00
parent 624ea22524
commit f3f92631e3
7 changed files with 75 additions and 1 deletions
+1
View File
@@ -107,6 +107,7 @@ $lang->programplan->error->createdTask = 'The task has been decomposed. Sub
$lang->programplan->error->parentWorkload = 'The sum of the workload of the child phase cannot be greater than that of the parent phase: %s.';
$lang->programplan->error->parentDuration = 'The planned start and planned completion of the child phase cannot exceed the parent phase.';
$lang->programplan->error->sameName = 'Stage name cannot be the same!';
$lang->programplan->error->sameCode = 'Stage code cannot be the same!';
$lang->programplan->error->taskDrag = 'The %s task cannot be dragged';
$lang->programplan->error->planDrag = 'The %s stage cannot be dragged';
+1
View File
@@ -107,6 +107,7 @@ $lang->programplan->error->createdTask = 'The task is decomposed. Sub stages
$lang->programplan->error->parentWorkload = 'The sum of the workload in the sub stage cannot be > that in the parent stage: %s.';
$lang->programplan->error->parentDuration = 'The planned start and planned completion of the child phase cannot exceed the parent phase.';
$lang->programplan->error->sameName = 'Stage name cannot be the same!';
$lang->programplan->error->sameCode = 'Stage code cannot be the same!';
$lang->programplan->error->taskDrag = 'The %s task cannot be dragged';
$lang->programplan->error->planDrag = 'The %s stage cannot be dragged';
+1
View File
@@ -107,6 +107,7 @@ $lang->programplan->error->createdTask = 'The task has been decomposed. Sub
$lang->programplan->error->parentWorkload = 'The sum of the workload of the child phase cannot be greater than that of the parent phase: %s.';
$lang->programplan->error->parentDuration = 'The planned start and planned completion of the child phase cannot exceed the parent phase.';
$lang->programplan->error->sameName = 'Stage name cannot be the same!';
$lang->programplan->error->sameCode = 'Stage code cannot be the same!';
$lang->programplan->error->taskDrag = 'The %s task cannot be dragged';
$lang->programplan->error->planDrag = 'The %s stage cannot be dragged';
+1
View File
@@ -107,6 +107,7 @@ $lang->programplan->error->createdTask = '已分解任务,不可添加子
$lang->programplan->error->parentWorkload = '子阶段的工作量之和不能大于父阶段的工作量:%s';
$lang->programplan->error->parentDuration = '子阶段计划开始、计划完成不能超过父阶段';
$lang->programplan->error->sameName = '阶段名称不能相同!';
$lang->programplan->error->sameCode = '阶段代号不能相同!';
$lang->programplan->error->taskDrag = '%s的任务不可以拖动';
$lang->programplan->error->planDrag = '%s的阶段不可以拖动';
+50 -1
View File
@@ -702,6 +702,15 @@ class programplanModel extends model
return false;
}
$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)
{
@@ -713,6 +722,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];
@@ -782,6 +792,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);
@@ -1006,6 +1021,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)
@@ -1045,15 +1067,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) and $this->config->systemMode == 'new'), 'name', 'unique', "id != {$planID} and type in ('sprint','stage') and `project` = {$oldPlan->project}")
->checkIF((!empty($plan->name) and $this->config->systemMode == 'new'), '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), 'code', 'unique', "id != $planID and type in ('sprint','stage','kanban') and `deleted` = '0'")
->where('id')->eq($planID)
->exec();
@@ -1232,6 +1258,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.
*
+15
View File
@@ -56,6 +56,9 @@
<thead>
<tr class='text-center'>
<th class='c-name required'><?php echo $name;?></th>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<th class='c-code required'><?php echo $lang->execution->code;?></th>
<?php endif;?>
<th class='c-pm <?php echo zget($visibleFields, 'PM', ' hidden') . zget($requiredFields, 'PM', '', ' required');?>'><?php echo $lang->programplan->PM;?></th>
<th class='c-percent <?php echo zget($visibleFields, 'percent', ' hidden') . zget($requiredFields, 'percent', '', ' required');?>'>
<?php echo $lang->programplan->percent;?>
@@ -82,6 +85,9 @@
<?php foreach($stages as $stage):?>
<tr>
<td><input type='text' name='names[<?php echo $i;?>]' id='names<?php echo $i;?>' value='<?php echo $stage->name;?>' class='form-control' /></td>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<td><?php echo html::input("codes[$i]", $stage->code, "class='form-control'");?></td>
<?php endif;?>
<td <?php echo zget($visibleFields, 'PM', ' hidden') . zget($requiredFields, 'PM', '', ' required');?>><?php echo html::select("PM[$i]", $PMUsers, '', "class='form-control picker-select'");?></td>
<td <?php echo zget($visibleFields, 'percent', ' hidden') . zget($requiredFields, 'percent', '', ' required');?>>
<div class='input-group'>
@@ -113,6 +119,9 @@
<?php echo html::hidden("planIDList[$i]", $plan->id);?>
<tr>
<td><input type='text' name="names[<?php echo $i;?>]" id='names<?php echo $i;?>' value='<?php echo $plan->name;?>' class='form-control' /></td>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<td><?php echo html::input("codes[$i]", $plan->code, "class='form-control'");?></td>
<?php endif;?>
<td <?php echo zget($visibleFields, 'PM', ' hidden') . zget($requiredFields, 'PM', '', ' required');?>><?php echo html::select("PM[$i]", $PMUsers, $plan->PM, "class='form-control picker-select'");?></td>
<td <?php echo zget($visibleFields, 'percent', ' hidden') . zget($requiredFields, 'percent', '', ' required');?>>
<div class='input-group'>
@@ -142,6 +151,9 @@
<?php for($j = 0; $j < 5; $j ++):?>
<tr class='addedItem'>
<td><input type='text' name='names[<?php echo $i;?>]' id='names<?php echo $i;?>' value='' class='form-control' /></td>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<td><?php echo html::input("codes[$i]", '', "class='form-control'");?></td>
<?php endif;?>
<td <?php echo zget($visibleFields, 'PM', ' hidden') . zget($requiredFields, 'PM', '', ' required');?>><?php echo html::select("PM[$i]", $PMUsers, '', "class='form-control picker-select'");?></td>
<td <?php echo zget($visibleFields, 'percent', ' hidden') . zget($requiredFields, 'percent', '', ' required');?>>
<div class='input-group'>
@@ -183,6 +195,9 @@
<table class='hidden'>
<tr id='addItem' class='hidden'>
<td><input type='text' name='<?php echo "names[$i]";?>' id='names<?php echo $i;?>' class='form-control' /></td>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<td><?php echo html::input("codes[$i]", '', "class='form-control'");?></td>
<?php endif;?>
<td <?php echo zget($visibleFields, 'PM', ' hidden') . zget($requiredFields, 'PM', '', ' required');?>><?php echo html::select("PM[$i]", $PMUsers, '', "class='form-control' id='PM$i'");?></td>
<?php echo html::hidden("planIDList[$i]", 0);?>
<td <?php echo zget($visibleFields, 'percent', ' hidden') . zget($requiredFields, 'percent', '', ' required');?>>
+6
View File
@@ -31,6 +31,12 @@
<th class='w-100px'><?php echo $lang->programplan->name;?> </th>
<td colspan='2'><?php echo html::input('name', $plan->name, "class='form-control'");?></td>
</tr>
<?php if(!isset($config->setCode) or $config->setCode == 1):?>
<tr>
<th class='w-100px'><?php echo $lang->execution->code;?> </th>
<td class='required' colspan='2'><?php echo html::input('code', $plan->code, "class='form-control'");?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->programplan->percent;?> </th>
<td colspan='2'>