From 54ffdaea7a888ad47f34e1f5fe42e3fe87932de3 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Tue, 24 Nov 2020 13:05:36 +0800 Subject: [PATCH] * Fix edit stage error. --- module/product/model.php | 4 ++-- module/programplan/control.php | 14 +++++--------- module/programplan/model.php | 33 ++++++++++++--------------------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index cfeead1fb8..d9c6dd8785 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -773,10 +773,10 @@ class productModel extends model ->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi() ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() ->beginIF($status == 'nodeleted')->andWhere('t2.deleted')->eq('0')->fi() - ->orderBy('t1.project desc') + ->orderBy('t2.id desc') ->fetchPairs(); - $executions = array('' => '') + $executions; + $executions = array('0' => '') + $executions; return $executions; } diff --git a/module/programplan/control.php b/module/programplan/control.php index 82bcdaaa55..88edaf56eb 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -116,23 +116,19 @@ class programplan extends control if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $locate = $this->session->projectPlanList ? $this->session->projectPlanList : $this->createLink('programplan', 'browse', "projectID=$projectID"); - $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate)); } - $stages = empty($planID) ? $this->loadModel('stage')->getStages('id_asc') : array(); - $browseType = empty($planID) ? 'parent' : 'children'; + $stages = empty($planID) ? $this->loadModel('stage')->getStages('id_asc') : array(); $this->app->loadLang('stage'); $project = $this->loadModel('project')->getById($projectID); - $plans = $this->programplan->getStage($projectID, $this->productID, $planID, $browseType); + $plans = $this->programplan->getStage($planID ? $planID : $projectID, $this->productID, 'parent'); - $title = $this->lang->programplan->create . $this->lang->colon . $project->name; - $position[] = html::a($this->createLink('programplan', 'browse', "projectID=$projectID"), $project->name); - $position[] = $this->lang->programplan->create; + $this->view->title = $this->lang->programplan->create . $this->lang->colon . $project->name; + $this->view->position[] = html::a($this->createLink('programplan', 'browse', "projectID=$projectID"), $project->name); + $this->view->position[] = $this->lang->programplan->create; - $this->view->title = $title; - $this->view->position = $position; $this->view->project = $project; $this->view->stages = $stages; $this->view->plans = $plans; diff --git a/module/programplan/model.php b/module/programplan/model.php index f18f122ea8..b9908936b3 100644 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -40,18 +40,6 @@ class programplanModel extends model return $this->processPlan($plan); } - /** - * Get projects by productID. - * - * @param int $productID - * @access public - * @return array - */ - public function getProjectsByProduct($productID) - { - return $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->fetchPairs(); - } - /** * Get plans list. * @@ -64,14 +52,14 @@ class programplanModel extends model */ public function getStage($projectID = 0, $productID = 0, $browseType = 'all', $orderBy = 'id_asc') { - $stageIdList = empty($projectID) ? array() : $this->getProjectsByProduct($productID); + $executions = empty($projectID) ? array() : $this->loadModel('product')->getExecutionPairsByProduct($productID); $plans = $this->dao->select('*')->from(TABLE_PROJECT) ->where('type')->eq('stage') ->beginIF($browseType == 'all')->andWhere('project')->eq($projectID)->fi() ->beginIF($browseType == 'parent')->andWhere('parent')->eq($projectID)->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() - ->beginIF($productID)->andWhere('id')->in($stageIdList)->fi() + ->beginIF($productID)->andWhere('id')->in(array_keys($executions))->fi() ->andWhere('deleted')->eq(0) ->orderBy($orderBy) ->fetchAll('id'); @@ -926,14 +914,17 @@ class programplanModel extends model */ public function getParentStageList($projectID, $planID, $productID) { - $projects = $this->getProjectsByProduct($productID); - unset($projects[$planID]); + $parentStage = $this->dao->select('t2.id, t2.name')->from(TABLE_PROJECTPRODUCT) + ->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->where('t1.product')->eq($productID) + ->andWhere('t2.project')->eq($projectID) + ->andWhere('t2.grade')->eq(1) + ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() + ->orderBy('t2.id desc') + ->fetchPairs(); - $parentStage = $this->dao->select('id,name')->from(TABLE_PROJECT) - ->where('type')->eq('stage') - ->andWhere('parent')->eq($projectID) - ->andWhere('deleted')->eq('0') - ->fetchPairs('id'); + /* Remove the currently edited stage. */ + if(isset($parentStage[$planID])) unset($parentStage[$planID]); foreach($parentStage as $key => $stage) {