Merge branch 'sunhuawei_fixbug_20316' into 'master'

* Fix bug #20316.

See merge request easycorp/zentaopms!2976
This commit is contained in:
孙广明
2022-04-18 02:59:35 +00:00
4 changed files with 18 additions and 14 deletions
+4 -10
View File
@@ -257,20 +257,14 @@ class branch extends control
* @access public
* @return void
*/
public function ajaxGetBranches($productID, $oldBranch = 0, $param = 'all', $projectID = 0, $withMainBranch = true)
public function ajaxGetBranches($productID, $oldBranch = 0, $param = '', $projectID = 0, $withMainBranch = true)
{
$product = $this->loadModel('product')->getById($productID);
if(empty($product) or $product->type == 'normal') return;
$branches = $this->loadModel('branch')->getList($productID, $projectID, $param, 'order', null, $withMainBranch);
$branchOption = array();
$branchTagOption = array();
foreach($branches as $branchInfo)
{
$branchOption[$branchInfo->id] = $branchInfo->name;
$branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : '');
}
return print(html::select('branch', strpos($param, 'active') !== false ? $branchOption : $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)'"));
$branches = $this->loadModel('branch')->getPairs($productID, $param);
return print(html::select('branch', $branches, $oldBranch, "class='form-control' onchange='loadBranch(this)'"));
}
/**
+11 -1
View File
@@ -96,7 +96,7 @@ class branchModel extends model
* Get pairs.
*
* @param int $productID
* @param string $params
* @param string $params active|noempty|all|withClosed
* @param int $executionID
* @param string $mergedBranches
* @access public
@@ -141,6 +141,16 @@ class branchModel extends model
{
$branches = array('all' => $this->lang->branch->all) + $branches;
}
if(strpos($params, 'withClosed') !== false)
{
$closedBranches = $this->dao->select('id')->from(TABLE_BRANCH)->where('product')->eq($productID)->andWhere('status')->eq('closed')->fetchPairs();
if(!empty($closedBranches))
{
foreach($closedBranches as $closedBranch) $branches[$closedBranch] .= ' (' . $this->lang->branch->statusList['closed'] . ')';
}
}
return $branches;
}
+2 -2
View File
@@ -58,7 +58,7 @@ class tree extends control
if(!empty($product->type) && $product->type != 'normal')
{
$branches = $this->loadModel('branch')->getPairs($product->id);
$branches = $this->loadModel('branch')->getPairs($product->id, 'withClosed');
if($currentModuleID)
{
$currentModuleBranch = $this->dao->select('branch')->from(TABLE_MODULE)->where('id')->eq($currentModuleID)->fetch('branch');
@@ -335,7 +335,7 @@ class tree extends control
if($showProduct)
{
$product = $this->loadModel('product')->getById($module->root);
if($product->type != 'normal') $this->view->branches = $this->loadModel('branch')->getPairs($module->root, 'active');
if($product->type != 'normal') $this->view->branches = $this->loadModel('branch')->getPairs($module->root, 'withClosed');
$this->view->product = $product;
$this->view->products = $this->product->getPairs('', $product->program);
}
+1 -1
View File
@@ -160,7 +160,7 @@ function loadBranches(obj)
var $inputGroup = $(obj).closest('.input-group');
$inputGroup.find('#branch').remove();
$inputGroup.find('#branch_chosen').remove();
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0&param=withClosed"), function(data)
{
if(data)
{