* Modify branch.

This commit is contained in:
mayue
2021-11-15 16:18:26 +08:00
parent 4719289333
commit a2f3100ea5
4 changed files with 65 additions and 19 deletions
+9 -1
View File
@@ -3681,7 +3681,15 @@ class executionModel extends model
$productPlans = array();
foreach($products as $productID => $product)
{
$productPlans[$productID] = $this->productplan->getPairs($product->id, isset($product->branch) ? $product->branch : '');
foreach($product->branch as $branchID)
{
$planInfo = $this->productplan->getPairs($product->id, $branchID);
foreach($planInfo as $planID => $plan)
{
if(empty($planID)) continue;
$productPlans[$productID][$planID] = $plan;
}
}
}
return $productPlans;
}
+45 -11
View File
@@ -333,18 +333,52 @@ class productModel extends model
* @access public
* @return array
*/
public function getProducts($projectID = 0, $status = 'all', $orderBy = '')
public function getProducts($projectID = 0, $status = 'all', $orderBy = '', $test = false)
{
return $this->dao->select('t1.*, t2.branch, t2.plan')
->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')
->on('t1.id = t2.product')
->where('t1.deleted')->eq(0)
->beginIF(!empty($projectID))->andWhere('t2.project')->eq($projectID)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->orderBy($orderBy . 't1.order asc')
->fetchAll('id');
if($test)
{
$productList = $this->dao->select('t1.*, t2.branch, t2.plan')
->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')
->on('t1.id = t2.product')
->where('t1.deleted')->eq(0)
->beginIF(!empty($projectID))->andWhere('t2.project')->eq($projectID)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->orderBy($orderBy . 't1.order asc')
->fetchGroup('id', 'branch');
$products = array();
foreach($productList as $productID => $branches)
{
$branch = array();
$plan = array();
foreach($branches as $branchID => $productInfo)
{
$branch[$productInfo->branch] = $productInfo->branch;
$plan[$productInfo->plan] = $productInfo->plan;
$productInfo->branch = $branch;
$productInfo->plan = $plan;
$products[$productID] = $productInfo;
}
}
return $products;
}
else
{
$productList = $this->dao->select('t1.*, t2.branch, t2.plan')
->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')
->on('t1.id = t2.product')
->where('t1.deleted')->eq(0)
->beginIF(!empty($projectID))->andWhere('t2.project')->eq($projectID)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->orderBy($orderBy . 't1.order asc')
->fetchAll('id');
}
}
/**
+3 -3
View File
@@ -663,11 +663,11 @@ class project extends control
$this->project->setMenu($projectID);
$products = $this->loadModel('product')->getProducts($projectID);
$products = $this->loadModel('product')->getProducts($projectID, 'all', '', true);
$linkedBranches = array();
foreach($products as $product)
foreach($products as $productID => $product)
{
if($product->branch) $linkedBranches[$product->branch] = $product->branch;
if($product->branch) $linkedBranches = $product->branch;
}
/* Load pager. */
+8 -4
View File
@@ -140,11 +140,13 @@
<div class="detail-content">
<div class="row row-grid">
<?php foreach($products as $productID => $product):?>
<?php $branchName = isset($branchGroups[$productID][$product->branch]) ? '/' . $branchGroups[$productID][$product->branch] : '';?>
<?php foreach($product->branch as $branchID):?>
<?php $branchName = isset($branchGroups[$productID][$branchID]) ? '/' . $branchGroups[$productID][$branchID] : '';?>
<div class="col-xs-6">
<?php echo html::a($this->createLink('product', 'browse', "productID=$productID&branch=$product->branch"), "<i class='icon icon-product text-muted'></i> " . $product->name . $branchName);?>
<?php echo html::a($this->createLink('product', 'browse', "productID=$productID&branch=$branchID"), "<i class='icon icon-product text-muted'></i> " . $product->name . $branchName);?>
</div>
<?php endforeach;?>
<?php endforeach;?>
</div>
</div>
</div>
@@ -153,10 +155,12 @@
<div class="detail-content">
<div class="row row-grid">
<?php foreach($products as $productID => $product):?>
<?php if(isset($planGroup[$productID][$product->plan])):?>
<div class="col-xs-12"><?php echo html::a($this->createLink('productplan', 'view', "planID={$product->plan}"), $product->name . '/' . $planGroup[$productID][$product->plan]);?></div>
<?php foreach($product->plan as $planID):?>
<?php if(isset($planGroup[$productID][$planID])):?>
<div class="col-xs-12"><?php echo html::a($this->createLink('productplan', 'view', "planID={$planID}"), $product->name . '/' . $planGroup[$productID][$planID]);?></div>
<?php endif;?>
<?php endforeach;?>
<?php endforeach;?>
</div>
</div>
</div>