* Query the program and project logic when upgrading.

This commit is contained in:
leiyong
2020-11-19 17:32:08 +08:00
parent ec2c0c7a26
commit 55976aeb26
4 changed files with 34 additions and 11 deletions
+6 -6
View File
@@ -428,26 +428,26 @@ class upgrade extends control
$this->view->noMergedSprints = $noMergedSprints;
}
$programs = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('type')->eq('program')->fetchPairs('id', 'name');
$programs = $this->upgrade->getProgramPairs();
$this->view->title = $this->lang->upgrade->mergeProgram;
$this->view->programs = $programs;
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('type')->eq('project')->andWhere('parent')->eq(key($programs))->fetchPairs('id', 'name');
$this->view->projects = $this->upgrade->getProjectPairsByProgram(key($programs));
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noempty');
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}
/**
* Gets the program under the project set.
* Get the project of the program it belongs to.
*
* @param int $programID
* @param int $programID
* @access public
* @return void
*/
public function ajaxGetProjectByProgram($programID = 0)
public function ajaxGetProjectPairsByProgram($programID = 0)
{
$projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('type')->eq('project')->andWhere('parent')->eq($programID)->fetchPairs('id', 'name');
$projects = $this->upgrade->getProjectPairsByProgram($programID);
die(html::select('projects', $projects, '', 'class="form-control"'));
}
+2 -2
View File
@@ -109,10 +109,10 @@ $(function()
toggleProject($('form #newProject0'));
});
function projectByProgram(obj)
function getProjectByProgram(obj)
{
var programID = $(obj).val();
var link = createLink('upgrade', 'ajaxGetProjectByProgram', 'programID=' + programID);
var link = createLink('upgrade', 'ajaxGetProjectPairsByProgram', 'programID=' + programID);
$.post(link, function(data)
{
$('#projects').replaceWith(data);
+25 -2
View File
@@ -1413,6 +1413,29 @@ class upgradeModel extends model
return $this->app->getAppRoot() . 'db' . DS . 'update' . $version . '.sql';
}
/**
* Gets program key-value pairs.
*
* @access public
* @return string
*/
public function getProgramPairs()
{
return $this->dao->select('*')->from(TABLE_PROGRAM)->where('deleted')->eq(0)->andWhere('type')->eq('program')->orderBy('id_asc')->fetchPairs('id', 'name');
}
/**
* Get the project of the program it belongs to.
*
* @param string $programID
* @access public
* @return string
*/
public function getProjectPairsByProgram($programID = 0)
{
return $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('type')->eq('project')->andWhere('parent')->eq($programID)->fetchPairs('id', 'name');
}
/**
* Execute a sql.
*
@@ -3938,7 +3961,7 @@ class upgradeModel extends model
$this->dao->insert(TABLE_PROJECT)->data($program)
->batchcheck('name,begin', 'notempty')
->checkIF($program->end != '', 'end', 'gt', $program->begin)
->check('name', 'unique', "deleted='0'")
->check('name', 'unique', "deleted='0' and type= 'program'")
->exec();
if(dao::isError()) return false;
@@ -3976,7 +3999,7 @@ class upgradeModel extends model
$this->dao->insert(TABLE_PROJECT)->data($project)
->batchcheck('name', 'notempty')
->check('name', 'unique', "deleted='0'")
->check('name', 'unique', "deleted='0' and type = 'project'")
->exec();
if(dao::isError()) return false;
+1 -1
View File
@@ -5,7 +5,7 @@
<th><?php echo $lang->upgrade->existPGM;?></th>
<td>
<div class='input-group'>
<?php echo html::select("programs", $programs, '', "class='form-control' onchange='projectByProgram(this)'");?>
<?php echo html::select("programs", $programs, '', "class='form-control' onchange='getProjectByProgram(this)'");?>
<span class='input-group-addon'>
<div class="checkbox-primary">
<input type="checkbox" name="newProgram" value="0" checked onchange="toggleProgram(this)" id="newProgram0" />