From ce70c10870f9f54bde16294183e7b74079676f42 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Wed, 13 Jul 2022 09:20:34 +0000 Subject: [PATCH] * Code optimization. --- extension/lite/project/ext/control/execution.php | 2 +- extension/lite/project/ext/view/execution.html.php | 2 +- module/execution/control.php | 7 +------ module/execution/view/task.html.php | 2 +- module/productplan/control.php | 7 +------ module/productplan/view/browsebylist.html.php | 2 +- module/program/control.php | 6 +----- module/program/view/project.html.php | 2 +- module/project/control.php | 7 ++----- module/project/view/browsebylist.html.php | 2 +- module/project/view/execution.html.php | 2 +- 11 files changed, 12 insertions(+), 29 deletions(-) diff --git a/extension/lite/project/ext/control/execution.php b/extension/lite/project/ext/control/execution.php index d5532e7411..c5ed1c7072 100644 --- a/extension/lite/project/ext/control/execution.php +++ b/extension/lite/project/ext/control/execution.php @@ -22,7 +22,7 @@ class project extends control } $allExecution = $this->execution->getList($projectID, 'all', 'all'); - $this->view->allExecutionsNum = count($allExecution); + $this->view->allExecutionsNum = empty($allExecution); $this->view->title = $this->lang->project->kanban; diff --git a/extension/lite/project/ext/view/execution.html.php b/extension/lite/project/ext/view/execution.html.php index 6dfc235595..a11aaf3846 100644 --- a/extension/lite/project/ext/view/execution.html.php +++ b/extension/lite/project/ext/view/execution.html.php @@ -30,7 +30,7 @@

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

diff --git a/module/execution/control.php b/module/execution/control.php index 4f5b724920..63bda66be4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -219,14 +219,9 @@ class execution extends control $showModule = !empty($this->config->datatable->executionTask->showModule) ? $this->config->datatable->executionTask->showModule : ''; $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($executionID, 'task', $showModule) : array(); - $allTasksNum = $this->dao->select('COUNT(id) AS count')->from(TABLE_TASK) - ->where('execution')->eq($executionID) - ->andWhere('deleted')->eq(0) - ->fetch(); - /* Assign. */ $this->view->tasks = $tasks; - $this->view->allTasksNum = $allTasksNum; + $this->view->allTasksNum = $this->task->getExecutionTasks($executionID); $this->view->summary = $this->execution->summary($tasks); $this->view->tabID = 'task'; $this->view->pager = $pager; diff --git a/module/execution/view/task.html.php b/module/execution/view/task.html.php index 90a87eb965..9be2c7db19 100644 --- a/module/execution/view/task.html.php +++ b/module/execution/view/task.html.php @@ -198,7 +198,7 @@ body {margin-bottom: 25px;}

task->noTask;?> - count)):?> + " . $lang->task->create, '', "class='btn btn-info'");?>

diff --git a/module/productplan/control.php b/module/productplan/control.php index 3b82972ed3..9f2dc98d98 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -351,17 +351,12 @@ class productplan extends control $this->view->kanbanData = $this->loadModel('kanban')->getPlanKanban($product, $branchID, $planGroup); } - $productPlansNum = $this->dao->select('COUNT(id) AS count')->from(TABLE_PRODUCTPLAN) - ->where('product')->eq($productID) - ->andWhere('deleted')->eq(0) - ->fetch(); - $this->view->productPlansNum = $productPlansNum; - $this->view->title = $productName . $this->lang->colon . $this->lang->productplan->browse; $this->view->position[] = $this->lang->productplan->browse; $this->view->productID = $productID; $this->view->branch = $branch; $this->view->branchStatusList = $branchStatusList; + $this->view->productPlansNum = $this->productplan->getList($productID, $branch, 'all'); $this->view->browseType = $browseType; $this->view->viewType = $viewType; $this->view->orderBy = $orderBy; diff --git a/module/productplan/view/browsebylist.html.php b/module/productplan/view/browsebylist.html.php index d49fed5427..453243d5bc 100644 --- a/module/productplan/view/browsebylist.html.php +++ b/module/productplan/view/browsebylist.html.php @@ -41,7 +41,7 @@

productplan->noPlan;?> - count)):?> + createLink('productplan', 'create', "productID=$product->id&branch=$branch"), " " . $lang->productplan->create, '', "class='btn btn-info'");?>

diff --git a/module/program/control.php b/module/program/control.php index 92cf9137b6..51100a9ef7 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -473,11 +473,7 @@ class program extends control $sortField = zget($this->config->program->sortFields, $order[0], 'id') . '_' . $order[1]; $projectStats = $this->program->getProjectStats($programID, $browseType, 0, $sortField, $pager, $programTitle); - $allProjectsNum = $this->dao->select('COUNT(id) AS count')->from(TABLE_PROJECT) - ->where('parent')->eq($programID) - ->andWhere('type')->eq('project') - ->andWhere('deleted')->eq(0) - ->fetch(); + $allProjectsNum = $this->program->getProjectStats($programID, 'all'); $this->view->allProjectsNum = $allProjectsNum; $this->view->title = $this->lang->program->project; diff --git a/module/program/view/project.html.php b/module/program/view/project.html.php index 23617123b9..226c8790da 100644 --- a/module/program/view/project.html.php +++ b/module/program/view/project.html.php @@ -35,7 +35,7 @@ js::set('browseType', $browseType);

project->empty;?> - count)) common::printLink('project', 'createGuide', "programID=$programID", ' ' . $lang->project->create, '', 'class="btn btn-info btn-wide " data-toggle="modal"');?> + ' . $lang->project->create, '', 'class="btn btn-info btn-wide " data-toggle="modal"');?>

diff --git a/module/project/control.php b/module/project/control.php index c039a63e8e..b171d10275 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -309,10 +309,7 @@ class project extends control $programTitle = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=project&key=programTitle'); $projectStats = $this->loadModel('program')->getProjectStats($programID, $browseType, $queryID, $orderBy, $pager, $programTitle); - $allProjectsNum = $this->dao->select('COUNT(id) AS count')->from(TABLE_PROJECT) - ->where('type')->eq('project') - ->andWhere('deleted')->eq(0) - ->fetch(); + $allProjectsNum = $this->loadModel('program')->getProjectStats($programID, 'all'); $this->view->allProjectsNum = $allProjectsNum; $this->view->title = $this->lang->project->browse; @@ -982,7 +979,7 @@ class project extends control $pager = new pager($recTotal, $recPerPage, $pageID); $allExecution = $this->project->getStats($projectID, 'all'); - $this->view->allExecutionNum = count($allExecution); + $this->view->allExecutionNum = empty($allExecution); $this->view->title = $this->lang->execution->allExecutions; $this->view->position[] = $this->lang->execution->allExecutions; diff --git a/module/project/view/browsebylist.html.php b/module/project/view/browsebylist.html.php index f0c078b870..d89feaeceb 100644 --- a/module/project/view/browsebylist.html.php +++ b/module/project/view/browsebylist.html.php @@ -73,7 +73,7 @@

project->empty;?> - count)):?> + ' . $lang->project->create, '', 'class="btn btn-info" data-toggle="modal"');?> diff --git a/module/project/view/execution.html.php b/module/project/view/execution.html.php index 5a7c921eee..4f96d88413 100644 --- a/module/project/view/execution.html.php +++ b/module/project/view/execution.html.php @@ -39,7 +39,7 @@

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