From ecd7f1197fa4bcdb43fa653b2190a81ece7836af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Thu, 9 Jun 2022 14:48:56 +0800 Subject: [PATCH] * Fix product order bug. --- module/product/control.php | 2 +- module/product/model.php | 42 ++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 8b4940bae5..2d3a6291a9 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -1201,7 +1201,7 @@ class product extends control * @access public * @return void */ - public function all($browseType = 'noclosed', $orderBy = 'program_asc,order_asc', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function all($browseType = 'noclosed', $orderBy = 'program_asc', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Load module and set session. */ $this->loadModel('program'); diff --git a/module/product/model.php b/module/product/model.php index f20a1b7d27..a97bdbcefb 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -339,19 +339,35 @@ class productModel extends model if(!empty($append) and is_array($append)) $append = implode(',', $append); - $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; - $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(1) - ->beginIF(strpos($mode, 'all') === false)->andWhere('deleted')->eq(0)->fi() - ->beginIF($programID)->andWhere('program')->eq($programID)->fi() - ->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() - ->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('id')->in($views)->fi() - ->andWhere('vision')->eq($this->config->vision) - ->orderBy($orderBy) - ->fetchPairs('id', 'name'); - return $products; + $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; + if($this->config->systemMode == 'new') + { + /* Order by program. */ + return $this->dao->select('t1.*, IF(INSTR(" closed", t1.status) < 2, 0, 1) AS isClosed')->from(TABLE_PRODUCT)->alias('t1') + ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') + ->where(1) + ->beginIF(strpos($mode, 'all') === false)->andWhere('t1.deleted')->eq(0)->fi() + ->beginIF($programID)->andWhere('t1.program')->eq($programID)->fi() + ->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('t1.status')->ne('closed')->fi() + ->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('t1.id')->in($views)->fi() + ->andWhere('t1.vision')->eq($this->config->vision) + ->orderBy('isClosed, t2.order_asc, t1.line_desc, t1.order_desc') + ->fetchPairs('id', 'name'); + } + else + { + $orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed'; + return $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed') + ->from(TABLE_PRODUCT) + ->where(1) + ->beginIF(strpos($mode, 'all') === false)->andWhere('deleted')->eq(0)->fi() + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() + ->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() + ->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('id')->in($views)->fi() + ->andWhere('vision')->eq($this->config->vision) + ->orderBy($orderBy) + ->fetchPairs('id', 'name'); + } } /**