* finish task #7708.

This commit is contained in:
z
2020-08-27 10:59:38 +08:00
parent a5f004beab
commit 5674cdbae8
8 changed files with 119 additions and 31 deletions
+24
View File
@@ -1,6 +1,30 @@
$(function()
{
$('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')});
$('#isCat').change(function()
{
if($(this).prop('checked'))
{
$('#longTimeBox').removeClass('hidden');
}
else
{
$('#longTimeBox').addClass('hidden');
$('#longTimeBox').find('#longTime').prop('checked', false).change();
}
});
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').val('').attr('disabled', 'disabled');
}
else
{
$('#end').removeAttr('disabled');
}
});
});
function setCopyProject(copiedProgramID)
+31
View File
@@ -0,0 +1,31 @@
$(function()
{
var endDate = $('#end').val();
$('#isCat').change(function()
{
if($(this).prop('checked'))
{
$('#longTimeBox').removeClass('hidden');
$('#longTime').change();
}
else
{
$('#longTimeBox').addClass('hidden');
$('#longTimeBox').find('#longTime').prop('checked', false).change();
}
});
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').val('').attr('disabled', 'disabled');
}
else
{
$('#end').val(endDate).removeAttr('disabled');
}
});
$('#isCat').change();
});
+2
View File
@@ -65,6 +65,7 @@ $lang->program->ac = 'AC';
$lang->program->cv = 'CV%';
$lang->program->pm = 'PM';
$lang->program->teamCount = 'The Number Of Team';
$lang->program->longTime = 'Long-term Project';
$lang->program->unitList[''] = '';
$lang->program->unitList['yuan'] = 'Yuan';
@@ -120,3 +121,4 @@ $lang->program->beginLetterParent = "Begin date of parent project: %s, Begin da
$lang->program->endGreaterParent = "End date of parent project: %s, End date cannot be greater than the end date of parent project.";
$lang->program->beginGreateChild = "Minimum begin date of child project: %s, the begin date of parent project cannot be greater than the minimum begin date of child project.";
$lang->program->endLetterChild = "Maximum end date of child project: %s, the end date of parent project cannot be less than the maximum end date of child project.";
$lang->program->childLongTime = "There are long-term projects in the sub project, and the parent project should also be a long-term project";
+2
View File
@@ -65,6 +65,7 @@ $lang->program->ac = 'AC';
$lang->program->cv = 'CV%';
$lang->program->pm = '项目负责人';
$lang->program->teamCount = '项目成员';
$lang->program->longTime = '长期项目';
$lang->program->unitList[''] = '';
$lang->program->unitList['yuan'] = '元';
@@ -120,3 +121,4 @@ $lang->program->beginLetterParent = "父项目的开始日期:%s,开始日
$lang->program->endGreaterParent = "父项目的完成日期:%s,完成日期不能大于父项目的完成日期";
$lang->program->beginGreateChild = "子项目的最小开始日期:%s,父项目的开始日期不能大于子项目的最小开始日期";
$lang->program->endLetterChild = "子项目的最大完成日期:%s,父项目的完成日期不能小于子项目的最大完成日期";
$lang->program->childLongTime = "子项目中有长期项目,父项目也应该是长期项目";
+43 -28
View File
@@ -247,26 +247,38 @@ class programModel extends model
->add('type', 'program')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setDefault('openedBy', $this->app->user->account)
->setDefault('end', '')
->setDefault('openedDate', helper::now())
->setDefault('team', substr($this->post->name, 0, 30))
->join('whitelist', ',')
->cleanInt('budget')
->stripTags($this->config->program->editor->create['id'], $this->config->allowedTags)
->remove('products, workDays, delta, branch, uid, plans')
->remove('products, workDays, delta, branch, uid, plans, longTime')
->get();
if($project->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($project->parent)->fetch();
if($project->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
if($project->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if(dao::isError()) return false;
if($parentProgram)
{
/* Child project begin cannot less than parent. */
if($project->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
/* When parent set end then child project end cannot greater than parent. */
if($parentProgram->end != '0000-00-00' and $project->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
/* When parent set end then child project cannot set longTime. */
if(empty($project->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if(dao::isError()) return false;
}
}
$requiredFields = $this->config->program->create->requiredFields;
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_PROJECT)->data($project)
->autoCheck()
->batchcheck($this->config->program->create->requiredFields, 'notempty')
->batchcheck($requiredFields, 'notempty')
->check('name', 'unique', "deleted='0'")
->check('code', 'unique', "deleted='0'")
->exec();
@@ -343,15 +355,16 @@ class programModel extends model
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROJECT)->fetch();
$program = fixer::input('post')
->setDefault('team', $this->post->name)
->setDefault('end', '')
->setDefault('isCat', 0)
->setIF($this->post->begin == '0000-00-00', 'begin', '')
->setIF($this->post->end == '0000-00-00', 'end', '')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setIF($this->post->acl == 'custom' and !isset($_POST['whitelist']), 'whitelist', '')
->setDefault('team', $this->post->name)
->setDefault('isCat', 0)
->join('whitelist', ',')
->stripTags($this->config->program->editor->edit['id'], $this->config->allowedTags)
->remove('products, branch, uid, plans')
->remove('products, branch, uid, plans, longTime')
->get();
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid);
@@ -361,23 +374,33 @@ class programModel extends model
if(!empty($program->isCat))
{
$minChildBegin = $this->dao->select('min(begin) as minBegin')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->fetch('minBegin');
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->fetch('maxEnd');
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->ne('0000-00-00')->fetch('maxEnd');
if($minChildBegin and $program->begin > $minChildBegin) dao::$errors['begin'] = sprintf($this->lang->program->beginGreateChild, $minChildBegin);
if($maxChildEnd and $program->end < $maxChildEnd) dao::$errors['end'] = sprintf($this->lang->program->endLetterChild, $maxChildEnd);
$longTimeCount = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->eq('0000-00-00')->fetch('count');
if(!empty($program->end) and $longTimeCount != 0) dao::$errors['end'] = $this->lang->program->childLongTime;
}
if($program->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($program->parent)->fetch();
if($parentProgram and $program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
if($parentProgram and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if($parentProgram)
{
if($program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
if($parentProgram->end != '0000-00-00' and $project->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if(empty($project->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
}
}
if(dao::isError()) return false;
$requiredFields = $this->config->program->edit->requiredFields;
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$this->dao->update(TABLE_PROJECT)->data($program)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->program->edit->requiredFields, 'notempty')
->batchcheck($requiredFields, 'notempty')
->checkIF($program->begin != '', 'begin', 'date')
->checkIF($program->end != '', 'end', 'date')
->checkIF($program->end != '', 'end', 'gt', $program->begin)
@@ -447,6 +470,13 @@ class programModel extends model
if(empty($program)) return true;
if($program->isCat and $action == 'group') return false;
if($program->isCat and $action == 'managemembers') return false;
if($program->isCat and $action == 'start') return false;
if($program->isCat and $action == 'activate') return false;
if($program->isCat and $action == 'suspend') return false;
if($program->isCat and $action == 'close') return false;
if($action == 'start') return $program->status == 'wait' or $program->status == 'suspended';
if($action == 'finish') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'close') return $program->status != 'closed';
@@ -466,23 +496,8 @@ class programModel extends model
public function checkHasContent($programID)
{
$count = 0;
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_BUDGET)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_BUG)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_CASE)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_DESIGN)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_DOC)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_DURATIONESTIMATION)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_ISSUE)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_RELATION)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_RELEASE)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_REPO)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_RISK)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_STORY)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TESTREPORT)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TESTSUITE)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TESTTASK)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_WORKESTIMATION)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TASK)->where('program')->eq($programID)->fetch('count');
return $count > 0;
}
+1 -1
View File
@@ -28,7 +28,7 @@
</td>
<td class='text-left'><?php echo $program->code;?></td>
<td class='text-left pgm-title table-nest-title' title='<?php echo $program->name?>'>
<?php echo html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?>
<?php echo $program->isCat ? $program->name : html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?>
</td>
<td class='c-status'><span class="status-program status-<?php echo $program->status?>"><?php echo zget($lang->project->statusList, $program->status, '');?></span></td>
<td class='text-center'><?php echo $program->begin;?></td>
+9 -1
View File
@@ -91,9 +91,17 @@
<?php echo html::input('begin', date('Y-m-d'), "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->begin . "' required");?>
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
<?php echo html::input('end', '', "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->end . "' required");?>
<?php if(empty($parentProgram) or $parentProgram->end == '0000-00-00'):?>
<span class='input-group-addon hidden' id='longTimeBox'>
<div class="checkbox-primary">
<input type="checkbox" name="longTime" value="1" id="longTime">
<label for="longTime"><?php echo $lang->program->longTime;?></label>
</div>
</span>
<?php endif;?>
</div>
</td>
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBeginEnd, $parentProgram->begin, $parentProgram->end);?></td>
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBeginEnd, $parentProgram->begin, $parentProgram->end == '0000-00-00' ? '' : $parentProgram->end);?></td>
</tr>
<?php if($template == 'scrum'):?>
<tr>
+7 -1
View File
@@ -60,7 +60,13 @@
<div class='input-group'>
<?php echo html::input('begin', $program->begin, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->begin . "' required");?>
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
<?php echo html::input('end', $program->end, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->end . "' required");?>
<?php echo html::input('end', $program->end == '0000-00-00' ? '' : $program->end, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->end . "' required");?>
<span class='input-group-addon hidden' id='longTimeBox'>
<div class="checkbox-primary">
<input type="checkbox" name="longTime" value="1" id="longTime" <?php if($program->end == '0000-00-00') echo "checked";?>>
<label for="longTime"><?php echo $lang->program->longTime;?></label>
</div>
</span>
</div>
</td>
<td colspan='2'></td>