* Fix program js.

This commit is contained in:
Yagami
2020-11-18 14:58:07 +08:00
parent 568c524c85
commit ec6ced01d5
13 changed files with 81 additions and 137 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ define('TABLE_RELEASE', '`' . $config->db->prefix . 'release`');
define('TABLE_PROGRAM', '`' . $config->db->prefix . 'project`');
define('TABLE_PROJECT', '`' . $config->db->prefix . 'project`');
define('TABLE_PHASE', '`' . $config->db->prefix . 'project`');
define('TABLE_EXECUTION', '`' . $config->db->prefix . 'project`');
define('TABLE_TASK', '`' . $config->db->prefix . 'task`');
define('TABLE_TASKSPEC', '`' . $config->db->prefix . 'taskspec`');
define('TABLE_TEAM', '`' . $config->db->prefix . 'team`');
+11
View File
@@ -99,6 +99,17 @@ function computeEndDate(delta)
if(!beginDate) return;
delta = parseInt(delta);
if(delta == 999)
{
$('#end').val('');
$('#end').attr('disabled', 'disabled');
return false;
}
else
{
$('#end').removeAttr('disabled');
}
beginDate = convertStringToDate(beginDate);
if((delta == 7 || delta == 14) && (beginDate.getDay() == 1))
{
+1 -15
View File
@@ -1,18 +1,4 @@
$(function()
{
$('#parent').change();
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').attr('disabled', 'disabled');
}
else
{
$('#end').removeAttr('disabled');
}
});
})
$(function(){$('#parent').change();})
function setAclList(programID)
{
-15
View File
@@ -9,18 +9,3 @@ function setAclList(programID)
$('.aclBox').html($('#PGMAcl').html());
}
}
$(function()
{
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').attr('disabled', 'disabled');
}
else
{
$('#end').removeAttr('disabled');
}
});
})
-11
View File
@@ -1,17 +1,6 @@
$(function()
{
$('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')});
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').attr('disabled', 'disabled');
}
else
{
$('#end').removeAttr('disabled');
}
});
setAclList($("#parent").val());
if(typeof(currentPlanID) == 'undefined')
-13
View File
@@ -1,18 +1,5 @@
$(function()
{
$('#longTime').change(function()
{
if($(this).prop('checked'))
{
$('#end').val('').attr('disabled', 'disabled');
$('#days').val('');
}
else
{
$('#end').removeAttr('disabled');
}
});
$('#parent').click(function()
{
if(!confirm(PGMChangeTips)) return false;
+1
View File
@@ -123,6 +123,7 @@ $lang->program->endList[31] = '一个月';
$lang->program->endList[93] = '三个月';
$lang->program->endList[186] = '半年';
$lang->program->endList[365] = '一年';
$lang->program->endList[999] = '长期';
$lang->program->noPRJ = '暂时没有项目';
$lang->program->accessDenied = '您无权访问该项目!';
+15 -15
View File
@@ -251,12 +251,12 @@ class programModel extends model
->setDefault('parent', 0)
->setDefault('openedDate', helper::now())
->setIF($this->post->acl == 'open', 'whitelist', '')
->setIF($this->post->longTime == 1, 'end', '2059-12-31')
->setIF($this->post->delta == 999, 'end', '2059-12-31')
->add('type', 'program')
->join('whitelist', ',')
->cleanInt('budget')
->stripTags($this->config->program->editor->pgmcreate['id'], $this->config->allowedTags)
->remove('delta,longTime')
->remove('delta')
->get();
if($program->parent)
@@ -271,7 +271,7 @@ class programModel extends model
if($parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
/* When parent set end then child program cannot set longTime. */
if(empty($program->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
if(empty($program->end) and $this->post->delta == 999 and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
if(dao::isError()) return false;
}
@@ -346,10 +346,10 @@ class programModel extends model
->setIF($this->post->begin == '0000-00-00', 'begin', '')
->setIF($this->post->end == '0000-00-00', 'end', '')
->setIF($this->post->acl == 'open', 'whitelist', '')
->setIF($this->post->longTime == 1, 'end', '2059-12-31')
->setIF($this->post->delta == 999, 'end', '2059-12-31')
->join('whitelist', ',')
->stripTags($this->config->program->editor->pgmedit['id'], $this->config->allowedTags)
->remove('uid,delta,longTime')
->remove('uid,delta')
->get();
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->pgmedit['id'], $this->post->uid);
@@ -361,7 +361,7 @@ class programModel extends model
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROGRAM)->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->PGMBeginGreateChild, $minChildBegin);
if($maxChildEnd and $program->end < $maxChildEnd and !$this->post->longTime) dao::$errors['end'] = sprintf($this->lang->program->PGMEndLetterChild, $maxChildEnd);
if($maxChildEnd and $program->end < $maxChildEnd and $this->post->delta != 999) dao::$errors['end'] = sprintf($this->lang->program->PGMEndLetterChild, $maxChildEnd);
}
if($program->parent)
@@ -371,7 +371,7 @@ class programModel extends model
{
if($program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->PGMBeginLetterParent, $parentProgram->begin);
if($parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
if(empty($program->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
if(empty($program->end) and $this->post->delta == 999 and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->PGMEndGreaterParent, $parentProgram->end);
}
}
if(dao::isError()) return false;
@@ -1110,8 +1110,8 @@ class programModel extends model
{
$project = fixer::input('post')
->setDefault('status', 'wait')
->setIF($this->post->longTime == 1, 'end', '2059-12-31')
->setIF($this->post->longTime == 1, 'days', 0)
->setIF($this->post->delta == 999, 'end', '2059-12-31')
->setIF($this->post->delta == 999, 'days', 0)
->setIF($this->post->acl == 'open', 'whitelist', '')
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', helper::now())
@@ -1120,7 +1120,7 @@ class programModel extends model
->join('whitelist', ',')
->cleanInt('budget')
->stripTags($this->config->program->editor->prjcreate['id'], $this->config->allowedTags)
->remove('longTime,products,branch,plans,delta')
->remove('products,branch,plans,delta')
->get();
if($project->parent)
@@ -1146,7 +1146,7 @@ class programModel extends model
}
$requiredFields = $this->config->program->PRJCreate->requiredFields;
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
if($this->post->delta == 999) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$this->lang->project->name = $this->lang->program->PRJName;
$this->lang->project->code = $this->lang->program->PRJCode;
@@ -1239,14 +1239,14 @@ class programModel extends model
$project = fixer::input('post')
->setDefault('team', substr($this->post->name, 0, 30))
->setIF($this->post->longTime == 1, 'end', '2059-12-31')
->setIF($this->post->longTime == 1, 'days', 0)
->setIF($this->post->delta == 999, 'end', '2059-12-31')
->setIF($this->post->delta == 999, 'days', 0)
->setIF($this->post->begin == '0000-00-00', 'begin', '')
->setIF($this->post->end == '0000-00-00', 'end', '')
->setIF($this->post->acl == 'open', 'whitelist', '')
->join('whitelist', ',')
->stripTags($this->config->program->editor->prjedit['id'], $this->config->allowedTags)
->remove('longTime,products,branch,plans,delta')
->remove('products,branch,plans,delta')
->get();
if($project->parent)
@@ -1275,7 +1275,7 @@ class programModel extends model
$project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->prjedit['id'], $this->post->uid);
$requiredFields = $this->config->program->PRJEdit->requiredFields;
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
if($this->post->delta == 999) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$this->lang->project->name = $this->lang->program->PRJName;
$this->lang->project->code = $this->lang->program->PRJCode;
-6
View File
@@ -81,12 +81,6 @@
<?php echo html::input('begin', date('Y-m-d'), "class='form-control form-date' 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' placeholder='" . $lang->program->end . "' required");?>
<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->PRJLongTime;?></label>
</div>
</span>
</div>
</td>
<td colspan='2'><?php echo html::radio('delta', $lang->program->endList , '', "onclick='computeEndDate(this.value)'");?></td>
+2 -7
View File
@@ -55,15 +55,10 @@
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
<?php $disabledEnd = $program->end == '2059-12-31' ? 'disabled' : '';?>
<?php echo html::input('end', $program->end == '2059-12-31' ? '' : $program->end, "class='form-control form-date' $disabledEnd placeholder='" . $lang->program->end . "' required");?>
<span class='input-group-addon' id='longTimeBox'>
<div class="checkbox-primary">
<input type="checkbox" name="longTime" value="1" id="longTime" <?php echo $program->end == '2059-12-31' ? 'checked' : '';?>>
<label for="longTime"><?php echo $lang->program->PRJLongTime;?></label>
</div>
</span>
</div>
</td>
<td colspan='2'></td>
<?php $endValue = $program->end == '2059-12-31' ? 999 : '';?>
<td colspan='2'><?php echo html::radio('delta', $lang->program->endList , $endValue, "onclick='computeEndDate(this.value)'");?></td>
</tr>
<tr>
<th><?php echo $lang->program->realBegan;?></th>
-6
View File
@@ -120,12 +120,6 @@
<?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");?>
<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->PRJLongTime;?></label>
</div>
</span>
</div>
</td>
<td colspan='2'><?php echo html::radio('delta', $lang->program->endList , '', "onclick='computeEndDate(this.value)'");?></td>
+4 -9
View File
@@ -112,18 +112,13 @@
<?php echo html::input('begin', $project->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
$disabledEnd = empty($project->end) ? 'disabled' : '';
echo html::input('end', $project->end, "class='form-control form-date' onchange='computeWorkDays();' $disabledEnd placeholder='" . $lang->program->end . "' required");
$disabledEnd = $project->end == '2059-12-31' ? 'disabled' : '';
echo html::input('end', $project->end == '2059-12-31' ? '' : $project->end, "class='form-control form-date' onchange='computeWorkDays();' $disabledEnd placeholder='" . $lang->program->end . "' required");
?>
<span class='input-group-addon' id='longTimeBox'>
<div class="checkbox-primary">
<input type="checkbox" name="longTime" value="1" <?php echo empty($project->end) ? 'checked' : '';?> id="longTime">
<label for="longTime"><?php echo $lang->program->PRJLongTime;?></label>
</div>
</span>
</div>
</td>
<td class='muted'></td>
<?php $deltaValue = $project->end == '2059-12-31' ? 999 : '';?>
<td colspan='2'><?php echo html::radio('delta', $lang->program->endList , '', "onclick='computeEndDate(this.value)'");?></td>
</tr>
<?php if($project->model == 'scrum'):?>
<tr>
+46 -39
View File
@@ -719,14 +719,15 @@ class projectModel extends model
}
/**
* Get project pairs.
* Get execution pairs.
*
* @param string $mode all|noclosed or empty
* @param string $programID
* @param int $projectID
* @param string $type all|sprint|stage|kanban
* @param string $mode all|noclosed or empty
* @access public
* @return array
*/
public function getPairs($mode = '', $programID = 0)
public function getExecutionPairs($projectID = 0, $type = 'all', $mode = '')
{
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProjectPairs();
@@ -734,26 +735,27 @@ class projectModel extends model
$mode .= $this->cookie->projectMode;
/* Order by status's content whether or not done */
$projects = $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_PROJECT)
$executions = $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->beginIF($programID)->andWhere('project')->eq($programID)->fi()
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
->beginIF($type != 'all')->andWhere('type')->eq($type)->fi()
->beginIF(strpos($mode, 'withdelete') === false)->andWhere('deleted')->eq(0)->fi()
->beginIF(!$this->app->user->admin and strpos($mode, 'all') === false)->andWhere('id')->in($this->app->user->view->sprints)->fi()
->orderBy($orderBy)
->fetchAll();
$pairs = array();
foreach($projects as $project)
foreach($executions as $execution)
{
if(strpos($mode, 'noclosed') !== false and ($project->status == 'done' or $project->status == 'closed')) continue;
$pairs[$project->id] = $project->name;
if(strpos($mode, 'noclosed') !== false and ($execution->status == 'done' or $execution->status == 'closed')) continue;
$pairs[$execution->id] = $execution->name;
}
if(strpos($mode, 'empty') !== false) $pairs[0] = '';
/* If the pairs is empty, to make sure there's an project in the pairs. */
if(empty($pairs) and isset($projects[0]))
if(empty($pairs) and isset($executions[0]))
{
$firstProject = $projects[0];
$pairs[$firstProject->id] = $firstProject->name;
$firstExecution = $executions[0];
$pairs[$firstExecution->id] = $firstExecution->name;
}
return $pairs;
@@ -762,25 +764,28 @@ class projectModel extends model
/**
* Get by idList.
*
* @param array $projectIDList
* @param array $executionIdList
* @access public
* @return array
*/
public function getByIdList($projectIDList)
public function getByIdList($executionIdList = array())
{
return $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIDList)->fetchAll('id');
return $this->dao->select('*')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->fetchAll('id');
}
/**
* Get project lists.
* Get execution lists.
*
* @param int $projectID
* @param string $type all|sprint|stage|kanban
* @param string $status all|undone|wait|running
* @param int $limit
* @param int $productID
* @param int $branch
* @access public
* @return array
*/
public function getList($status = 'all', $limit = 0, $productID = 0, $branch = 0, $programID = 0)
public function getExecutionList($projectID = 0, $type = 'all', $status = 'all', $limit = 0, $productID = 0, $branch = 0)
{
if($status == 'involved') return $this->getInvolvedList($status, $limit, $productID, $branch);
@@ -789,9 +794,10 @@ class projectModel extends model
return $this->dao->select('t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.product')->eq($productID)
->andWhere('t2.type')->in('sprint,stage')
->beginIF($projectID)->andWhere('t2.project')->eq($projectID)->fi()
->beginIF($type == 'all')->andWhere('t2.type')->in('sprint,stage,kanban')->fi()
->beginIF($type != 'all')->andWhere('t2.type')->eq($type)->fi()
->andWhere('t2.deleted')->eq(0)
->beginIF($programID)->andWhere('t2.project')->eq($programID)->fi()
->beginIF($status == 'undone')->andWhere('t2.status')->notIN('done,closed')->fi()
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
@@ -804,11 +810,12 @@ class projectModel extends model
{
return $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_PROJECT)
->where('deleted')->eq(0)
->andWhere('type')->in('sprint,stage')
->beginIF($type == 'all')->andWhere('t2.type')->in('sprint,stage,kanban')->fi()
->beginIF($type != 'all')->andWhere('t2.type')->eq($type)->fi()
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi()
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
->beginIF($programID)->andWhere('project')->eq($programID)->fi()
->orderBy('order_desc')
->beginIF($limit)->limit($limit)->fi()
->fetchAll('id');
@@ -861,17 +868,17 @@ class projectModel extends model
}
/**
* Get project id by program.
* Get execution id list by project.
*
* @param int $programID
* @param int $status all|undone|wait|doing|suspended|closed
* @param int $projectID
* @param int $status all|undone|wait|doing|suspended|closed
* @access public
* @return array
*/
public function getProjectIDByProgram($programID, $status = 'all')
public function getExecutionIdList($projectID, $status = 'all')
{
return $this->dao->select('id')->from(TABLE_PROJECT)
->where('project')->eq($programID)
return $this->dao->select('id')->from(TABLE_EXECUTION)
->where('project')->eq($projectID)
->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi()
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
->andWhere('deleted')->eq('0')
@@ -879,21 +886,20 @@ class projectModel extends model
}
/**
* Get projects by program.
* Get executions by project.
*
* @param int $programID
* @param int $projectID
* @param string $status
* @param int $limit
* @access public
* @return array
*/
public function getProjectsByProgram($programID, $status = 'all', $limit = 0)
public function getExecutionsByProject($projectID, $status = 'all', $limit = 0)
{
$program = $this->getByID($programID);
if(empty($program)) return array();
if(!$projectID) return array();
$projects = $this->dao->select('*')->from(TABLE_PROJECT)
->where('project')->eq((int)$program->id)
$executions = $this->dao->select('*')->from(TABLE_EXECUTION)
->where('project')->eq((int)$projectID)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi()
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
@@ -902,16 +908,17 @@ class projectModel extends model
->beginIF($limit)->limit($limit)->fi()
->fetchAll('id');
if($program->model == 'waterfall')
$project = $this->loadModel('program')->getPRJByID($projectID);
if($project->model == 'waterfall')
{
foreach($projects as $projectID => $project)
foreach($executions as $executionID => $execution)
{
if($project->parent and isset($projects[$project->parent])) $projects[$project->id]->name = $projects[$project->parent]->name . '/' . $project->name;
if($execution->parent and isset($executions[$execution->parent])) $executions[$execution->id]->name = $executions[$execution->parent]->name . '/' . $execution->name;
}
foreach($projects as $project) if($project->grade == 2) unset($projects[$project->parent]);
foreach($executions as $execution) if($execution->grade == 2) unset($executions[$execution->parent]);
}
return $projects;
return $executions;
}
/**