* Adjust project creation logic.
This commit is contained in:
@@ -123,7 +123,7 @@ $lang->common->common = '公有模块';
|
||||
$lang->mainNav = new stdclass();
|
||||
$lang->mainNav->my = '<i class="icon icon-menu-my"></i> 地盘|my|index|';
|
||||
$lang->mainNav->program = '<i class="icon icon-stack"></i> 项目集|program|pgmindex|';
|
||||
$lang->mainNav->product = '<i class="icon icon-menu-project"></i> 产品|product|productlist|';
|
||||
$lang->mainNav->product = '<i class="icon icon-menu-project"></i> 产品|product|all|';
|
||||
$lang->mainNav->project = '<i class="icon icon-menu-doc"></i> 项目|program|prjbrowse|';
|
||||
$lang->mainNav->system = '<i class="icon icon-menu-users"></i> 组织|custom|estimate|';
|
||||
$lang->mainNav->admin = '<i class="icon icon-menu-backend"></i> 后台|admin|index|';
|
||||
|
||||
@@ -9,8 +9,12 @@ $config->program->editor->pgmactivate = array('id' => 'comment', 'tools' => 'sim
|
||||
$config->program->editor->pgmfinish = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->program->editor->pgmsuspend = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
|
||||
$config->program->editor->prjcreate = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjedit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjcreate = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjedit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjclose = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjsuspend = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjstart = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->program->editor->prjactivate = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
|
||||
$config->program->list = new stdclass();
|
||||
$config->program->list->exportFields = 'id,name,code,template,category,status,begin,end,budget,PM,end,desc';
|
||||
|
||||
+52
-21
@@ -915,12 +915,12 @@ class program extends control
|
||||
*
|
||||
* @param string $template
|
||||
* @param int $programID
|
||||
* @param int $parentProgramID
|
||||
* @param int $copyProgramID
|
||||
* @param string $from PRJ|PGM
|
||||
* @param int $copyProjectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function PRJCreate($template = 'waterfall', $programID = 0, $from = 'PRJ', $parentProgramID = 0, $copyProgramID = '')
|
||||
public function PRJCreate($template = 'waterfall', $programID = 0, $from = 'PRJ', $copyProjectID = '')
|
||||
{
|
||||
if($from == 'PRJ')
|
||||
{
|
||||
@@ -952,21 +952,9 @@ class program extends control
|
||||
$acl = 'open';
|
||||
$privway = 'extend';
|
||||
|
||||
if($parentProgramID)
|
||||
if($copyProjectID)
|
||||
{
|
||||
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($parentProgramID)->fetch();
|
||||
if($this->program->checkHasContent($parentProgramID))
|
||||
{
|
||||
echo js::alert($this->lang->program->cannotCreateChild);
|
||||
die(js::locate('back'));
|
||||
}
|
||||
|
||||
if(empty($template)) $template = $parentProgram->template;
|
||||
}
|
||||
|
||||
if($copyProgramID)
|
||||
{
|
||||
$copyProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProgramID)->fetch();
|
||||
$copyProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProjectID)->fetch();
|
||||
$name = $copyProgram->name;
|
||||
$code = $copyProgram->code;
|
||||
$team = $copyProgram->team;
|
||||
@@ -981,7 +969,8 @@ class program extends control
|
||||
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
|
||||
$this->view->programs = array('' => '') + $this->program->getPairsByTemplate($template);
|
||||
$this->view->programs = array('' => '') + $this->program->getPRJPairsByTemplate($template, $programID);
|
||||
$this->view->programID = $programID;
|
||||
$this->view->template = $template;
|
||||
$this->view->name = $name;
|
||||
$this->view->code = $code;
|
||||
@@ -989,10 +978,10 @@ class program extends control
|
||||
$this->view->acl = $acl;
|
||||
$this->view->privway = $privway;
|
||||
$this->view->whitelist = $whitelist;
|
||||
$this->view->parentProgram = $parentProgramID ? $parentProgram : '';
|
||||
$this->view->copyProgramID = $copyProgramID;
|
||||
$this->view->programID = $programID;
|
||||
$this->view->copyProjectID = $copyProjectID;
|
||||
$this->view->from = $from;
|
||||
$this->view->programList = $this->program->getParentPairs();
|
||||
$this->view->parentProgram = $this->program->getPGMByID($programID);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -1384,4 +1373,46 @@ class program extends control
|
||||
$this->view->actions = $this->loadModel('action')->getList('project', $projectID);
|
||||
$this->display('project', 'close');
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function PRJActivate($projectID)
|
||||
{
|
||||
$project = $this->program->getPRJByID($projectID);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$changes = $this->project->activate($projectID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
if($this->post->comment != '' or !empty($changes))
|
||||
{
|
||||
$actionID = $this->action->create('program', $projectID, 'Activated', $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
$this->executeHooks($projectID);
|
||||
die(js::reload('parent.parent'));
|
||||
}
|
||||
|
||||
$newBegin = date('Y-m-d');
|
||||
$dateDiff = helper::diffDate($newBegin, $project->begin);
|
||||
$newEnd = date('Y-m-d', strtotime($project->end) + $dateDiff * 24 * 3600);
|
||||
|
||||
$this->view->title = $this->lang->project->activate;
|
||||
$this->view->position[] = $this->lang->project->activate;
|
||||
|
||||
$this->view->project = $project;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->loadModel('action')->getList('project', $projectID);
|
||||
$this->view->newBegin = $newBegin;
|
||||
$this->view->newEnd = $newEnd;
|
||||
$this->view->project = $project;
|
||||
$this->display('project', 'activate');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#copyProjectModal {padding: 0}
|
||||
#copyProjectModal {padding: 0 2px}
|
||||
#copyProjectModal > div {position: relative;}
|
||||
#copyProjectModal a {display: block; min-height: 30px; line-height: 30px; padding: 5px 15px; border: 1px solid #e5e5e5; color: #333; margin: 5px 0; border-radius: 3px;}
|
||||
#copyProjectModal a > i {display: inline-block; margin-right: 5px;}
|
||||
#copyProjectModal a:hover {border:1px solid #00a9fc; background-color: #E9F2FB; text-decoration: none}
|
||||
#copyProjectModal a.active {border-color: #00da88; color: #00da88; background-color: #E5FFE6}
|
||||
#copyProjectModal a.active:after {position: absolute; content: '\e92f'; font-family: ZentaoIcon; font-size: 20px; right: 25px;}
|
||||
#copyProjectModal a.cancel {color: #ff5d5d}
|
||||
#budget {border-right:0px;}
|
||||
@@ -0,0 +1,20 @@
|
||||
$(function()
|
||||
{
|
||||
$('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')});
|
||||
$('#longTime').change(function()
|
||||
{
|
||||
if($(this).prop('checked'))
|
||||
{
|
||||
$('#end').val('').attr('disabled', 'disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#end').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function setCopyProject(copyProjectID)
|
||||
{
|
||||
location.href = createLink('program', 'PRJCreate', 'template=' + template + '&programID=' + programID + '&from=' + from + '©ProjectID=' + copyProjectID);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class programModel extends model
|
||||
/**
|
||||
* Get program pairs by template.
|
||||
*
|
||||
* @param varchar $template
|
||||
* @param string $model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -829,7 +829,7 @@ class programModel extends model
|
||||
if($action == 'prjfinish') return $program->status == 'wait' or $program->status == 'doing';
|
||||
if($action == 'prjclose') return $program->status != 'closed';
|
||||
if($action == 'prjsuspend') return $program->status == 'wait' or $program->status == 'doing';
|
||||
if($action == 'prjactivate') return $program->status == 'done';
|
||||
if($action == 'prjactivate') return $program->status == 'done' or $program->status == 'closed';
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1077,14 +1077,11 @@ class programModel extends model
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function buildPRJMenuQuery($projectID)
|
||||
public function buildPRJMenuQuery($projectID = 0)
|
||||
{
|
||||
$rootProject = $this->getPRJByID($projectID);
|
||||
$path = '';
|
||||
if($rootProject)
|
||||
{
|
||||
$path = $rootProject->path;
|
||||
}
|
||||
$path = '';
|
||||
$program = $this->getPRJByID($projectID);
|
||||
if($program) $path = $program->path;
|
||||
|
||||
return $this->dao->select('*')->from(TABLE_PROJECT)
|
||||
->beginIF($projectID > 0)->where('path')->like($path . '%')->fi()
|
||||
@@ -1092,6 +1089,26 @@ class programModel extends model
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project pairs by template.
|
||||
*
|
||||
* @param string $model
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getPRJPairsByTemplate($model, $programID = 0)
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_PROGRAM)
|
||||
->where('type')->eq('project')
|
||||
->beginIF($programID)->andWhere('parent')->eq($programID)->fi()
|
||||
->andWhere('model')->eq($model)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi()
|
||||
->orderBy('id_desc')
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the treemenu of project.
|
||||
*
|
||||
@@ -1161,6 +1178,7 @@ class programModel extends model
|
||||
$project = fixer::input('post')
|
||||
->setDefault('status', 'wait')
|
||||
->add('type', 'project')
|
||||
->add('lifetime', 'short')
|
||||
->setIF($this->post->acl != 'custom', 'whitelist', '')
|
||||
->setDefault('openedBy', $this->app->user->account)
|
||||
->setDefault('end', '')
|
||||
|
||||
@@ -10,30 +10,12 @@
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php if(isset($tips)):?>
|
||||
<?php $defaultURL = $this-> createLink('project', 'task', 'projectID=' . $projectID);?>
|
||||
<?php include '../../common/view/header.lite.html.php';?>
|
||||
<body>
|
||||
<div class='modal-dialog mw-500px' id='tipsModal'>
|
||||
<div class='modal-header'>
|
||||
<a href='<?php echo $defaultURL;?>' class='close'><i class="icon icon-close"></i></a>
|
||||
<h4 class='modal-title' id='myModalLabel'><?php echo $lang->project->tips;?></h4>
|
||||
</div>
|
||||
<div class='modal-body'>
|
||||
<?php echo $tips;?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit;?>
|
||||
<?php endif;?>
|
||||
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php js::import($jsRoot . 'misc/date.js');?>
|
||||
<?php js::set('weekend', $config->project->weekend);?>
|
||||
<?php js::set('holders', $lang->project->placeholder);?>
|
||||
<?php js::set('errorSameProducts', $lang->project->errorSameProducts);?>
|
||||
<?php js::set('template', $template);?>
|
||||
<?php js::set('programID', $programID);?>
|
||||
<?php js::set('from', $from);?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
@@ -80,7 +62,7 @@
|
||||
<?php echo html::select('budgetUnit', $lang->program->unitList, empty($parentProgram->budgetUnit) ? 'yuan' : $parentProgram->budgetUnit, "class='form-control'");?>
|
||||
</div>
|
||||
</td>
|
||||
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBudget, $parentProgram->budget . zget($lang->program->unitList, $parentProgram->budgetUnit, ''));?></td>
|
||||
<td class='muted'></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->dateRange;?></th>
|
||||
@@ -89,17 +71,15 @@
|
||||
<?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'>
|
||||
<span class='input-group-addon' id='longTimeBox'>
|
||||
<div class="checkbox-primary">
|
||||
<input type="checkbox" name="longTime" value="1" id="longTime">
|
||||
<label for="longTime"><?php echo $lang->program->longTime;?></label>
|
||||
<label for="longTime"><?php echo $lang->program->PRJLongTime;?></label>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</td>
|
||||
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBeginEnd, $parentProgram->begin, $parentProgram->end == '0000-00-00' ? '' : $parentProgram->end);?></td>
|
||||
<td class='muted'></td>
|
||||
</tr>
|
||||
<?php if($template == 'scrum'):?>
|
||||
<tr>
|
||||
@@ -172,11 +152,11 @@
|
||||
<div id='copyProjects' class='row'>
|
||||
<?php foreach ($programs as $id => $name):?>
|
||||
<?php if(empty($id)):?>
|
||||
<?php if($copyProgramID != 0):?>
|
||||
<?php if($copyProjectID != 0):?>
|
||||
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='' class='cancel'><?php echo html::icon($lang->icons['cancel']) . ' ' . $lang->project->cancelCopy;?></a></div>
|
||||
<?php endif;?>
|
||||
<?php else: ?>
|
||||
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='<?php echo $id;?>' class='nobr <?php echo ($copyProgramID == $id) ? ' active' : '';?>'><?php echo html::icon($lang->icons['project'], 'text-muted') . ' ' . $name;?></a></div>
|
||||
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='<?php echo $id;?>' class='nobr <?php echo ($copyProjectID == $id) ? ' active' : '';?>'><?php echo html::icon($lang->icons['project'], 'text-muted') . ' ' . $name;?></a></div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
@@ -184,6 +164,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php js::set('template', $template);?>
|
||||
<?php js::set('parentProgramID', isset($parentProgram->id) ? $parentProgram->id : 0);?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user