diff --git a/module/productplan/js/batchedit.js b/module/productplan/js/batchedit.js index 9c6b7dd997..5b8cf09d81 100644 --- a/module/productplan/js/batchedit.js +++ b/module/productplan/js/batchedit.js @@ -33,12 +33,8 @@ function setPlanStatus(planID, status) if(status != 'wait') { $('#future' + planID).closest('div').addClass('hidden'); - - $("input[name='begin[" + planID + "]']").closest('td').addClass('required'); - $("input[name='end[" + planID + "]']").closest('td').addClass('required'); $("input[name='begin[" + planID + "]']").removeAttr('disabled'); $("input[name='end[" + planID + "]']").removeAttr('disabled'); - $('.form-date').datetimepicker('update'); } else @@ -46,15 +42,12 @@ function setPlanStatus(planID, status) var isFuture = $('#future' + planID).prop('checked'); $('#future' + planID).closest('div').removeClass('hidden'); - $("input[name='begin[" + planID + "]']").closest('td').removeClass('required'); - $("input[name='end[" + planID + "]']").closest('td').removeClass('required'); if(isFuture) { $("input[name='begin[" + planID + "]']").attr('disabled', 'disabled'); $("input[name='end[" + planID + "]']").attr('disabled', 'disabled'); } - } } diff --git a/module/productplan/js/edit.js b/module/productplan/js/edit.js index 340aaa5c09..8aa184ecee 100644 --- a/module/productplan/js/edit.js +++ b/module/productplan/js/edit.js @@ -72,8 +72,6 @@ function setPlanStatus() { $('#checkBox').closest('div').addClass('hidden'); $('#future').val(0); - $('#begin').closest('td').addClass('required'); - $('#end').closest('td').addClass('required'); $('#begin').removeAttr('disabled'); $('#end').parents('tr').show(); } @@ -82,12 +80,10 @@ function setPlanStatus() var isFuture = $('#future').prop('checked'); $('#checkBox').closest('div').removeClass('hidden'); - $('#begin').closest('td').removeClass('required'); - $('#end').closest('td').removeClass('required'); if(isFuture) { $('#begin').attr('disabled', 'disabled'); - $('#end').val('').parents('tr').hide(); + $('#end').parents('tr').hide(); } } } diff --git a/module/productplan/model.php b/module/productplan/model.php index e4ada7a7fb..33165c925f 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -464,19 +464,19 @@ class productplanModel extends model { $oldPlan = $this->dao->findByID((int)$planID)->from(TABLE_PRODUCTPLAN)->fetch(); $plan = fixer::input('post')->stripTags($this->config->productplan->editor->edit['id'], $this->config->allowedTags) - ->setIF($this->post->future or empty($_POST['begin']), 'begin', $this->config->productplan->future) - ->setIF($this->post->future or empty($_POST['end']), 'end', $this->config->productplan->future) + ->setIF($this->post->future and empty($_POST['begin']), 'begin', $this->config->productplan->future) + ->setIF($this->post->future and empty($_POST['end']), 'end', $this->config->productplan->future) ->remove('delta,uid,future') ->get(); if($oldPlan->parent > 0) { $parentPlan = $this->getByID($oldPlan->parent); - if($parentPlan->begin != $this->config->productplan->future) + if($parentPlan->begin !== $this->config->productplan->future) { if($plan->begin < $parentPlan->begin) dao::$errors['begin'] = sprintf($this->lang->productplan->beginLetterParent, $parentPlan->begin); } - if($parentPlan->end != $this->config->productplan->future) + if($parentPlan->end !== $this->config->productplan->future) { if($plan->end !== $this->config->productplan->future and $plan->end > $parentPlan->end) dao::$errors['end'] = sprintf($this->lang->productplan->endGreaterParent, $parentPlan->end); } @@ -496,22 +496,12 @@ class productplanModel extends model if($maxEnd > $plan->end and $maxEnd != $this->config->productplan->future) dao::$errors['end'] = sprintf($this->lang->productplan->endLetterChildTip, $planID, $plan->end, $maxEnd); } - $requiredFields = $oldPlan->status == 'wait' ? $this->config->productplan->edit->requiredFields : 'title, begin, end'; - if($plan->status != 'wait' and $plan->begin == $this->config->productplan->future) - { - dao::$errors['begin'] = sprintf($this->lang->error->notempty, $this->lang->productplan->begin); - } - if($plan->status != 'wait' and $plan->end == $this->config->productplan->future) - { - dao::$errors['end'] = sprintf($this->lang->error->notempty, $this->lang->productplan->end); - } if(dao::isError()) return false; - $plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_PRODUCTPLAN) ->data($plan) ->autoCheck() - ->batchCheck($requiredFields, 'notempty') + ->batchCheck($this->config->productplan->edit->requiredFields, 'notempty') ->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin) ->where('id')->eq((int)$planID) ->exec(); @@ -671,21 +661,13 @@ class productplanModel extends model $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; + $plan->parent = $oldPlans[$planID]->parent; if(empty($plan->title)) die(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID))); + if($plan->begin > $plan->end and !empty($plan->end)) die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID))); - if(!$isFuture and $plan->status != 'wait') - { - 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($plan->begin == '' or $plan->end == '') - { - $plan->begin = $this->config->productplan->future; - $plan->end = $this->config->productplan->future; - } + if($plan->begin == '') $plan->begin = $this->config->productplan->future; + if($plan->end == '') $plan->end = $this->config->productplan->future; foreach($extendFields as $extendField) { @@ -701,12 +683,13 @@ class productplanModel extends model } $changes = array(); + $parents = array(); foreach($plans as $planID => $plan) { + $parentID = $oldPlans[$planID]->parent; /* Determine whether the begin and end dates of the parent plan and the child plan are correct. */ - if($oldPlans[$planID]->parent > 0) + if($parentID > 0) { - $parentID = $oldPlans[$planID]->parent; $parent = isset($plans[$parentID]) ? $plans[$parentID] : $this->getByID($parentID); if($parent->begin != $this->config->productplan->future and $plan->begin != $this->config->productplan->future and $plan->begin < $parent->begin) { @@ -717,7 +700,7 @@ class productplanModel extends model die(js::alert(sprintf($this->lang->productplan->endGreaterParentTip, $planID, $plan->end, $parent->end))); } } - elseif($oldPlans[$planID]->parent == -1 and $plan->begin != $this->config->productplan->future) + elseif($parentID == -1 and $plan->begin != $this->config->productplan->future) { $childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($planID)->andWhere('deleted')->eq(0)->fetchAll('id'); $minBegin = $plan->begin; @@ -735,12 +718,15 @@ class productplanModel extends model $change = common::createChanges($oldPlans[$planID], $plan); if($change) { + if($parentID > 0 and !isset($parents[$parentID])) $parents[$parentID] = $parentID; $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->where('id')->eq($planID)->exec(); if(dao::isError()) die(js::error(dao::getError())); $changes[$planID] = $change; } } + foreach($parents as $parent) $this->updateParentStatus($parent); + return $changes; } diff --git a/module/productplan/view/batchedit.html.php b/module/productplan/view/batchedit.html.php index 5d3d08eb0b..eab73ee039 100644 --- a/module/productplan/view/batchedit.html.php +++ b/module/productplan/view/batchedit.html.php @@ -38,28 +38,28 @@
- begin == '2030-01-01' || $plan->end == '2030-01-01') ? 'checked="checked"' : '';?> + begin == '2030-01-01' or $plan->end == '2030-01-01') ? 'checked="checked"' : '';?>