* Sort products.

This commit is contained in:
tianshujie98
2021-04-01 11:32:55 +08:00
parent eab73f9546
commit ff3bb25320
2 changed files with 21 additions and 8 deletions
+8 -8
View File
@@ -261,14 +261,14 @@ class productModel extends model
{
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProductPairs();
$products = $this->dao->select('*, IF(INSTR(" closed", t1.status) < 2, 0, 1) AS isClosed, t1.id AS id, t1.name AS name')
->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
->where('t1.deleted')->eq(0)
->beginIF($programID)->andWhere('t1.program')->eq($programID)->fi()
->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('t1.status')->ne('closed')->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
->orderBy('t2.order_asc, t1.line_desc, t1.order_asc')
$orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed';
$products = $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed')
->from(TABLE_PRODUCT)
->where('deleted')->eq(0)
->beginIF($programID)->andWhere('program')->eq($programID)->fi()
->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
->orderBy($orderBy)
->fetchPairs('id', 'name');
return $products;
}
+13
View File
@@ -585,6 +585,18 @@ class story extends control
$this->commonAction($storyID);
/* Sort products. */
$myProducts = array();
$othersProducts = array();
$products = $this->loadModel('product')->getList();
foreach($products as $product)
{
if($product->status == 'normal' and $product->PO == $this->app->user->account) $myProducts[$product->id] = $product->name;
if($product->status == 'normal' and !($product->PO == $this->app->user->account)) $othersProducts[$product->id] = $product->name;
if($product->status == 'closed') continue;
}
/* Assign. */
$story = $this->story->getById($storyID, 0, true);
$product = $this->product->getById($story->product);
@@ -599,6 +611,7 @@ class story extends control
$this->view->stories = $stories;
$this->view->users = $this->user->getPairs('pofirst|nodeleted', "$story->assignedTo,$story->openedBy,$story->closedBy");
$this->view->product = $product;
$this->view->products = $myProducts + $othersProducts;
$this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product);
$this->display();
}