diff --git a/module/product/model.php b/module/product/model.php index 0420ab3686..f9d71a4b30 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -325,11 +325,13 @@ class productModel extends model */ public function getProjectPairs($productID, $param = 'all') { + $projectList = array_keys($this->loadModel('project')->getPairs()); $projects = array(); $datas = $this->dao->select('t2.id, t2.name, t2.deleted') ->from(TABLE_PROJECTPRODUCT)->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2') ->on('t1.project = t2.id') ->where('t1.product')->eq((int)$productID) + ->andWhere('t2.id')->in($projectList) ->orderBy('t1.project desc') ->fetchAll(); diff --git a/module/productplan/model.php b/module/productplan/model.php index f42c5ee71c..0fadd7972d 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -37,7 +37,7 @@ class productplanModel extends model * @access public * @return object */ - public function getList($product = 0, $pager = null, $orderBy) + public function getList($product = 0, $pager = null, $orderBy = 'begin_desc') { return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('product')->eq($product) ->andWhere('deleted')->eq(0) diff --git a/module/story/model.php b/module/story/model.php index fa7cbe9aec..5e83273df1 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -648,8 +648,10 @@ class storyModel extends model $story->lastEditedBy = $this->app->user->account; $story->lastEditedDate = $now; $story->plan = $planID; + if($planID) $story->stage = 'planned'; $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec(); + if(!$planID) $this->setStage($storyID); if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story); } return $allChanges; @@ -737,7 +739,7 @@ class storyModel extends model /* If no projects, in plan, stage is planned. No plan, wait. */ if(!$projects) { - $this->dao->update(TABLE_STORY)->set('stage')->eq('wait')->where('id')->eq((int)$storyID)->andWhere('plan')->eq(0)->andWhere('status')->eq('active')->exec(); + $this->dao->update(TABLE_STORY)->set('stage')->eq('wait')->where('id')->eq((int)$storyID)->andWhere('plan')->eq(0)->exec(); $this->dao->update(TABLE_STORY)->set('stage')->eq('planned')->where('id')->eq((int)$storyID)->andWhere('plan')->gt(0)->exec(); return true; }