* change for merge program.

This commit is contained in:
z
2020-06-12 09:07:07 +08:00
parent 18337e6ae0
commit da8d8b55d3
9 changed files with 460 additions and 6 deletions

View File

@@ -154,8 +154,139 @@ class upgrade extends control
{
if($_POST)
{
$now = helper::now();
if($type == 'productline')
{
foreach($this->post->newPrograms as $lineID => $programName)
{
if(empty($_POST['products'][$lineID])) continue;
$linkedProducts = $this->post->products[$lineID];
$linkedProjects = zget($this->post->projects, $lineID, array());
/* Create Program. */
$programID = $this->upgrade->createProgram($programName, $linkedProducts, $linkedProjects);
/* Change program field for product and project. */
$this->upgrade->setProductProgram($programID, $linkedProducts);
if($linkedProjects) $this->upgrade->setProjectProgram($programID, $linkedProjects);
/* Set program team. */
/* Process unlinked product. */
foreach($linkedProducts as $productID)
{
unset($_POST['productIdList'][$lineID][$productID]);
foreach($linkedProjects as $projectID) unset($_POST['projectIdList'][$lineID][$productID][$projectID]);
}
if($_POST['productIdList'][$lineID])
{
foreach($_POST['productIdList'][$lineID] as $productID) unset($_POST['projectIdList'][$lineID][$productID]);
}
if($_POST['productIdList'][$lineID]) $this->dao->update(TABLE_PRODUCT)->set('line')->eq(0)->where('id')->in($_POST['productIdList'][$lineID])->exec();
if($_POST['projectIdList'][$lineID])
{
$projectIdList = array();
foreach($_POST['projectIdList'][$lineID] as $productID => $projects)
{
if(empty($projects)) continue;
foreach($projects as $projectID) $projectIdList[$projectID] = $projectID;
}
if($projectIdList) $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($projectIdList)->exec();
}
}
}
elseif($type == 'product')
{
$linkedProducts = $this->post->products;
$linkedProjects = $this->post->projects;
if(isset($_POST['newProgram']))
{
$programName = $this->post->programName;
if(empty($programName)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->program)));
/* Create Program. */
$programID = $this->upgrade->createProgram($programName, $linkedProducts, $linkedProjects);
}
else
{
$programID = $this->post->programs[$i];
}
/* Change program field for product and project. */
$this->upgrade->setProductProgram($programID, $linkedProducts);
if($linkedProjects) $this->upgrade->setProjectProgram($programID, $linkedProjects);
/* Set program team. */
/* Process unlinked product. */
foreach($linkedProducts as $productID)
{
unset($_POST['productIdList'][$productID]);
foreach($linkedProjects as $projectID) unset($_POST['projectIdList'][$productID][$projectID]);
}
if($_POST['productIdList'])
{
foreach($_POST['productIdList'] as $productID) unset($_POST['projectIdList'][$productID]);
}
if($_POST['projectIdList'])
{
$projectIdList = array();
foreach($_POST['projectIdList'] as $productID => $projects)
{
if(empty($projects)) continue;
foreach($projects as $projectID) $projectIdList[$projectID] = $projectID;
}
if($projectIdList) $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($projectIdList)->exec();
}
}
elseif($type == 'project')
{
$linkedProjects = $this->post->projects;
if(isset($_POST['newProgram']))
{
$programName = $this->post->programName;
if(empty($programName)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->program)));
/* Create Program. */
$programID = $this->upgrade->createProgram($programName, array(), $linkedProjects);
}
else
{
$programID = $this->post->programs[$i];
}
$this->upgrade->createProduct4Program($programID);
/* Change program field for product and project. */
$this->upgrade->setProjectProgram($programID, $linkedProjects);
/* Set program team. */
}
elseif($type == 'moreLink')
{
foreach($this->post->programs as $i => $programID)
{
$projectID = $this->post->projects[$i];
/* Change program field for product and project. */
$this->upgrade->setProjectProgram($programID, array($projectID));
/* Set program team. */
}
}
die(js::locate($this->createLink('upgrade', 'mergeProgram', "type=$type"), 'parent'));
}
$noMergedProductCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('deleted')->eq(0)->fetch('count');
$noMergedProjectCount = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('program')->eq(0)->andWhere('template')->eq('')->andWhere('deleted')->eq(0)->fetch('count');
if(empty($noMergedProductCount) and empty($noMergedProjectCount)) die(js::locate($this->createLink('upgrade', 'programPriv')));
$this->view->noMergedProductCount = $noMergedProductCount;
$this->view->noMergedProjectCount = $noMergedProjectCount;
$this->view->type = $type;
if($type == 'productline')
{
@@ -232,6 +363,8 @@ class upgrade extends control
$projectProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->in(array_keys($noMergedProjects))->fetchGroup('project', 'product');
foreach($projectProducts as $projectID => $products) unset($noMergedProjects[$projectID]);
if(empty($noMergedProjects)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=moreLink'));
$this->view->noMergedProjects = $noMergedProjects;
}
if($type == 'moreLink')
@@ -245,7 +378,7 @@ class upgrade extends control
foreach($products as $productID => $data) $productPairs[$productID] = $productID;
}
$programes = $this->dao->select('t1.*,t2.id as productID')->from(TABLE_PROJECT)->alias('t1')
$programs = $this->dao->select('t1.*,t2.id as productID')->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.id=t2.program')
->where('t2.id')->in($productPairs)
->fetchAll('productID');
@@ -253,7 +386,7 @@ class upgrade extends control
foreach($noMergedProjects as $projectID => $project)
{
$products = zget($projectProducts, $projectID, array());
foreach($projects as $productID => $data)
foreach($products as $productID => $data)
{
$program = zget($programs, $productID, '');
if($program) $project->programs[$program->id] = $program->name;
@@ -263,6 +396,10 @@ class upgrade extends control
$this->view->noMergedProjects = $noMergedProjects;
}
$this->view->title = $this->lang->upgrade->mergeProgram;
$this->view->programs = $this->dao->select('*')->from(TABLE_PROJECT)->where('program')->eq(0)->andWhere('deleted')->eq(0)->andWhere('template')->eq('scrum')->fetchPairs('id', 'name');
$this->view->users = $this->loadModel('user')->getPairs();
$this->display();
}

View File

@@ -0,0 +1,2 @@
.modal-dialog{width:100%;}
#programName {border-left-color:#dcdcdc !important;}

View File

@@ -0,0 +1,43 @@
$(function()
{
$('[name^=products]').change(function()
{
value = $(this).val();
if($(this).prop('checked'))
{
$('[data-product=' + value + ']').prop('checked', true)
}
else
{
$('[data-product=' + value + ']').prop('checked', false)
}
})
$('[name^=projects]').change(function()
{
if($(this).prop('checked'))
{
var productID = $(this).attr('data-product');
if($('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true);
}
})
toggleProgram($('form #newProgram0'));
});
function toggleProgram(obj)
{
$obj = $(obj);
$programs = $obj.closest('.input-group').find('[id^=programs]');
$programName = $obj.closest('.input-group').find('[id^=programName]');
if($obj.prop('checked'))
{
$programs.addClass('hidden');
$programName.removeClass('hidden');
}
else
{
$programs.removeClass('hidden');
$programName.addClass('hidden');
}
}

View File

@@ -74,11 +74,14 @@ $lang->upgrade->to15Desc = <<<EOD
</div>
EOD;
$lang->upgrade->line = '产品线';
$lang->upgrade->program = '项目名称';
$lang->upgrade->product = $lang->productCommon;
$lang->upgrade->project = $lang->projectCommon;
$lang->upgrade->line = '产品线';
$lang->upgrade->program = '项目名称';
$lang->upgrade->programAdmin = '项目管理员';
$lang->upgrade->product = $lang->productCommon;
$lang->upgrade->project = $lang->projectCommon;
$lang->upgrade->newProgram = '新建';
$lang->upgrade->mergeSummary = "尊敬的用户,您的系统中共有%s个产品%s个迭代等待迁移。经系统计算我们推荐您的迁移方案如下您也可以根据自己的情况进行调整";
$lang->upgrade->mergeByProductLine = "以产品线组织的产品和迭代:将整个产品线及其下面的产品和迭代归并到一个大项目中。";
$lang->upgrade->mergeByProduct = "以产品组织的迭代:可以选择多个产品及其下面的迭代归并到一个大项目中,也可以选择某一个产品将其下面所属的迭代归并到大项目中。";
$lang->upgrade->mergeByProject = "独立的迭代:可以选择若干迭代归并到一个大项目中,也可以独立归并。";

View File

@@ -3751,6 +3751,101 @@ class upgradeModel extends model
fwrite($fh, $log);
}
public function createProgram($programName, $productIdList = array(), $projectIdList = array())
{
$program = new stdclass();
$program->name = $programName;
$program->template = 'scrum';
$program->category = count($productIdList) > 1 ? 'multiple' : 'single';
$program->status = 'wait';
$program->openedBy = $this->app->user->account;
$program->openedDate = helper::now();
$program->acl = 'open';
$begin = helper::today();
$end = helper::today();
if($productIdList)
{
$products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll('id');
foreach($products as $product)
{
if(empty($begin)) $begin = $product->createdDate;
if($product->createdDate < $begin) $begin = $product->createdDate;
}
}
if($projectIdList)
{
$projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchAll('id');
foreach($projects as $project)
{
if($begin > $project->begin) $begin = $project->begin;
if($end < $project->end) $end = $project->end;
}
}
if(empty($projectIdList)) $end = date('Y-m-d', '+1 year');
$program->begin = $begin;
$program->end = $end;
$this->dao->insert(TABLE_PROJECT)->data($program)->exec();
$programID = $this->dao->lastInsertId();
$this->dao->update(TABLE_PROJECT)->set('code')->eq('pgm' . $programID)->where('id')->eq($programID)->exec();
return $programID;
}
public function createProduct4Program($programID)
{
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
$product = new stdclass();
$product->name = $program->name;
$product->code = $program->code;
$product->program = $program->id;
$product->type = 'normal';
$product->status = 'normal';
$product->acl = $program->acl;
$product->whitelist = $program->whitelist;
$product->createdBy = $program->createdBy;
$product->createdDate = $program->createdDate;
$product->createdVersion = $this->config->version;
$this->dao->insert(TABLE_PRODUCT)->data($product)->exec();
$productID = $this->dao->lastInsertId();
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID * 5)->where('id')->eq($productID)->exec();
$this->app->loadLang('doc');
$lib = new stdclass();
$lib->product = $productID;
$lib->name = $this->lang->doclib->main['product'];
$lib->type = 'product';
$lib->main = '1';
$lib->acl = 'default';
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product');
}
public function setProductProgram($programID, $productIdList = array())
{
$this->dao->update(TABLE_PRODUCT)->set('program')->eq($programID)->where('id')->in($productIdList)->exec();
$this->dao->update(TABLE_STORY)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_BUG)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_RELEASE)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_CASE)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_TESTREPORT)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_TESTSUITE)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_BUILD)->set('program')->eq($programID)->where('product')->in($productIdList)->exec();
$this->dao->update(TABLE_DOC)->set('program')->eq($programID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'product' and product " . helper::dbIN($productIdList) . ')')->exec();
}
public function setProjectProgram($programID, $projectIdList = array())
{
$this->dao->update(TABLE_PROJECT)->set('program')->eq($programID)->where('id')->in($projectIdList)->exec();
$this->dao->update(TABLE_TASK)->set('program')->eq($programID)->where('project')->in($projectIdList)->exec();
$this->dao->update(TABLE_DOC)->set('program')->eq($programID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'project' and project " . helper::dbIN($projectIdList) . ')')->exec();
}
/**
* Append execute for pro and biz.
*

View File

@@ -0,0 +1,35 @@
<table class='table table-form'>
<thead>
<tr>
<th><?php echo $lang->upgrade->program;?></th>
<th><?php echo $lang->upgrade->programAdmin;?></th>
<th><?php echo $lang->upgrade->line;?></th>
<th><?php echo $lang->upgrade->product;?></th>
<th><?php echo $lang->upgrade->project;?></th>
</tr>
</thead>
<tbody>
<?php foreach($productlines as $line):?>
<?php if(!isset($lineGroups[$line->id])) continue;?>
<tr>
<td class='text-top'><?php echo html::input("newPrograms[$line->id]", $line->name, "class='form-control'");?></td>
<td class='text-top'><?php echo html::select("account[$line->id]", $users, '', "class='form-control chosen'");?></td>
<td class='text-top'><?php echo $line->name;?></td>
<td class='text-top'>
<?php $projectHtml = '';?>
<?php foreach($lineGroups[$line->id] as $productID => $product):?>
<?php echo html::checkBox("products[$line->id]", array($productID => "{$lang->productCommon} #{$product->id} {$product->name}"), $product->id, "data-productid='{$product->id}'");?>
<?php echo html::hidden("productIdList[$line->id][$productID]", $productID);?>
<?php if(isset($productGroups[$productID])):?>
<?php foreach($productGroups[$productID] as $project):?>
<?php $projectHtml .= html::checkBox("projects[$line->id]", array($project->id => "{$lang->projectCommon} #{$project->id} {$project->name}"), $project->id, "data-product='{$product->id}'");?>
<?php $projectHtml .= html::hidden("projectIdList[$line->id][$productID][$project->id]", $project->id);?>
<?php endforeach;?>
<?php endif;?>
<?php endforeach;?>
</td>
<td><?php echo $projectHtml;?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>

View File

@@ -0,0 +1,47 @@
<table class='table table-form'>
<thead>
<tr>
<th><?php echo $lang->upgrade->program;?></th>
<th><?php echo $lang->upgrade->programAdmin;?></th>
<th><?php echo $lang->upgrade->product;?></th>
<th><?php echo $lang->upgrade->project;?></th>
</tr>
</thead>
<tbody>
<?php $i = 0;?>
<?php foreach($noMergedProducts as $productID => $product):?>
<tr>
<?php if($i == 0):?>
<td class='text-top' rowspan='<?php echo count($noMergedProducts);?>'>
<div class='input-group'>
<?php echo html::select("programs", $programs, '', "class='form-control chosen'");?>
<?php echo html::input("programName", '', "class='form-control'");?>
<span class='input-group-addon'>
<div class="checkbox-primary">
<input type="checkbox" name="newProgram" value="0" checked onchange="toggleProgram(this)" id="newProgram0" />
<label for="newProgram0"><?php echo $lang->upgrade->newProgram;?></label>
</div>
</span>
</div>
</td>
<td class='text-top' rowspan='<?php echo count($noMergedProducts);?>'><?php echo html::select("account", $users, '', "class='form-control chosen'");?></td>
<?php endif;?>
<td class='text-top'>
<?php
echo html::checkBox("products", array($product->id => "{$lang->productCommon} #{$product->id} {$product->name}"), $product->id, "data-productid='{$product->id}'");
echo html::hidden("productIdList[$product->id]", $product->id);
?>
</td>
<td>
<?php if(isset($productGroups[$productID])):?>
<?php foreach($productGroups[$productID] as $project):?>
<?php echo html::checkBox("projects", array($project->id => "{$lang->projectCommon} #{$project->id} {$project->name}"), $project->id, "data-product='{$productID}'");?>
<?php echo html::hidden("projectIdList[$productID][$project->id]", $project->id);?>
<?php endforeach;?>
<?php endif;?>
</td>
</tr>
<?php $i++;?>
<?php endforeach;?>
</tbody>
</table>

View File

@@ -0,0 +1,33 @@
<table class='table table-form'>
<thead>
<tr>
<th><?php echo $lang->upgrade->program;?></th>
<th><?php echo $lang->upgrade->programAdmin;?></th>
<th><?php echo $lang->upgrade->project;?></th>
</tr>
</thead>
<tbody>
<?php $i = 0;?>
<?php foreach($noMergedProjects as $projectID => $project):?>
<tr>
<?php if($i == 0):?>
<td class='text-top' rowspan='<?php echo count($noMergedProjects);?>'>
<div class='input-group'>
<?php echo html::select("programs", $programs, '', "class='form-control chosen'");?>
<?php echo html::input("programName", '', "class='form-control'");?>
<span class='input-group-addon'>
<div class="checkbox-primary">
<input type="checkbox" name="newProgram" value="0" checked onchange="toggleProgram(this)" id="newProgram0" />
<label for="newProgram0"><?php echo $lang->upgrade->newProgram;?></label>
</div>
</span>
</div>
</td>
<td class='text-top' rowspan='<?php echo count($noMergedProjects);?>'><?php echo html::select("account", $users, '', "class='form-control chosen'");?></td>
<?php endif;?>
<td><?php echo html::checkBox("projects", array($project->id => "{$lang->projectCommon} #{$project->id} {$project->name}"), $project->id);?></td>
</tr>
<?php $i++;?>
<?php endforeach;?>
</tbody>
</table>

View File

@@ -0,0 +1,59 @@
<?php
/**
* The mergeProgram view file of upgrade module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package upgrade
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<div class='container'>
<form method='post' target='hiddenwin'>
<div class='modal-dialog'>
<div class='modal-header'>
<strong><?php echo $lang->upgrade->mergeProgram;?></strong>
</div>
<div class='modal-body'>
<div class='alert alert-info'>
<?php
printf($lang->upgrade->mergeSummary, $noMergedProductCount, $noMergedProjectCount);
if($type == 'productline') echo '<br />' . $lang->upgrade->mergeByProductLine;
if($type == 'product') echo '<br />' . $lang->upgrade->mergeByProduct;
if($type == 'project') echo '<br />' . $lang->upgrade->mergeByProject;
if($type == 'moreLink') echo '<br />' . $lang->upgrade->mergeByMoreLink;
?>
</div>
<?php if($type == 'productline'):?>
<?php include './mergebyline.html.php';?>
<?php elseif($type == 'product'):?>
<?php include './mergebyproduct.html.php';?>
<?php elseif($type == 'project'):?>
<?php include './mergebyproject.html.php';?>
<?php elseif($type == 'moreLink'):?>
<table class='table table-form'>
<thead>
<tr>
<th><?php echo $lang->upgrade->program;?></th>
<th><?php echo $lang->upgrade->project;?></th>
</tr>
</thead>
<tbody>
<?php foreach($noMergedProjects as $projectID => $project):?>
<tr>
<td><?php echo html::select("programs[]", $project->programs, '', "class='form-control chosen'");?></td>
<td><?php echo "{$lang->projectCommon} #{$project->id} {$project->name}" . html::hidden("projects[]", $project->id);?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php endif;?>
</div>
<div class='modal-footer'><?php echo html::submitButton();?></div>
</div>
</form>
</div>
<?php include '../../common/view/footer.lite.html.php';?>