* Finish task #84590.

This commit is contained in:
Yagami
2023-02-16 13:56:15 +08:00
parent 8de77be199
commit 15ff524a7d
8 changed files with 100 additions and 140 deletions
+3 -2
View File
@@ -2142,7 +2142,7 @@ class execution extends control
if($this->post->names)
{
$allChanges = $this->execution->batchUpdate();
if(dao::isError()) return print(js::error(dao::getError()));
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(!empty($allChanges))
{
@@ -2165,7 +2165,8 @@ class execution extends control
$this->loadModel('common')->syncPPEStatus($syncExecution);
}
}
return print(js::locate($this->session->executionList, 'parent'));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->session->executionList));
}
if($this->app->tab == 'project')
+6
View File
@@ -21,3 +21,9 @@ function changeProject(obj, executionID, projectID)
$(obj).data("lastselected", lastSelected);
}
}
$('#executionForm').on('change input mousedown', '.has-error', function()
{
$(this).parent().find('.text-danger').remove();
$(this).removeClass('has-error');
})
+4
View File
@@ -392,6 +392,10 @@ $lang->execution->errorLetterProject = "The start time of {$lang->execu
$lang->execution->errorGreaterProject = "The end time of {$lang->executionCommon} cannot be greater than the end time %s of the project.";
$lang->execution->errorCommonBegin = 'The start date of ' . $lang->executionCommon . ' should be ≥ the start date of project : %s.';
$lang->execution->errorCommonEnd = 'The deadline of ' . $lang->executionCommon . ' should be ≤ the deadline of project : %s.';
$lang->execution->errorLetterParent = 'The begin cannot be less than the begin of the parent stage to which it belongs: %s.';
$lang->execution->errorGreaterParent = 'The end cannot be greater than the end of the parent stage to which it belongs:%s.';
$lang->execution->errorNameRepeat = 'Child stages of the same parent stage cannot have the same name.';
$lang->execution->errorAttrMatch = "Parent stage's attribute is [%s], the attribute needs to be consistent with the parent stage.";
$lang->execution->accessDenied = "Zugriff zu {$lang->executionCommon} verweigert!";
$lang->execution->tips = 'Hinweis';
$lang->execution->afterInfo = "{$lang->executionCommon} wurde erstellt. Als nächstes können Sie ";
+4
View File
@@ -392,6 +392,10 @@ $lang->execution->errorLetterProject = "The start time of {$lang->execu
$lang->execution->errorGreaterProject = "The end time of {$lang->executionCommon} cannot be greater than the end time %s of the project.";
$lang->execution->errorCommonBegin = 'The start date of ' . $lang->executionCommon . ' should be ≥ the start date of project : %s.';
$lang->execution->errorCommonEnd = 'The deadline of ' . $lang->executionCommon . ' should be ≤ the deadline of project : %s.';
$lang->execution->errorLetterParent = 'The begin cannot be less than the begin of the parent stage to which it belongs: %s.';
$lang->execution->errorGreaterParent = 'The end cannot be greater than the end of the parent stage to which it belongs:%s.';
$lang->execution->errorNameRepeat = 'Child stages of the same parent stage cannot have the same name.';
$lang->execution->errorAttrMatch = "Parent stage's attribute is [%s], the attribute needs to be consistent with the parent stage.";
$lang->execution->accessDenied = "Your access to {$lang->executionCommon} is denied!";
$lang->execution->tips = 'Note';
$lang->execution->afterInfo = "{$lang->executionCommon} is created. Next you can ";
+4
View File
@@ -392,6 +392,10 @@ $lang->execution->errorLetterProject = "The start time of {$lang->execu
$lang->execution->errorGreaterProject = "The end time of {$lang->executionCommon} cannot be greater than the end time %s of the project.";
$lang->execution->errorCommonBegin = 'The start date of ' . $lang->executionCommon . ' should be ≥ the start date of project : %s.';
$lang->execution->errorCommonEnd = 'The deadline of ' . $lang->executionCommon . ' should be ≤ the deadline of project : %s.';
$lang->execution->errorLetterParent = 'The begin cannot be less than the begin of the parent stage to which it belongs: %s.';
$lang->execution->errorGreaterParent = 'The end cannot be greater than the end of the parent stage to which it belongs:%s.';
$lang->execution->errorNameRepeat = 'Child stages of the same parent stage cannot have the same name.';
$lang->execution->errorAttrMatch = "Parent stage's attribute is [%s], the attribute needs to be consistent with the parent stage.";
$lang->execution->accessDenied = "Votre accès au {$lang->executionCommon} est refusé ! Désolé.";
$lang->execution->tips = 'Note';
$lang->execution->afterInfo = "Le {$lang->executionCommon} a été créé avec succès ! Ensuite vous pouvez ";
+4
View File
@@ -392,6 +392,10 @@ $lang->execution->errorLetterProject = "{$lang->executionCommon}的计
$lang->execution->errorGreaterProject = "{$lang->executionCommon}的计划完成时间不能大于所属项目的计划完成时间%s。";
$lang->execution->errorCommonBegin = $lang->executionCommon . '开始日期应大于等于项目的开始日期:%s。';
$lang->execution->errorCommonEnd = $lang->executionCommon . '截止日期应小于等于项目的截止日期:%s。';
$lang->execution->errorLetterParent = '计划开始时间不能小于所属父阶段的计划开始时间:%s。';
$lang->execution->errorGreaterParent = '计划完成时间不能大于所属父阶段的计划完成时间:%s。';
$lang->execution->errorNameRepeat = '相同父阶段的子阶段名称不能相同';
$lang->execution->errorAttrMatch = "父阶段类型为[%s],阶段类型需与父阶段一致";
$lang->execution->accessDenied = "您无权访问该{$lang->executionCommon}!";
$lang->execution->tips = '提示';
$lang->execution->afterInfo = "{$lang->executionCommon}添加成功,您现在可以进行以下操作:";
+74 -31
View File
@@ -712,6 +712,9 @@ class executionModel extends model
$codeList = array();
$projectModel = 'scrum';
$parents = array();
foreach($oldExecutions as $oldExecution) $parents[$oldExecution->id] = $oldExecution->parent;
/* Replace required language. */
if($this->app->tab == 'project')
{
@@ -743,7 +746,6 @@ class executionModel extends model
$executions[$executionID]->PO = $data->POs[$executionID];
$executions[$executionID]->QD = $data->QDs[$executionID];
$executions[$executionID]->RD = $data->RDs[$executionID];
$executions[$executionID]->lifetime = $data->lifetimes[$executionID];
$executions[$executionID]->status = $data->statuses[$executionID];
$executions[$executionID]->begin = $data->begins[$executionID];
$executions[$executionID]->end = $data->ends[$executionID];
@@ -753,29 +755,60 @@ class executionModel extends model
$executions[$executionID]->lastEditedBy = $this->app->user->account;
$executions[$executionID]->lastEditedDate = helper::now();
if(isset($data->codes)) $executions[$executionID]->code = $executionCode;
if(isset($data->codes)) $executions[$executionID]->code = $executionCode;
if(isset($data->projects)) $executions[$executionID]->project = zget($data->projects, $executionID, 0);
if(isset($data->attributes)) $executions[$executionID]->attribute = zget($data->attributes, $executionID, '');
if(isset($data->lifetimes)) $executions[$executionID]->lifetime = $data->lifetimes[$executionID];
if($executions[$executionID]->status == 'closed' and $oldExecutions[$executionID]->status != 'closed') $executions[$executionID]->closedDate = helper::now();
if($executions[$executionID]->status == 'suspended' and $oldExecutions[$executionID]->status != 'suspended') $executions[$executionID]->suspendedDate = helper::today();
/* Check unique code for edited executions. */
if($projectModel == 'scrum' and isset($executionCode) and empty($executionCode))
if(isset($data->codes) and empty($executionCode))
{
dao::$errors['code'][] = 'execution#' . $executionID . sprintf($this->lang->error->notempty, $this->lang->execution->execCode);
return false;
dao::$errors["codes\[$executionID\]"][] = sprintf($this->lang->error->notempty, $this->lang->execution->execCode);
}
elseif(!empty($executionCode))
elseif(isset($data->codes) and $executionCode)
{
/* Check unique code for edited executions. */
if(isset($codeList[$executionCode]))
{
dao::$errors['code'][] = 'execution#' . $executionID . sprintf($this->lang->error->unique, $this->lang->execution->execCode, $executionCode);
return false;
dao::$errors["codes\[$executionID\]"][] = sprintf($this->lang->error->unique, $this->lang->execution->execCode, $executionCode);
}
$codeList[$executionCode] = $executionCode;
}
/* Name check. */
$parentID = $parents[$executionID];
if(isset($nameList[$executionName]))
{
foreach($nameList[$executionName] as $repeatID)
{
if($parentID == $parents[$repeatID])
{
dao::$errors["names\[$executionID\]"][] = $this->lang->execution->errorNameRepeat;
break;
}
}
}
$nameList[$executionName][] = $executionID;
/* Attribute check. */
if(isset($data->attributes))
{
$this->app->loadLang('stage');
$attribute = $executions[$executionID]->attribute;
if(isset($attributeList[$parentID]))
{
if($attributeList[$parentID] != $attribute and $attributeList[$parentID] != 'mix')
{
$parentAttr = zget($this->lang->stage->typeList, $attributeList[$parentID]);
dao::$errors["attributes$executionID"][] = sprintf($this->lang->execution->errorAttrMatch, $parentAttr);
}
}
$attributeList[$executionID] = $attribute;
}
/* Judge workdays is legitimate. */
$workdays = helper::diffDate($data->ends[$executionID], $data->begins[$executionID]) + 1;
if(isset($data->dayses[$executionID]) and $data->dayses[$executionID] > $workdays)
@@ -785,6 +818,37 @@ class executionModel extends model
return false;
}
/* Parent stage begin and end check. */
if(isset($executions[$parentID]))
{
$begin = $executions[$executionID]->begin;
$end = $executions[$executionID]->end;
$parentBegin = $executions[$parentID]->begin;
$parentEnd = $executions[$parentID]->end;
if($begin < $parentBegin)
{
dao::$errors["begins\[$executionID\]"][] = sprintf($this->lang->execution->errorLetterParent, $parentBegin);
}
if($end > $parentEnd)
{
dao::$errors["ends\[$executionID\]"][] = sprintf($this->lang->execution->errorGreaterParent, $parentEnd);
}
}
/* Project begin and end check. */
if($project and $execution->begin < $project->begin)
{
dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterProject, $project->begin);
return false;
}
if($project and $execution->end > $project->end)
{
dao::$errors['end'] = sprintf($this->lang->execution->errorGreaterProject, $project->end);
return false;
}
foreach($extendFields as $extendField)
{
$executions[$executionID]->{$extendField->field} = $this->post->{$extendField->field}[$executionID];
@@ -794,6 +858,8 @@ class executionModel extends model
}
}
if(dao::isError()) return false;
/* Update burn before close execution. */
$closedIdList = array();
foreach($executions as $executionID => $execution)
@@ -830,29 +896,6 @@ class executionModel extends model
}
}
if($project and $execution->begin < $project->begin)
{
dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterProject, $project->begin);
return false;
}
if($project and $execution->end > $project->end)
{
dao::$errors['end'] = sprintf($this->lang->execution->errorGreaterProject, $project->end);
return false;
}
/* Replace required language. */
if($this->app->tab == 'project')
{
$this->lang->project->name = $this->lang->execution->name;
$this->lang->project->code = $this->lang->execution->code;
}
else
{
$this->lang->project->name = $this->lang->execution->execName;
$this->lang->project->code = $this->lang->execution->execCode;
}
$this->dao->update(TABLE_EXECUTION)->data($execution)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->execution->edit->requiredFields, 'notempty')
+1 -107
View File
@@ -43,7 +43,7 @@
$desc = $from == 'execution' ? 'execDesc' : 'desc';
$status = $from == 'execution' ? 'execStatus' : 'status';
?>
<form class='main-form' method='post' target='hiddenwin' id='executionForm' action='<?php echo inLink('batchEdit');?>'>
<form class='main-form form-ajax' method='post' id='executionForm' action='<?php echo inLink('batchEdit');?>'>
<div class="table-responsive">
<table class='table table-form'>
<thead>
@@ -148,111 +148,5 @@
<?php
js::set('weekend', $config->execution->weekend);
js::set('confirmSync', $lang->execution->confirmSync);
js::set('emptyBegin', $lang->programplan->emptyBegin);
js::set('emptyEnd', $lang->programplan->emptyEnd);
js::set('planFinishSmall', $lang->programplan->error->planFinishSmall);
js::set('errorBegin', $lang->execution->errorLetterProject);
js::set('errorEnd', $lang->execution->errorGreaterProject);
?>
<script>
$('#executionForm').submit(function()
{
/* Clear all error messages. */
$('input[name^=begins]').each(function()
{
var executionID = $(this).attr('id').replace(/\w*\[|\]/g, '');
$('#helpbegins' + executionID).remove();
$('#helpends' + executionID).remove();
});
var submitForm = true;
$('input[name^=begins]').each(function()
{
var beginDate = $(this).val();
var executionID = $(this).attr('id').replace(/\w*\[|\]/g, '');
$('#helpbegins' + executionID).remove();
$('#helpends' + executionID).remove();
/* Invalid data is skipped. */
var nameVal = $("[name='names[" + executionID + "]']").val()
if(!nameVal) return;
var projectBeginDate = '0000-00-00';
var projectEndDate = '2059-12-31';
$.ajax(
{
url: createLink('execution', 'ajaxGetProjectStartDate', "executionID=" + executionID),
dataType: 'json',
method: 'post',
async: false,
success: function(data)
{
if(data)
{
projectBeginDate = data.begin;
projectEndDate = data.end;
}
}
});
/* Check if the begin date is empty. */
if(!beginDate)
{
submitForm = false;
var emptyBeginHtml = '<div id="helpbegins' + executionID + '" class="text-danger help-text">' + emptyBegin + '</div>';
$(this).after(emptyBeginHtml);
alert(emptyBegin);
return false;
}
var endDate = $("[name='ends[" + executionID + "]']").val();
if(!endDate)
{
submitForm = false;
var emptyEndHtml = '<div id="helpends' + executionID + '" class="text-danger help-text">' + emptyEnd + '</div>';
$("[name='ends[" + executionID + "]']").after(emptyEndHtml);
alert(emptyEnd);
return false;
}
if(endDate < beginDate)
{
submitForm = false;
var emptyEndHtml = '<div id="helpends' + executionID + '" class="text-danger help-text">' + planFinishSmall + '</div>';
$("[name='ends[" + executionID + "]']").after(emptyEndHtml);
alert(planFinishSmall);
return false;
}
if(beginDate < projectBeginDate)
{
submitForm = false;
var errorBeginTip = errorBegin.replace('%s', projectBeginDate);
var errorBeginHtml = '<div id="helpbegins' + executionID + '" class="text-danger help-text">' + errorBeginTip + '</div>';
$("[name='begins[" + executionID + "]']").after(errorBeginHtml);
alert(errorBeginTip);
return false;
}
if(endDate > projectEndDate)
{
submitForm = false;
var errorEndTip = errorEnd.replace('%s', projectEndDate);
var errorEndHtml = '<div id="helpends' + executionID + '" class="text-danger help-text">' + errorEndTip + '</div>';
$("[name='ends[" + executionID + "]']").after(errorEndHtml);
alert(errorEndTip);
return false;
}
});
if(!submitForm)
{
setTimeout(function(){$('#submit').removeAttr('disabled')}, 500);
return false;
}
});
</script>
<?php include '../../common/view/footer.html.php';?>