*Finish task 46662 46665 46669.

This commit is contained in:
zhengrunyu
2021-12-30 09:01:44 +08:00
parent 7f6d93632a
commit d28dcd7d63
9 changed files with 139 additions and 20 deletions
+2 -2
View File
@@ -112,9 +112,9 @@ class productplan extends control
if(!empty($_POST))
{
$changes = $this->productplan->update($planID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$change[$planID] = $changes;
$this->syncStory($change);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($changes)
{
$actionID = $this->loadModel('action')->create('productplan', $planID, 'edited');
@@ -131,7 +131,7 @@ class productplan extends control
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->edit;
$this->view->position[] = $this->lang->productplan->edit;
$this->view->oldBranch = $oldBranch;
$this->view->plan = $plan;
$this->view->plan = $plan;
$this->display();
}
+29
View File
@@ -25,6 +25,35 @@ function changeDate(planID)
}
};
/**
* Set plan status.
*
* @param int $planID
* @param $status
* @access public
* @return void
*/
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');
}
else
{
$('#future'+planID).closest('div').removeClass('hidden');
$("input[name='begin["+planID+"]']").closest('td').removeClass('required');
$("input[name='end["+planID+"]']").closest('td').removeClass('required');
$("input[name='begin"+planID+"']").attr('disabled', 'disabled');
$("input[name='end"+planID+"']").attr('disabled', 'disabled');
}
}
/**
* Get conflict stories.
*
+33
View File
@@ -59,6 +59,39 @@ function computeEndDate(delta)
$('#end').val(endDate).datetimepicker('update');
}
/**
* Set plan status.
*
* @access public
* @return void
*/
function setPlanStatus()
{
var status = $('#status').val();
if(status != 'wait')
{
$('#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();
}
else
{
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();
}
}
}
$('#future').on('change', function()
{
if($(this).prop('checked'))
+6
View File
@@ -71,6 +71,12 @@ $lang->productplan->childrenAB = "C";
$lang->productplan->order = "Order";
$lang->productplan->deleted = "Deleted";
$lang->productplan->mailto = "Mailto";
$lang->productplan->status = "Plan Status";
$lang->productplan->statusList['wait'] = 'Wait';
$lang->productplan->statusList['doing'] = 'Doing';
$lang->productplan->statusList['done'] = 'Done';
$lang->productplan->statusList['closed'] = 'Closed';
$lang->productplan->endList[7] = '1 Week';
$lang->productplan->endList[14] = '2 Weeks';
+6
View File
@@ -71,6 +71,12 @@ $lang->productplan->childrenAB = "子";
$lang->productplan->order = "排序";
$lang->productplan->deleted = "已删除";
$lang->productplan->mailto = "抄送给";
$lang->productplan->status = "计划状态";
$lang->productplan->statusList['wait'] = '未开始';
$lang->productplan->statusList['doing'] = '进行中';
$lang->productplan->statusList['done'] = '已完成';
$lang->productplan->statusList['closed'] = '已关闭';
$lang->productplan->endList[7] = '一星期';
$lang->productplan->endList[14] = '两星期';
+32 -9
View File
@@ -454,11 +454,23 @@ class productplanModel extends model
->setIF($this->post->future || empty($_POST['end']), 'end', '2030-01-01')
->remove('delta,uid,future')
->get();
if(!$this->post->future and strpos($this->config->productplan->edit->requiredFields, 'begin') !== false and empty($_POST['begin']))
if($oldPlan->parent != 0 and $oldPlan->parent != -1) $parentPlan = $this->getByID($oldPlan->parent);
if(!empty($parentPlan->begin))
{
if($plan->begin < $parentPlan->begin) dao::$errors['begin'] = sprintf($this->lang->productplan->beginLetterParent, $parentPlan->begin);
}
if(!empty($parentPlan->end))
{
if($plan->end !=='2030-01-01' and $plan->end > $parentPlan->end) dao::$errors['end'] = sprintf($this->lang->productplan->endGreaterParent, $parentPlan->end);
}
$requiredFields = $plan->status == 'wait' ? $this->config->productplan->edit->requiredFields : 'title, begin, end';
if(!$this->post->future and strpos($requiredFields, 'begin') !== false and empty($_POST['begin']))
{
dao::$errors['begin'] = sprintf($this->lang->error->notempty, $this->lang->productplan->begin);
}
if(!$this->post->future and strpos($this->config->productplan->edit->requiredFields, 'end') !== false and empty($_POST['end']))
if(!$this->post->future and strpos($requiredFields, 'end') !== false and empty($_POST['end']))
{
dao::$errors['end'] = sprintf($this->lang->error->notempty, $this->lang->productplan->end);
}
@@ -468,7 +480,7 @@ class productplanModel extends model
$this->dao->update(TABLE_PRODUCTPLAN)
->data($plan)
->autoCheck()
->batchCheck($this->config->productplan->edit->requiredFields, 'notempty')
->batchCheck($requiredFields, 'notempty')
->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
->where('id')->eq((int)$planID)
->exec();
@@ -495,7 +507,7 @@ class productplanModel extends model
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$plans = array();
$extendFields = $this->getFlowExtendFields();
foreach($data->id as $planID)
@@ -504,13 +516,24 @@ class productplanModel extends model
$plan->branch = $data->branch[$planID];
$plan->title = $data->title[$planID];
$plan->desc = $purifier->purify($data->desc[$planID]);
$plan->begin = $data->begin[$planID];
$plan->end = $data->end[$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($oldPlans[$planID]->parent != 0 and $oldPlans[$planID]->parent != -1) $parentPlan = $this->getByID($oldPlans[$planID]->parent);
if(!empty($parentPlan->begin))
{
if($plan->begin < $parentPlan->begin) dao::$errors['begin'] = sprintf($this->lang->productplan->beginLetterParent, $parentPlan->begin);
}
if(!empty($parentPlan->end))
{
if($plan->end !=='2030-01-01' and $plan->end > $parentPlan->end) dao::$errors['end'] = sprintf($this->lang->productplan->endGreaterParent, $parentPlan->end);
}
if(empty($plan->title))die(js::alert(sprintf($this->lang->productplan->errorNoTitle, $planID)));
if(empty($plan->begin))die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
if(empty($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 == '2030-01-01' and $plan->status != 'wait') die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
if($plan->end == '2030-01-01' and $plan->status != 'wait') 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)));
foreach($extendFields as $extendField)
{
+13 -4
View File
@@ -27,6 +27,7 @@
<?php endif;?>
<th><?php echo $lang->productplan->title?></th>
<th><?php echo $lang->productplan->desc?></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>
<th class='c-future'><?php echo $lang->productplan->future?></th>
@@ -49,11 +50,19 @@
<?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>
<td title='<?php echo $plan->title?>'><?php echo html::input("title[$plan->id]", $plan->title, "class='form-control' required")?></td>
<td><?php echo html::textarea("desc[$plan->id]", $plan->desc, "class='form-control' rows='1'")?></td>
<td><?php echo html::input("begin[$plan->id]", $plan->begin, "class='form-control form-date $hiddenInput'");echo html::input("begin$plan->id", '', "class='form-control $showInput' disabled='disabled'");?></td>
<td><?php echo html::input("end[$plan->id]", $plan->end, "class='form-control form-date $hiddenInput'");echo html::input("end$plan->id", '', "class='form-control $showInput' disabled='disabled'");?></td>
<td><div class='checkbox-primary'><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 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:?>
<td><?php echo zget($lang->productplan->statusList, $plan->status);?></td>
<?php echo html::hidden("status[$plan->id]", $plan->status);?>
<?php endif;?>
<?php $required = $plan->status != 'wait' ? 'required' : '' ;?>
<td class=<?php echo $required;?>><?php echo html::input("begin[$plan->id]", $plan->begin, "class='form-control form-date $hiddenInput'");echo html::input("begin$plan->id", '', "class='form-control $showInput' disabled='disabled'");?></td>
<td class=<?php echo $required;?>><?php echo html::input("end[$plan->id]", $plan->end, "class='form-control form-date $hiddenInput'");echo html::input("end$plan->id", '', "class='form-control $showInput' disabled='disabled'");?></td>
<?php $hidden = $plan->status != 'wait' ? '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>
<?php endforeach;?>
+1 -1
View File
@@ -130,7 +130,7 @@
<?php foreach($extendFields as $extendField) echo "<td>" . $this->loadModel('flow')->getFieldValue($extendField, $plan) . "</td>";?>
<td class='c-actions'>
<?php
$attr = $plan->expired ? "disabled='disabled'" : '';
$attr = ($plan->expired or $plan->status === 'done' or $plan->status === 'closed')? "disabled='disabled'" : '';
if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0)
{
$disabled = '';
+17 -4
View File
@@ -39,19 +39,32 @@
<td><?php echo html::input('title', $plan->title, "class='form-control' required");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->productplan->status;?></th>
<?php if($plan->parent != -1):?>
<td><?php echo html::select('status', array_slice($lang->productplan->statusList,($plan->status == 'wait' ? 0 : 1)), $plan->status, "class='form-control chosen' onchange='setPlanStatus()'");?></td>
<?php else:?>
<td><?php echo zget($lang->productplan->statusList, $plan->status);?></td>
<?php echo html::hidden('status', $plan->status);?>
<?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'" : '';?>
<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'");?></td>
<td><?php echo html::input('begin', $plan->begin != '2030-01-01' ? formatTime($plan->begin) : '', "class='form-control form-date' $required");?></td>
<td>
<?php $checked = $plan->begin == '2030-01-01' || $plan->end == '2030-01-01' ? "checked='checked'" : '';?>
<div class='checkbox-primary'>
<?php if($plan->status == 'wait'):?>
<div class='checkbox-primary <?php echo $hidden;?>' id='checkBox'>
<input type='checkbox' id='future' name='future' value='1' <?php echo $checked;?> />
<label for='future'><?php echo $lang->productplan->future;?></label>
</div>
<?php endif;?>
</td>
</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"');?></td>
<td><?php echo html::input('end', $plan->end != '2030-01-01' ? formatTime($plan->end) : '', "class='form-control form-date' $required");?></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>