From 613c00bed9207d4ecd7b73d590f9e128c6769c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Wed, 6 Jul 2022 13:31:14 +0800 Subject: [PATCH] * Code for stage/task. --- module/execution/control.php | 12 ----- module/product/control.php | 2 +- module/project/control.php | 34 +++++++++++-- module/project/model.php | 27 ++++++++++- module/project/view/execution.html.php | 66 ++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 module/project/view/execution.html.php diff --git a/module/execution/control.php b/module/execution/control.php index 1cc1c84b54..9c40288774 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3547,18 +3547,6 @@ class execution extends control $from = $this->app->tab; if($from == 'execution') $this->session->set('executionList', $this->app->getURI(true), 'execution'); - if($from == 'project') - { - $projects = $this->project->getPairsByProgram(); - $projectID = $this->project->saveState($projectID, $projects); - $project = $this->loadModel('project')->getByID($projectID); - $this->view->project = $project; - $this->project->setMenu($projectID); - - if(!$projectID) return print(js::locate($this->createLink('project', 'browse'))); - if(!empty($project->model) and $project->model == 'kanban' and !(defined('RUN_MODE') and RUN_MODE == 'api')) return print(js::locate($this->createLink('project', 'index', "projectID=$projectID"))); - } - if($this->app->viewType == 'mhtml') { if($this->app->rawModule == 'project' and $this->app->rawMethod == 'execution') diff --git a/module/product/control.php b/module/product/control.php index 1108ea3e27..0dd085d32e 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -1100,7 +1100,7 @@ class product extends control /* Get product reviewers. */ $product = $this->product->getByID($productID); $productReviewers = $product->reviewer; - if(!$productReviewers and $product->acl != 'open') $productReviewers = $this->loadModel('user')->getProductViewListUsers($product, '', '', ''); + if(!$productReviewers and $product->acl != 'open') $productReviewers = $this->loadModel('user')->getProductViewListUsers($product, '', '', '', ''); $storyReviewers = ''; if($storyID) diff --git a/module/project/control.php b/module/project/control.php index 82695213fa..f7d2363376 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -956,10 +956,38 @@ class project extends control */ public function execution($status = 'all', $projectID = 0, $orderBy = 'order_asc', $productID = 0, $recTotal = 0, $recPerPage = 100, $pageID = 1) { - $uri = $this->app->getURI(true); - $this->app->session->set('executionList', $uri, 'project'); + $this->loadModel('execution'); + $this->loadModel('programplan'); - echo $this->fetch('execution', 'all', "status=$status&projectID=$projectID&orderBy=$orderBy&productID=$productID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"); + $projects = $this->project->getPairsByProgram(); + $projectID = $this->project->saveState($projectID, $projects); + $project = $this->project->getByID($projectID); + $this->project->setMenu($projectID); + + if(!$projectID) return print(js::locate($this->createLink('project', 'browse'))); + if(!empty($project->model) and $project->model == 'kanban' and !(defined('RUN_MODE') and RUN_MODE == 'api')) return print(js::locate($this->createLink('project', 'index', "projectID=$projectID"))); + + /* Load pager and get tasks. */ + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + + $this->view->title = $this->lang->execution->allExecutions; + $this->view->position[] = $this->lang->execution->allExecutions; + + + $this->view->executionStats = $this->project->getStats($projectID, $status, $productID, 0, 30, $orderBy, $pager, true); + $this->view->productList = $this->loadModel('product')->getProductPairsByProject($projectID); + $this->view->productID = $productID; + $this->view->projectID = $projectID; + $this->view->project = $project; + $this->view->projects = array('') + $this->project->getPairsByProgram(); + $this->view->pager = $pager; + $this->view->orderBy = $orderBy; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->status = $status; + $this->view->isStage = (isset($project->model) and $project->model == 'waterfall') ? true : false; + + $this->display(); } /** diff --git a/module/project/model.php b/module/project/model.php index 03147d7e1a..d6e748509d 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2308,7 +2308,7 @@ class projectModel extends model * @access public * @return array */ - public function getStats($projectID = 0, $status = 'undone', $productID = 0, $branch = 0, $itemCounts = 30, $orderBy = 'id_asc', $pager = null) + public function getStats($projectID = 0, $status = 'undone', $productID = 0, $branch = 0, $itemCounts = 30, $orderBy = 'id_asc', $pager = null, $withTasks = false) { if(empty($productID)) { @@ -2384,6 +2384,30 @@ class projectModel extends model $burns[$executionID] = $executionBurns; } + if($withTasks) + { + $executionTasks = $this->dao->select('*')->from(TABLE_TASK) + ->where('deleted')->eq(0) + ->andWhere('status')->ne('closed') + ->andWhere('execution')->in(array_keys($executions)) + ->fetchGroup('execution', 'id'); + + foreach($executionTasks as $executionID => $tasks) + { + foreach($tasks as $task) + { + if($task->parent > 0) + { + if(isset($executionTasks[$executionID][$task->parent])) + { + $executionTasks[$executionID][$task->parent]->children[$task->id] = $task; + unset($executionTasks[$executionID][$task->id]); + } + } + } + } + } + /* Process executions. */ $parents = array(); $children = array(); @@ -2409,6 +2433,7 @@ class projectModel extends model $execution->children = array(); $execution->grade == 1 ? $parents[$execution->id] = $execution : $children[$execution->parent][] = $execution; + if(isset($executionTasks) and isset($executionTasks[$execution->id])) $execution->tasks = $executionTasks[$execution->id]; } /* In the case of the waterfall model, calculate the sub-stage. */ diff --git a/module/project/view/execution.html.php b/module/project/view/execution.html.php new file mode 100644 index 0000000000..c44b1aa377 --- /dev/null +++ b/module/project/view/execution.html.php @@ -0,0 +1,66 @@ + + + + +
+ +
+

+ execution->noExecution;?> + + + createLink('programplan', 'create', "projectID=$projectID&productID=$productID"), " " . $lang->programplan->create, '', "class='btn btn-info'");?> + + + createLink('execution', 'create', "projectID=$projectID"), " " . $lang->execution->create, '', "class='btn btn-info' data-app='execution'");?> + + + +

+
+ + +
' data-ride='table'> +
+ +
+
+ +
+ + +