* Finish task #36028,#36068,#36072.

This commit is contained in:
Yagami
2021-02-22 11:05:30 +08:00
parent 98cea3e643
commit b668ce1970
7 changed files with 108 additions and 33 deletions
+2 -1
View File
@@ -439,11 +439,12 @@ class upgrade extends control
}
$programs = $this->upgrade->getProgramPairs();
$currentProgramID = $programID ? $programID : key($programs);
$this->view->title = $this->lang->upgrade->mergeProgram;
$this->view->programs = $programs;
$this->view->programID = $programID;
$this->view->projects = array('' => '') + $this->upgrade->getProjectPairsByProgram(key($programs));
$this->view->projects = array('' => '') + $this->upgrade->getProjectPairsByProgram($currentProgramID);
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noempty');
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
+37 -1
View File
@@ -126,7 +126,7 @@ function getProjectByProgram(obj)
function toggleProgram(obj)
{
var $obj = $(obj);
var $obj = $(obj);
if($obj.length == 0) return false;
var $programs = $obj.closest('table').find('#programs');
@@ -135,6 +135,7 @@ function toggleProgram(obj)
$('form .pgm-no-exist').removeClass('hidden');
$('form .pgm-exist').addClass('hidden');
$programs.attr('disabled', 'disabled');
$('#PGMStatus').closest('.PGMParams').show();
$('form #newProject0').prop('checked', true);
toggleProject($('form #newProject0'));
@@ -143,6 +144,7 @@ function toggleProgram(obj)
{
$('form .pgm-exist').removeClass('hidden');
$('form .pgm-no-exist').addClass('hidden');
$('#PGMStatus').closest('.PGMParams').hide();
$programs.removeAttr('disabled');
}
}
@@ -176,6 +178,38 @@ function toggleProject(obj)
}
}
function setPRJStatus()
{
var PRJStatus = 'closed';
$(':checkbox:checked[data-status]').each(function()
{
var status = $(this).attr('data-status');
if(status == 'doing' || status == 'suspended')
{
PRJStatus = 'doing';
return false;
}
if(status == 'wait') PRJStatus = 'wait';
});
if($(':checkbox:checked[data-status]').length == 0) PRJStatus = 'wait';
$('#PRJStatus').val(PRJStatus);
$('#PRJStatus').trigger('chosen:updated');
setPGMStatus(PRJStatus);
}
function setPGMStatus(PRJStatus)
{
var PGMStatus = 'wait';
if(PRJStatus != 'wait') PGMStatus = 'doing';
if(PRJStatus == 'closed') PGMStatus = 'closed';
$('#PGMStatus').val(PGMStatus);
$('#PGMStatus').trigger('chosen:updated');
}
function setPGMBegin(PGMBegin)
{
$(':checkbox:checked[data-begin]').each(function()
@@ -189,6 +223,8 @@ function setPGMBegin(PGMBegin)
$('.PGMParams #begin').val(PGMBegin);
}
});
setPRJStatus();
}
function setPGMEnd(PGMEnd)
+57 -27
View File
@@ -3998,7 +3998,7 @@ class upgradeModel extends model
$program = new stdclass();
$program->name = $data->PGMName;
$program->type = 'program';
$program->status = 'wait';
$program->status = $data->PGMStatus;
$program->begin = $data->begin;
$program->end = isset($data->end) ? $data->end : '';
$program->openedBy = $account;
@@ -4042,7 +4042,7 @@ class upgradeModel extends model
$project->type = 'project';
$project->model = 'scrum';
$project->parent = $programID;
$project->status = 'wait';
$project->status = $data->PRJStatus;
$project->begin = $data->begin;
$project->end = isset($data->end) ? $data->end : '';
$project->PM = $data->PM;
@@ -4115,29 +4115,9 @@ class upgradeModel extends model
{
$projectStory = $sprintStory;
$projectStory->project = $projectID;
$this->dao->insert(TABLE_PROJECTSTORY)->data($projectStory)->exec();
$this->dao->replace(TABLE_PROJECTSTORY)->data($projectStory)->exec();
}
/* Compute project date. */
$linkedSprintIdList = $this->dao->select('id')->from(TABLE_PROJECT)->where('project')->eq($projectID)->fetchPairs();
$linkedSprintIdList += $sprintIdList;
$undoneSprints = $this->dao->select("count('*') as count")->from(TABLE_PROJECT)->where('id')->in($linkedSprintIdList)->andWhere('status')->ne('closed')->fetch('count');
$minRealBegan = $this->dao->select('date')->from(TABLE_ACTION)->where('objectID')->in($linkedSprintIdList)->andWhere('objectType')->eq('project')->andWhere('action')->eq('started')->orderBy('date_asc')->fetch('date');
$maxRealEnd = $this->dao->select('date')->from(TABLE_ACTION)->where('objectID')->in($linkedSprintIdList)->andWhere('objectType')->eq('project')->andWhere('action')->eq('closed')->orderBy('date_desc')->fetch('date');
$data = new stdClass();
$data->realBegan = $minRealBegan ? substr($minRealBegan, 0, 10) : '0000-00-00';
if($maxRealEnd and !$undoneSprints)
{
$data->realEnd = substr($maxRealEnd, 0, 10);
$data->closedDate = $maxRealEnd;
$data->status = 'closed';
}
$this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($projectID)->exec();
if($maxRealEnd and !$undoneSprints) $this->loadModel('action')->create('project', $projectID, 'closedbysystem');
/* Compute product acl. */
$products = $this->dao->select('id,program,acl')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll();
foreach($products as $product)
@@ -4167,7 +4147,32 @@ class upgradeModel extends model
$this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($sprint->id)->exec();
}
/* Set product and project relation. */
/* Compute project date and status. */
$linkedSprintIdList = $this->dao->select('id')->from(TABLE_PROJECT)->where('project')->eq($projectID)->fetchPairs();
$linkedSprintIdList += $sprintIdList;
$minRealBegan = $this->dao->select('date')->from(TABLE_ACTION)->where('objectID')->in($linkedSprintIdList)->andWhere('objectType')->eq('project')->andWhere('action')->eq('started')->orderBy('date_asc')->fetch('date');
$maxRealEnd = $this->dao->select('date')->from(TABLE_ACTION)->where('objectID')->in($linkedSprintIdList)->andWhere('objectType')->eq('project')->andWhere('action')->eq('closed')->orderBy('date_desc')->fetch('date');
$PRJStatus = $this->computeStatus($projectID);
$data = new stdClass();
$data->realBegan = $minRealBegan ? substr($minRealBegan, 0, 10) : '0000-00-00';
$data->status = $PRJStatus;
if($PRJStatus == 'closed')
{
$data->realEnd = substr($maxRealEnd, 0, 10);
$data->closedDate = $maxRealEnd;
}
$this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($projectID)->exec();
if($PRJStatus == 'closed') $this->loadModel('action')->create('project', $projectID, 'closedbysystem');
/* Compute program status. */
$PGMStatus = $this->computeStatus($programID);
$this->dao->update(TABLE_PROJECT)->set('status')->eq($PGMStatus)->where('id')->eq($programID)->exec();
if($PGMStatus == 'closed') $this->loadModel('action')->create('program', $programID, 'closedbysystem');
/* Set product and project relation. */
foreach($productIdList as $productID)
{
$data = new stdclass();
@@ -4180,9 +4185,34 @@ class upgradeModel extends model
$this->computeObjectMembers($programID, $projectID, $productIdList, $sprintIdList);
}
/**
* Compute program and project members.
*
/**
* Compute project or program status.
*
* @param int $objectID
* @access public
* @return string
*/
public function computeStatus($objectID)
{
$objects = $this->dao->select('id, status')->from(TABLE_PROJECT)->where('parent')->eq($objectID)->fetchPairs();
$objectStatus = empty($objects) ? 'wait' : 'closed';
foreach($objects as $status)
{
if($status == 'doing' || $status == 'suspended')
{
$objectStatus = 'doing';
break;
}
if($status == 'wait') $objectStatus = 'wait';
}
return $objectStatus;
}
/**
* Compute program and project members.
*
* @param int $programID
* @param int $projectID
* @param array $productIdList
@@ -20,6 +20,10 @@
</div>
</td>
</tr>
<tr class='PGMParams'>
<th><?php echo $lang->program->PGMCommon . $lang->program->PGMStatus;?></th>
<td><?php echo html::select('PGMStatus', $lang->program->statusList, '', "class='form-control chosen'");?></td>
</tr>
<tr>
<th>
<span class="prj-exist hidden"><?php echo $lang->upgrade->existPRJ;?></span>
@@ -40,6 +44,10 @@
</div>
</td>
</tr>
<tr class='PGMParams'>
<th><?php echo $lang->program->PRJCommon . $lang->program->PRJStatus;?></th>
<td><?php echo html::select('PRJStatus', $lang->program->statusList, '', "class='form-control chosen'");?></td>
</tr>
<tr class='PGMParams'>
<th><?php echo $lang->program->PRJPM;?></th>
<td><?php echo html::select('PM', array('' => '') + $users, '', "class='form-control chosen'");?></td>
+2 -2
View File
@@ -37,14 +37,14 @@
<?php foreach($lineGroups[$line->id] as $productID => $product):?>
<div class='lineGroup'>
<div class='productList'>
<?php echo html::checkBox("products[$line->id]", array($productID => "{$lang->productCommon} #{$product->id} {$product->name}"), $i == 0 ? $product->id : 0, "title='{$product->name}' data-productid='{$product->id}' data-line='{$line->id}' data-begin='{$product->createdDate}'");?>
<?php echo html::checkBox("products[$line->id]", array($productID => $product->name), $i == 0 ? $product->id : 0, "title='{$product->name}' data-productid='{$product->id}' data-line='{$line->id}' data-begin='{$product->createdDate}'");?>
<?php echo html::hidden("productIdList[$line->id][$productID]", $productID);?>
</div>
<div class='projectList'>
<div class='scroll-handle'>
<?php if(isset($productGroups[$productID])):?>
<?php foreach($productGroups[$productID] as $sprint):?>
<?php echo html::checkBox("sprints[$line->id][$productID]", array($sprint->id => "{$lang->upgrade->project} #{$sprint->id} {$sprint->name}"), $i == 0 ? $sprint->id : 0, "title='{$sprint->name}' data-product='{$product->id}' data-line='{$line->id}' data-begin='{$sprint->begin}' data-end='{$sprint->end}'");?>
<?php echo html::checkBox("sprints[$line->id][$productID]", array($sprint->id => $sprint->name), $i == 0 ? $sprint->id : 0, "title='{$sprint->name}' data-product='{$product->id}' data-line='{$line->id}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}'");?>
<?php echo html::hidden("sprintIdList[$line->id][$productID][$sprint->id]", $sprint->id);?>
<?php endforeach;?>
<?php endif;?>
+1 -1
View File
@@ -26,7 +26,7 @@
<div class='scroll-handle'>
<?php if(isset($productGroups[$productID])):?>
<?php foreach($productGroups[$productID] as $sprint):?>
<?php echo html::checkBox("sprints[$productID]", array($sprint->id => "{$sprint->name}"), $isChecked ? $sprint->id : '', "data-product='{$productID}' data-begin='{$sprint->begin}' data-end='{$sprint->end}'");?>
<?php echo html::checkBox("sprints[$productID]", array($sprint->id => "{$sprint->name}"), $isChecked ? $sprint->id : '', "data-product='{$productID}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}'");?>
<?php echo html::hidden("sprintIdList[$productID][$sprint->id]", $sprint->id);?>
<?php endforeach;?>
<?php endif;?>
+1 -1
View File
@@ -12,7 +12,7 @@
</div>
<div class='line-groups'>
<?php foreach($noMergedSprints as $sprintID => $sprint):?>
<?php echo html::checkBox("sprints", array($sprint->id => "{$lang->upgrade->project} #{$sprint->id} {$sprint->name}"), $sprint->id, "data-begin='{$sprint->begin}' data-end='{$sprint->end}'");?>
<?php echo html::checkBox("sprints", array($sprint->id => "{$lang->upgrade->project} #{$sprint->id} {$sprint->name}"), $sprint->id, "data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}'");?>
<?php endforeach;?>
</div>
</div>