* Modify the batch editing plan logic.

This commit is contained in:
tianshujie
2021-12-31 15:49:44 +08:00
parent 1f1e56c28f
commit 39a8417b61
4 changed files with 81 additions and 50 deletions
+15 -11
View File
@@ -111,22 +111,26 @@ $lang->productplan->endList[93] = '3 Months';
$lang->productplan->endList[186] = '6 Months';
$lang->productplan->endList[365] = '1 Year';
$lang->productplan->errorNoTitle = 'ID %s title should not be empty.';
$lang->productplan->errorNoBegin = 'ID %s begin time should not be empty.';
$lang->productplan->errorNoEnd = 'ID %s end time should not be empty.';
$lang->productplan->beginGeEnd = 'ID %s begin time should not be >= end time.';
$lang->productplan->beginLetterParent = "The start date of the parent plan: %s, the start date cannot be less than the start date of the parent plan.";
$lang->productplan->endGreaterParent = "The completion date of the parent plan: %s, the completion date cannot be greater than the completion date of the parent plan.";
$lang->productplan->beginGreaterChild = "The start date of the child plan: %s, the start date cannot be greater than the start date of the child plan.";
$lang->productplan->endLetterChild = "The completion date of the child plan: %s, the completion date cannot be less than the completion date of the child plan.";
$lang->productplan->noLinkedProject = "The current product has not been linked with a project. Please enter the list of the product to link or create a project.";
$lang->productplan->enterProjectList = "Enter the list of the product";
$lang->productplan->errorNoTitle = 'ID %s title should not be empty.';
$lang->productplan->errorNoBegin = 'ID %s begin time should not be empty.';
$lang->productplan->errorNoEnd = 'ID %s end time should not be empty.';
$lang->productplan->beginGeEnd = 'ID %s begin time should not be >= end time.';
$lang->productplan->beginLetterParent = "The start date of the parent plan: %s, the start date cannot be less than the start date of the parent plan.";
$lang->productplan->endGreaterParent = "The completion date of the parent plan: %s, the completion date cannot be greater than the completion date of the parent plan.";
$lang->productplan->beginGreaterChild = "The start date of the child plan: %s, the start date cannot be greater than the start date of the child plan.";
$lang->productplan->endLetterChild = "The completion date of the child plan: %s, the completion date cannot be less than the completion date of the child plan.";
$lang->productplan->noLinkedProject = "The current product has not been linked with a project. Please enter the list of the product to link or create a project.";
$lang->productplan->enterProjectList = "Enter the list of the product";
$lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s]: %s, cannot be greater than the start date of the child plan: %s.";
$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.", ;
$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s.";
$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s.";
$lang->productplan->featureBar['browse']['all'] = 'All';
$lang->productplan->featureBar['browse']['wait'] = 'Waiting';
$lang->productplan->featureBar['browse']['closed'] = 'Closed';
$lang->productplan->featureBar['browse']['doing'] = 'Doing';
$lang->productplan->featureBar['browse']['done'] = 'Done';
$lang->productplan->featureBar['browse']['closed'] = 'Closed';
$lang->productplan->orderList['begin_desc'] = 'Begin Descend';
$lang->productplan->orderList['begin_asc'] = 'Begin Ascend';
+14 -10
View File
@@ -111,16 +111,20 @@ $lang->productplan->endList[93] = '三个月';
$lang->productplan->endList[186] = '半年';
$lang->productplan->endList[365] = '一年';
$lang->productplan->errorNoTitle = 'ID %s 标题不能为空';
$lang->productplan->errorNoBegin = 'ID %s 开始时间不能为空';
$lang->productplan->errorNoEnd = 'ID %s 结束时间不能为空';
$lang->productplan->beginGeEnd = 'ID %s 开始时间不能大于结束时间';
$lang->productplan->beginLetterParent = "父计划的开始日期:%s,开始日期不能小于父计划的开始日期";
$lang->productplan->endGreaterParent = "父计划的完成日期:%s,完成日期不能大于父计划的完成日期";
$lang->productplan->beginGreaterChild = "子计划的开始日期:%s,开始日期不能大于子计划的开始日期";
$lang->productplan->endLetterChild = "子计划的完成日期:%s,完成日期不能小于子计划的完成日期";
$lang->productplan->noLinkedProject = "当前产品还未关联项目,请进入产品的项目列表关联或创建一个项目";
$lang->productplan->enterProjectList = "进入产品的项目列表";
$lang->productplan->errorNoTitle = 'ID %s 标题不能为空';
$lang->productplan->errorNoBegin = 'ID %s 开始时间不能为空';
$lang->productplan->errorNoEnd = 'ID %s 结束时间不能为空';
$lang->productplan->beginGeEnd = 'ID %s 开始时间不能大于结束时间';
$lang->productplan->beginLetterParent = "父计划的开始日期:%s,开始日期不能小于父计划的开始日期";
$lang->productplan->endGreaterParent = "父计划的完成日期:%s,完成日期不能大于父计划的完成日期";
$lang->productplan->beginGreaterChild = "子计划的开始日期:%s,开始日期不能大于子计划的开始日期";
$lang->productplan->endLetterChild = "子计划的完成日期:%s,完成日期不能小于子计划的完成日期";
$lang->productplan->noLinkedProject = "当前产品还未关联项目,请进入产品的项目列表关联或创建一个项目";
$lang->productplan->enterProjectList = "进入产品的项目列表";
$lang->productplan->beginGreaterChildTip = "父计划[%s]的开始日期:%s,不能大于子计划的开始日期: %s";
$lang->productplan->endLetterChildTip = "父计划[%s]的完成日期:%s,不能小于子计划的完成日期: %s";
$lang->productplan->beginLetterParentTip = "子计划[%s]的开始日期:%s,不能小于父计划的开始日期: %s";
$lang->productplan->endGreaterParentTip = "子计划[%s]的完成日期:%s,不能大于父计划的完成日期: %s";
$lang->productplan->featureBar['browse']['all'] = '所有';
$lang->productplan->featureBar['browse']['wait'] = '未开始';
+49 -26
View File
@@ -629,7 +629,7 @@ class productplanModel extends model
*/
public function batchUpdate($productID)
{
$data = fixer::input('post')->skipSpecial('desc')->get();
$data = fixer::input('post')->skipSpecial('desc')->get();
$oldPlans = $this->getByIDList($data->id);
$this->app->loadClass('purifier', true);
@@ -641,35 +641,28 @@ class productplanModel extends model
$extendFields = $this->getFlowExtendFields();
foreach($data->id as $planID)
{
$plan = new stdclass();
$plan->branch = $data->branch[$planID];
$plan->title = $data->title[$planID];
$plan->desc = $purifier->purify($data->desc[$planID]);
$plan->begin = $data->begin[$planID] == '' ? '2030-01-01' : $data->begin[$planID];
$plan->end = $data->end[$planID] == '' ? '2030-01-01' : $data->end[$planID];
$plan->status = $data->status[$planID];
if($plan->status == 'wait' and !isset($data->future[$planID])) $data->future[$planID] = 'on';
$isFuture = isset($data->future[$planID]) ? 1 : 0;
$isFuture = isset($data->future[$planID]) ? true : false;
if($oldPlans[$planID]->parent > 0)
$plan = new stdclass();
$plan->title = $data->title[$planID];
$plan->begin = isset($data->begin[$planID]) ? $data->begin[$planID] : '';
$plan->end = isset($data->end[$planID]) ? $data->end[$planID] : '';
$plan->status = isset($data->status[$planID]) ? $data->status[$planID] : $oldPlans[$planID]->status;
if(empty($plan->title)) die(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID)));
if(!$isFuture and $plan->status != 'wait')
{
$parentPlan = $this->getByID($oldPlans[$planID]->parent);
if($parentPlan->begin != '2030-01-01')
{
if($plan->begin < $parentPlan->begin) dao::$errors['begin'] = sprintf($this->lang->productplan->beginLetterParent, $parentPlan->begin);
}
if($parentPlan->end != '2030-01-01')
{
if($plan->end !='2030-01-01' and $plan->end > $parentPlan->end) dao::$errors['end'] = sprintf($this->lang->productplan->endGreaterParent, $parentPlan->end);
}
if($plan->begin == '') die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
if($plan->end == '') die(js::alert(sprintf($this->lang->productplan->errorNoEnd, $planID)));
if($plan->begin > $plan->end) die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID)));
}
if(empty($plan->title))die(js::alert(sprintf($this->lang->productplan->errorNoTitle, $planID)));
if(!$isFuture and $plan->begin == '2030-01-01') die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
if(!$isFuture and $plan->end == '2030-01-01') die(js::alert(sprintf($this->lang->productplan->errorNoEnd, $planID)));
if($plan->begin > $plan->end and ($plan->begin != '2030-01-01' and $plan->end != '2030-01-01')) die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID)));
if($plan->begin == '' or $plan->end == '')
{
$plan->begin = '2030-01-01';
$plan->end = '2030-01-01';
}
foreach($extendFields as $extendField)
{
@@ -687,6 +680,36 @@ class productplanModel extends model
$changes = array();
foreach($plans as $planID => $plan)
{
if($oldPlans[$planID]->parent > 0)
{
$parentID = $oldPlans[$planID]->parent;
$parent = isset($plans[$parentID]) ? $plans[$parentID] : $this->getByID($parentID);
$parentBeginDate = isset($plans[$parentID]->begin) ? $plans[$parentID]->begin : $parent->begin;
$parentEndDate = isset($plans[$parentID]->end) ? $plans[$parentID] : $parent->end;
if($parentBeginDate != '2030-01-01' and $plan->begin < $parentBeginDate)
{
die(js::alert(sprintf($this->lang->productplan->beginLetterParentTip, $planID, $plan->begin, $parentBeginDate)));
}
elseif($parentEndDate != '2030-01-01' and $plan->end > $parentEndDate)
{
die(js::alert(sprintf($this->lang->productplan->endGreaterParentTip, $planID, $plan->end, $parentEndDate)));
}
}
elseif($oldPlans[$planID]->parent == -1 and $plan->begin != '2030-01-01')
{
$childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($planID)->andWhere('deleted')->eq(0)->andWhere('id')->notIN($data->id)->fetchAll('id');
$minBegin = $plan->begin;
$maxEnd = $plan->end;
foreach($childPlans as $childID => $childPlan)
{
$childPlan = isset($plans[$childID]) ? $oldPlans[$childID] : $childPlan;
if($childPlan->begin < $minBegin and $minBegin != '2030-01-01') $minBegin = $childPlan->begin;
if($childPlan->end > $maxEnd and $maxEnd != '2030-01-01') $maxEnd = $childPlan->end;
}
if($minBegin < $plan->begin) die(js::alert(sprintf($this->lang->productplan->beginGreaterChildTip, $planID, $plan->begin, $minBegin)));
if($maxEnd > $plan->end) die(js::alert(sprintf($this->lang->productplan->endLetterChildTip, $planID, $plan->end, $maxEnd)));
}
$change = common::createChanges($oldPlans[$planID], $plan);
if($change)
{
+3 -3
View File
@@ -25,7 +25,7 @@
<?php if($product->type != 'normal'):?>
<th class='c-branch'><?php echo $lang->productplan->branch;?></th>
<?php endif;?>
<th><?php echo $lang->productplan->title?></th>
<th class='required'><?php echo $lang->productplan->title?></th>
<th class='c-status'><?php echo $lang->productplan->status?></th>
<th class='c-full-date'><?php echo $lang->productplan->begin?></th>
<th class='c-full-date'><?php echo $lang->productplan->end?></th>
@@ -47,7 +47,7 @@
<?php echo html::select("branch[$plan->id]", $plan->parent == '-1' ? '' : $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id, this.value); 'class='form-control chosen' $disabled");?>
</td>
<?php endif;?>
<td title='<?php echo $plan->title?>'><?php echo html::input("title[$plan->id]", $plan->title, "class='form-control' required")?></td>
<td title='<?php echo $plan->title?>'><?php echo html::input("title[$plan->id]", $plan->title, "class='form-control'")?></td>
<?php if($plan->parent != -1):?>
<td><?php echo html::select("status[$plan->id]", array_slice($lang->productplan->statusList,($plan->status == 'wait' ? 0 : 1)), $plan->status, "class='form-control chosen' onchange='setPlanStatus($plan->id, this.value)'");?></td>
<?php else:?>
@@ -59,7 +59,7 @@
<?php if($plan->end == '2030-01-01') $plan->end = '';?>
<td class=<?php echo $required;?>><?php echo html::input("begin[$plan->id]", $plan->begin, "class='form-control form-date' $disabled");?></td>
<td class=<?php echo $required;?>><?php echo html::input("end[$plan->id]", $plan->end, "class='form-control form-date' $disabled");?></td>
<?php $hidden = $plan->status != 'wait' ? 'hidden' : '';?>
<?php $hidden = ($plan->status != 'wait' and $plan->parent != -1) ? 'hidden' : '';?>
<td><div class='checkbox-primary <?php echo $hidden;?>'><input type='checkbox' id="future<?php echo $plan->id; ?>" name='future[<?php echo $plan->id; ?>]' <?php echo $isChecked;?> onclick="changeDate(<?php echo $plan->id;?>);"/><label for='future<?php echo $plan->id; ?>'><?php echo $lang->productplan->future;?></label></div></td>
<?php foreach($extendFields as $extendField) echo "<td" . (($extendField->control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->loadModel('flow')->getFieldControl($extendField, $plan, $extendField->field . "[{$plan->id}]") . "</td>";?>
</tr>