diff --git a/module/pivot/model.php b/module/pivot/model.php index 6c2296fe8a..936ad2e925 100644 --- a/module/pivot/model.php +++ b/module/pivot/model.php @@ -289,7 +289,7 @@ class pivotModel extends model public function getExecutions(string $begin = '', string $end = ''): array { $permission = common::hasPriv('pivot', 'showProject') || $this->app->user->admin; - $IDList = !$permission ? $this->app->user->view->sprints : array(); + $IDList = !$permission ? $this->app->user->view->sprints : array(); $executions = $this->pivotTao->getExecutionList($begin, $end, $IDList); foreach($executions as $execution) @@ -315,14 +315,8 @@ class pivotModel extends model /* 获取符合条件的产品。 */ /* Get products. */ $permission = common::hasPriv('pivot', 'showProduct') || $this->app->user->admin; - $products = $this->dao->select('t1.id, t1.code, t1.name, t1.PO')->from(TABLE_PRODUCT)->alias('t1') - ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') - ->where('t1.deleted')->eq('0') - ->andWhere('t1.shadow')->eq('0') - ->beginIF(strpos($conditions, 'closedProduct') === false)->andWhere('t1.status')->ne('closed')->fi() - ->beginIF(!$permission)->andWhere('t1.id')->in($this->app->user->view->products)->fi() - ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc') - ->fetchAll('id'); + $IDList = !$permission ? $this->app->user->view->products : array(); + $products = $this->pivotTao->getProductList($conditions, $IDList); /* 为产品生成计划数据和相关的需求数据。 */ /* Generate plan data and related story data for products. */ diff --git a/module/pivot/tao.php b/module/pivot/tao.php index 761936509d..3a934325f6 100644 --- a/module/pivot/tao.php +++ b/module/pivot/tao.php @@ -2,6 +2,27 @@ declare(strict_types=1); class pivotTao extends pivotModel { + /** + * 获取产品列表。 + * Get product list. + * + * @param string $conditions + * @param array $IDList + * @access public + * @return array + */ + protected function getProductList(string $conditions, array $IDList = array()): array + { + return $this->dao->select('t1.id, t1.code, t1.name, t1.PO')->from(TABLE_PRODUCT)->alias('t1') + ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') + ->where('t1.deleted')->eq('0') + ->andWhere('t1.shadow')->eq('0') + ->beginIF(strpos($conditions, 'closedProduct') === false)->andWhere('t1.status')->ne('closed')->fi() + ->beginIF(!empty($IDList))->andWhere('t1.id')->in($IDList)->fi() + ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc') + ->fetchAll('id'); + } + /** * 补充产品的计划信息。 * Supplement product plan information. @@ -20,6 +41,7 @@ class pivotTao extends pivotModel ->beginIF(strpos($conditions, 'overduePlan') === false)->andWhere('end')->gt(date('Y-m-d'))->fi() ->orderBy('product, parent_desc, begin') ->fetchAll('id'); + foreach($plans as $plan) { if($plan->parent > 0)