* finish task #7644,7642.

This commit is contained in:
z
2020-08-20 15:52:07 +08:00
parent a95981f2a7
commit 09cfff0dbc
8 changed files with 90 additions and 12 deletions
+3
View File
@@ -269,3 +269,6 @@ CREATE TABLE `zt_taskspec` (
`deadline` date NOT NULL,
UNIQUE KEY `task` (`task`,`version`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
ALTER TABLE `zt_project` ADD `path` varchar(255) NOT NULL AFTER `parent`;
ALTER TABLE `zt_project` ADD `grade` tinyint unsigned NOT NULL AFTER `path`;
+21 -8
View File
@@ -22,7 +22,6 @@ class program extends control
$this->session->set('program', $programID);
$this->lang->navGroup->program = 'program';
$this->view->title = $this->lang->program->common . $this->lang->colon . $this->lang->program->index;
$this->view->position[] = $this->lang->program->index;
$this->view->program = $this->project->getByID($programID);
@@ -87,20 +86,19 @@ class program extends control
/**
* Create a program.
*
* @param varchar $template
* @param int $copyProgramID
* @param string $template
* @param int $programID
* @param int $copyProgramID
* @access public
* @return void
*/
public function create($template = 'cmmi', $copyProgramID = '')
public function create($template = 'cmmi', $programID = 0, $copyProgramID = '')
{
if($_POST)
{
$projectID = $this->program->create();
if(dao::isError())
{
$this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
}
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
$this->loadModel('action')->create('project', $projectID, 'opened');
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse', array('status' => 'wait', 'orderBy' => 'order_desc'))));
}
@@ -111,6 +109,19 @@ class program extends control
$whitelist = '';
$acl = 'open';
$privway = 'extend';
if($programID)
{
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
if($this->program->checkHasContent($programID))
{
echo js::alert($this->lang->program->cannotCreateChild);
die(js::locate('back'));
}
if(empty($template)) $template = $program->template;
}
if($copyProgramID)
{
$copyProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProgramID)->fetch();
@@ -120,6 +131,7 @@ class program extends control
$acl = $copyProgram->acl;
$privway = $copyProgram->privway;
$whitelist = $copyProgram->whitelist;
if(empty($template)) $template = $copyProgram->template;
}
$this->view->title = $this->lang->program->create;
@@ -134,6 +146,7 @@ class program extends control
$this->view->acl = $acl;
$this->view->privway = $privway;
$this->view->whitelist = $whitelist;
$this->view->programID = $programID;
$this->view->copyProgramID = $copyProgramID;
$this->display();
}
+2
View File
@@ -25,3 +25,5 @@
#cards .project-detail .progress-text-left .progress-text {width: 50px; left: -50px;}
#cards .pager {margin: 0; float: right;}
#cards .pager .btn{border: none}
.w-215px{width:215px;}
+2 -2
View File
@@ -3,7 +3,7 @@ $(function()
$('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')});
});
function setCopyProject(programID)
function setCopyProject(copiedProgramID)
{
location.href = createLink('program', 'create', 'template=' + template + '&copyProgramID=' + programID);
location.href = createLink('program', 'create', 'template=' + template + '&programID=' + programID + '&copyProgramID=' + copiedProgramID);
}
+2
View File
@@ -41,6 +41,7 @@ $lang->program->transfer = '进入项目';
$lang->program->setPlanduration = '设置工期';
$lang->program->export = '导出';
$lang->program->privway = '权限控制';
$lang->program->children = '子项目';
$lang->program->manageGroupMember = '维护分组用户';
$lang->program->durationEstimation = '工作量估算';
@@ -82,3 +83,4 @@ $lang->program->scrumDesc = '<strong>简介:</strong>小步迭代,
$lang->program->cmmi = '瀑布';
$lang->program->cmmiTitle = '瀑布式项目管理';
$lang->program->cmmiDesc = '<strong>简介:</strong>按阶段规范化管理<br><strong>包含功能点:</strong>估算、计划、阶段、报告';
$lang->program->cannotCreateChild = '该项目已经有实际的内容,无法直接添加子项目。您可以为当前项目创建一个父项目,然后在新的父项目下面添加子项目。';
+52
View File
@@ -5,6 +5,7 @@ class programModel extends model
{
return $this->dao->select('*')->from(TABLE_PROJECT)
->where('iscat')->eq(0)
->andWhere('template')->ne('')
->andWhere('program')->eq(0)
->andWhere('deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi()
@@ -93,6 +94,12 @@ class programModel extends model
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec();
$this->file->updateObjectID($this->post->uid, $programID, 'project');
if($project->parent > 0)
{
$this->dao->update(TABLE_PROJECT)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec();
$this->fixPath($programID);
}
/* Add program admin.*/
$groupPriv = $this->dao->select('t1.*')->from(TABLE_USERGROUP)->alias('t1')
->leftJoin(TABLE_GROUP)->alias('t2')->on('t1.group = t2.id')
@@ -189,4 +196,49 @@ class programModel extends model
{
return $this->dao->select('*')->from(TABLE_PRODUCT)->where('project')->eq($program)->fetchAll('id');
}
public function checkHasContent($programID)
{
$count = 0;
$count += $this->dao->select('count(*) as count')->from(TABLE_BUDGET)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_BUG)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_CASE)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_DESIGN)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_DOC)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_DURATIONESTIMATION)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_ISSUE)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_RELATION)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_RELEASE)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_REPO)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_RISK)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_STORY)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_TESTREPORT)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_TESTSUITE)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_TESTTASK)->where('program')->eq($programID)->fetch('count');
$count += $this->dao->select('count(*) as count')->from(TABLE_WORKESTIMATION)->where('program')->eq($programID)->fetch('count');
return $count > 0;
}
public function fixPath($programID)
{
$path = array();
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
if($program->parent == 0)
{
$path['path'] = ",{$program->id},";
$path['grade'] = 1;
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
}
else
{
$path = $this->fixPath($program->parent);
$path['path'] .= "{$program->id},";
$path['grade'] += 1;
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
}
return $path;
}
}
+2 -1
View File
@@ -14,7 +14,7 @@
<th class='w-100px'><?php common::printOrderLink('end', $orderBy, $vars, $lang->program->end);?></th>
<th class='w-100px'><?php common::printOrderLink('budget', $orderBy, $vars, $lang->program->budget);?></th>
<th class='w-100px'><?php common::printOrderLink('PM', $orderBy, $vars, $lang->program->PM);?></th>
<th class='text-center w-200px'><?php echo $lang->actions;?></th>
<th class='text-center w-215px'><?php echo $lang->actions;?></th>
<?php if($canOrder):?>
<th class='w-60px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, $lang->project->orderAB);?></th>
<?php endif;?>
@@ -43,6 +43,7 @@
<?php common::printIcon('program', 'suspend', "projectID=$project->id", $project, 'list', '', '', 'iframe', true);?>
<?php common::printIcon('program', 'close', "projectID=$project->id", $project, 'list', '', '', 'iframe', true);?>
<?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "projectID=$project->id"), "<i class='icon-edit'></i>", '', "class='btn' title='{$lang->edit}'");?>
<?php common::printIcon('program', 'create', "template=&projectID=$project->id", '', 'list', 'treemap-alt', '', '', '', '', $this->lang->program->children);?>
</td>
<?php if($canOrder):?>
<td class='sort-handler'><i class="icon icon-move"></i></td>
+6 -1
View File
@@ -101,7 +101,7 @@
<tr class='hide'>
<th><?php echo $lang->project->status;?></th>
<td><?php echo html::hidden('status', 'wait');?></td>
<td><?php echo html::hidden('template', $template);?></td>
<td></td>
<td></td>
<td></td>
</tr>
@@ -129,6 +129,10 @@
<td colspan='4' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
<?php
echo html::hidden('template', $template);
echo html::hidden('parent', $programID);
?>
</td>
</tr>
</table>
@@ -165,4 +169,5 @@
</div>
</div>
<?php js::set('template', $template);?>
<?php js::set('programID', $programID);?>
<?php include '../../common/view/footer.html.php';?>