diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php index 9b81014ee9..a7c1cfaf1b 100644 --- a/module/productplan/lang/en.php +++ b/module/productplan/lang/en.php @@ -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'; diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php index fd6d0e2d24..282f7b296e 100644 --- a/module/productplan/lang/zh-cn.php +++ b/module/productplan/lang/zh-cn.php @@ -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'] = '未开始'; diff --git a/module/productplan/model.php b/module/productplan/model.php index 8a657e3041..19a77bca17 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -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) { diff --git a/module/productplan/view/batchedit.html.php b/module/productplan/view/batchedit.html.php index e4f6bdda05..a2570b29ff 100644 --- a/module/productplan/view/batchedit.html.php +++ b/module/productplan/view/batchedit.html.php @@ -25,7 +25,7 @@ type != 'normal'):?> productplan->branch;?> - productplan->title?> + productplan->title?> productplan->status?> productplan->begin?> productplan->end?> @@ -47,7 +47,7 @@ id]", $plan->parent == '-1' ? '' : $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id, this.value); 'class='form-control chosen' $disabled");?> - id]", $plan->title, "class='form-control' required")?> + id]", $plan->title, "class='form-control'")?> parent != -1):?> id]", array_slice($lang->productplan->statusList,($plan->status == 'wait' ? 0 : 1)), $plan->status, "class='form-control chosen' onchange='setPlanStatus($plan->id, this.value)'");?> @@ -59,7 +59,7 @@ end == '2030-01-01') $plan->end = '';?> >id]", $plan->begin, "class='form-control form-date' $disabled");?> >id]", $plan->end, "class='form-control form-date' $disabled");?> - status != 'wait' ? 'hidden' : '';?> + status != 'wait' and $plan->parent != -1) ? 'hidden' : '';?>
onclick="changeDate(id;?>);"/>
control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->loadModel('flow')->getFieldControl($extendField, $plan, $extendField->field . "[{$plan->id}]") . "";?>