From 475c058ee1d15ab1110dedd12f86297033c15108 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Thu, 24 Sep 2020 11:21:18 +0800 Subject: [PATCH] * Adjust product batch editing. --- module/common/model.php | 2 +- module/product/control.php | 4 ++++ module/product/model.php | 29 +++++++++++++++++++++-------- module/product/view/all.html.php | 2 +- module/program/control.php | 4 ++-- module/program/model.php | 4 ++-- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 5a055c8548..27852bef15 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -555,7 +555,7 @@ class commonModel extends model if(!empty($recentProjects)) { - foreach($recentProjects as $project) echo '
  • ' . html::a(helper::createLink('project', 'view', 'projectID=' . $project->id), $project->code) . '
  • '; + foreach($recentProjects as $project) echo '
  • ' . html::a(helper::createLink('program', 'index', 'projectID=' . $project->id), $project->code) . '
  • '; if(count($recentProjects) >= 5) echo '
  • ' . $this->lang->more . '
  • '; } diff --git a/module/product/control.php b/module/product/control.php index d56321322f..d335963e7d 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -385,6 +385,7 @@ class product extends control $this->action->logHistory($actionID, $changes); } } + die(js::locate($this->session->productList, 'parent')); } @@ -494,6 +495,7 @@ class product extends control $this->view->title = $product->name . $this->lang->colon . $this->lang->product->view; $this->view->position[] = html::a($this->createLink($this->moduleName, 'browse'), $product->name); $this->view->position[] = $this->lang->product->view; + $this->view->product = $product; $this->view->actions = $this->loadModel('action')->getList('product', $productID); $this->view->users = $this->user->getPairs('noletter'); @@ -760,6 +762,7 @@ class product extends control { $this->loadModel('program'); $this->lang->product->switcherMenu = $this->product->getSwitcher(); + $this->session->set('productList', $this->app->getURI(true)); /* Load pager and get tasks. */ $this->app->loadClass('pager', $static = true); @@ -779,6 +782,7 @@ class product extends control $this->view->program = $program; $this->view->programName = $programName; $this->view->browseType = $browseType; + $this->display(); } diff --git a/module/product/model.php b/module/product/model.php index a935fed6ac..0b34fce3b0 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -953,8 +953,9 @@ class productModel extends model $products = $this->getList($programID, $status, $limit = 0, $line); if(empty($products)) return array(); + $productKeys = array_keys($products); $products = $this->dao->select('*')->from(TABLE_PRODUCT) - ->where('id')->in(array_keys($products)) + ->where('id')->in($productKeys) ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); @@ -963,13 +964,13 @@ class productModel extends model ->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('type')->eq($storyType) - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->groupBy('product, status') ->fetchGroup('product', 'status'); /* Padding the stories to sure all products have records. */ $emptyStory = array_keys($this->lang->story->statusList); - foreach(array_keys($products) as $productID) + foreach($productKeys as $productID) { if(!isset($stories[$productID])) $stories[$productID] = $emptyStory; } @@ -987,7 +988,7 @@ class productModel extends model $plans = $this->dao->select('product, count(*) AS count') ->from(TABLE_PRODUCTPLAN) ->where('deleted')->eq(0) - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->andWhere('end')->gt(helper::now()) ->groupBy('product') ->fetchPairs(); @@ -995,14 +996,14 @@ class productModel extends model $releases = $this->dao->select('product, count(*) AS count') ->from(TABLE_RELEASE) ->where('deleted')->eq(0) - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->groupBy('product') ->fetchPairs(); $bugs = $this->dao->select('product,count(*) AS conut') ->from(TABLE_BUG) ->where('deleted')->eq(0) - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->groupBy('product') ->fetchPairs(); @@ -1010,7 +1011,7 @@ class productModel extends model ->from(TABLE_BUG) ->where('deleted')->eq(0) ->andwhere('status')->eq('active') - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->groupBy('product') ->fetchPairs(); @@ -1018,10 +1019,22 @@ class productModel extends model ->from(TABLE_BUG) ->where('deleted')->eq(0) ->andwhere('assignedTo')->eq('') - ->andWhere('product')->in(array_keys($products)) + ->andWhere('product')->in($productKeys) ->groupBy('product') ->fetchPairs(); + if(empty($programID)) + { + $programKeys = array(0=>0); + foreach($products as $product) $programKeys[] = $product->program; + $programs = $this->dao->select('id,name')->from(TABLE_PROGRAM) + ->where('id')->in(array_unique($programKeys)) + ->andWhere('deleted')->eq('0') + ->fetchPairs(); + + foreach($products as $product) $product->programName = isset($programs[$product->program]) ? $programs[$product->program] : ''; + } + $stats = array(); foreach($products as $key => $product) { diff --git a/module/product/view/all.html.php b/module/product/view/all.html.php index 4fa6bd0235..9a1ac671bf 100644 --- a/module/product/view/all.html.php +++ b/module/product/view/all.html.php @@ -76,7 +76,7 @@ createLink('product', 'browse', 'product=' . $product->id), $product->name);?> - + programName : $programName;?> stories['active'];?> stories['changed'];?> stories['draft'];?> diff --git a/module/program/control.php b/module/program/control.php index 4bfbfffb47..58395330ca 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -752,10 +752,10 @@ class program extends control */ public function ajaxGetRecentProjects() { - $recentProjects = $this->program->getPRJParams(0, 15); + $recentProjects = $this->program->getPRJPairs(0, 15); if(!empty($recentProjects)) { - foreach($recentProjects as $project) echo html::a(helper::createLink('project', 'view', 'projectID=' . $project->id), '' . $project->name); + foreach($recentProjects as $project) echo html::a(helper::createLink('program', 'index', 'projectID=' . $project->id), '' . $project->name); } } diff --git a/module/program/model.php b/module/program/model.php index 75c1815803..9db28bde73 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -785,7 +785,7 @@ class programModel extends model $programID = $programTitle == 'base' ? current($path) : end($path); if(empty($path) || $programID == $id) continue; - $program = isset($programList[$programID]) ? $programList[$programID] : $this->getPRJParams($programID); + $program = isset($programList[$programID]) ? $programList[$programID] : $this->getPRJPairs($programID); $programList[$programID] = $program; $projectList[$id]->name = $program->name . '/' . $projectList[$id]->name; @@ -817,7 +817,7 @@ class programModel extends model * @access public * @return object */ - public function getPRJParams($projectID = 0, $limit = 0) + public function getPRJPairs($projectID = 0, $limit = 0) { if($limit) {