Merge branch 'sprint/181_zhengrunyu_Fixbug' into 'master'
*Code chenge status of parent and fix bug See merge request easycorp/zentaopms!1280
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,28 +38,28 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($plans as $plan):?>
|
||||
<?php $isChecked = ($plan->begin == '2030-01-01' || $plan->end == '2030-01-01') ? 'checked="checked"' : '';?>
|
||||
<?php $isChecked = ($plan->begin == '2030-01-01' or $plan->end == '2030-01-01') ? 'checked="checked"' : '';?>
|
||||
<tr>
|
||||
<td class='text-center'><?php echo $plan->id . html::hidden("id[$plan->id]", $plan->id);?></td>
|
||||
<?php if($product->type != 'normal'):?>
|
||||
<td class='text-left'>
|
||||
<?php $disabled = $plan->parent == '-1' ? "disabled='disabled'" : '';?>
|
||||
<?php $disabled = $plan->parent != -1 ? "disabled='disabled'" : '';?>
|
||||
<?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'")?></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>
|
||||
<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, $plan->parent)'");?></td>
|
||||
<?php else:?>
|
||||
<td><?php echo html::select("status[$plan->id]", array_slice($lang->productplan->statusList,($plan->status == 'wait' ? 0 : 1)), $plan->status, "class='form-control chosen' disabled onchange='setPlanStatus($plan->id, this.value)'");?></td>
|
||||
<td><?php echo html::select("status[$plan->id]", array_slice($lang->productplan->statusList,($plan->status == 'wait' ? 0 : 1)), $plan->status, "class='form-control chosen' disabled onchange='setPlanStatus($plan->id, this.value, $plan->parent)'");?></td>
|
||||
<?php endif;?>
|
||||
<?php $required = $plan->status != 'wait' ? 'required' : '' ;?>
|
||||
<?php $disabled = ($plan->begin == '2030-01-01' || $plan->end == '2030-01-01') ? 'disabled="disabled"' : '';?>
|
||||
<?php $disabled = (($plan->begin == '2030-01-01' or $plan->end == '2030-01-01') and $plan->status == 'wait') ? 'disabled="disabled"' : '';?>
|
||||
<?php if($plan->parent == -1 and ($plan->begin == '2030-01-01' or $plan->end == '2030-01-01')) $disabled = 'disabled="disabled"';?>
|
||||
<?php if($plan->begin == '2030-01-01') $plan->begin = '';?>
|
||||
<?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' : '';?>
|
||||
<td><?php echo html::input("begin[$plan->id]", $plan->begin, "class='form-control form-date' $disabled");?></td>
|
||||
<td><?php echo html::input("end[$plan->id]", $plan->end, "class='form-control form-date' $disabled");?></td>
|
||||
<?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>
|
||||
|
||||
@@ -47,11 +47,10 @@
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php $required = $plan->status != 'wait' ? 'required' : '' ;?>
|
||||
<?php $hidden = $plan->status != 'wait' ? 'hidden' : '';?>
|
||||
<?php $checked = $plan->begin == '2030-01-01' || $plan->end == '2030-01-01' ? "checked='checked'" : '';?>
|
||||
<?php $hidden = $plan->status != 'wait' ? 'hidden' : '';?>
|
||||
<?php $checked = $plan->begin == '2030-01-01' || $plan->end == '2030-01-01' ? "checked='checked'" : '';?>
|
||||
<th><?php echo $lang->productplan->begin;?></th>
|
||||
<td><?php echo html::input('begin', $plan->begin != '2030-01-01' ? formatTime($plan->begin) : '', "class='form-control form-date' $required");?></td>
|
||||
<td><?php echo html::input('begin', $plan->begin != '2030-01-01' ? formatTime($plan->begin) : '', "class='form-control form-date'");?></td>
|
||||
<td>
|
||||
<?php if($plan->status == 'wait'):?>
|
||||
<div class='checkbox-primary <?php echo $hidden;?>' id='checkBox'>
|
||||
@@ -63,7 +62,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->productplan->end;?></th>
|
||||
<td><?php echo html::input('end', $plan->end != '2030-01-01' ? formatTime($plan->end) : '', "class='form-control form-date' $required");?></td>
|
||||
<td><?php echo html::input('end', $plan->end != '2030-01-01' ? formatTime($plan->end) : '', "class='form-control form-date'");?></td>
|
||||
<?php $deltaValue = $plan->end == '2030-01-01' ? 0 : (strtotime($plan->end) - strtotime($plan->begin)) / 3600 / 24 + 1;?>
|
||||
<td colspan='2'><?php echo html::radio('delta', $lang->productplan->endList , $deltaValue, "onclick='computeEndDate(this.value)'");?></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user