From ad3ce6bab638ffb2acddb2115ce95ec9928dea78 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 16 Nov 2017 15:26:20 +0800 Subject: [PATCH] * change for pro. --- module/custom/control.php | 2 +- module/report/model.php | 50 ++++++++------------ module/report/view/projectdeviation.html.php | 4 +- module/testcase/view/showimport.html.php | 4 +- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/module/custom/control.php b/module/custom/control.php index ee8af74abe..07e09e6b71 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -120,7 +120,7 @@ class custom extends control /* Fix bug #942. */ if($field == 'priList' and !is_numeric($key)) die(js::alert($this->lang->custom->notice->priListKey)); if($module == 'bug' and $field == 'severityList' and !is_numeric($key)) die(js::alert($this->lang->custom->notice->severityListKey)); - if(!empty($key) and $key != 'n/a' and !validater::checkCode($key)) die(js::alert($this->lang->custom->notice->keyList)); + if(!empty($key) and $key != 'n/a' and !validater::checkREG($key, '/^[a-zA-Z_0-9]+$/')) die(js::alert($this->lang->custom->notice->keyList)); /* the length of role is 20, check it when save. */ if($module == 'user' and $field == 'roleList' and strlen($key) > 20) die(js::alert($this->lang->custom->notice->userRole)); diff --git a/module/report/model.php b/module/report/model.php index a8c6d351f8..4670128ac4 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -89,45 +89,33 @@ class reportModel extends model */ public function getProjects($begin = 0, $end = 0) { - $projects = array(); - - $tasks = $this->dao->select('t1.*')->from(TABLE_TASK)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2') - ->on('t1.project = t2.id') + $tasks = $this->dao->select('t1.*,t2.name as projectName')->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->where('t1.status')->ne('cancel') ->andWhere('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq(0) + ->andWhere('t2.status')->eq('done') + ->beginIF($begin)->andWhere('t2.begin')->ge($begin)->fi() + ->beginIF($end)->andWhere('t2.end')->le($end)->fi() + ->orderBy('t2.end_desc') ->fetchAll(); + + $projects = array(); foreach($tasks as $task) { - if(!isset($projects[$task->project])) $projects[$task->project] = new stdclass(); - - $projects[$task->project]->estimate = isset($projects[$task->project]->estimate) ? $projects[$task->project]->estimate + $task->estimate : $task->estimate; - $projects[$task->project]->consumed = isset($projects[$task->project]->consumed) ? $projects[$task->project]->consumed + $task->consumed : $task->consumed; - } - - $projectList = $this->dao->select('id, name, status')->from(TABLE_PROJECT) - ->where('1=1') - ->beginIF($begin)->andWhere('begin')->ge($begin)->fi() - ->beginIF($end)->andWhere('end')->le($end)->fi() - ->fetchAll(); - $projectPairs = array(); - foreach($projectList as $project) - { - $projectPairs[$project->id] = $project->name; - if($project->status != 'done') unset($projects[$project->id]); - } - foreach($projects as $id => $project) - { - if(!isset($projectPairs[$id])) - { - unset($projects[$id]); - continue; + $projectID = $task->project; + if(!isset($projects[$projectID])) + { + $projects[$projectID] = new stdclass(); + $projects[$projectID]->estimate = 0; + $projects[$projectID]->consumed = 0; } - if(!isset($project->consumed)) $projects[$id]->consumed = 0; - if(!isset($project->estimate)) $projects[$id]->estimate = 0; - $projects[$id]->name = $projectPairs[$id]; + + $projects[$projectID]->name = $task->projectName; + $projects[$projectID]->estimate += $task->estimate; + $projects[$projectID]->consumed += $task->consumed; } + return $projects; } diff --git a/module/report/view/projectdeviation.html.php b/module/report/view/projectdeviation.html.php index fec42b85ec..b06f43db91 100644 --- a/module/report/view/projectdeviation.html.php +++ b/module/report/view/projectdeviation.html.php @@ -34,9 +34,9 @@ $project):?> - + - createLink('project', 'view', "projectID=$id"), $project->name);?> + createLink('project', 'view', "projectID=$id"), $project->name);?> estimate;?> consumed;?> consumed - $project->estimate;?> diff --git a/module/testcase/view/showimport.html.php b/module/testcase/view/showimport.html.php index a0822c1332..4ad3509c24 100644 --- a/module/testcase/view/showimport.html.php +++ b/module/testcase/view/showimport.html.php @@ -11,7 +11,7 @@ testcase->id?> testcase->title?> - + testcase->branch?> testcase->module?> @@ -51,7 +51,7 @@ ?> title, ENT_QUOTES), "class='form-control'")?> - + branch) and $case->branch !== '') ? $case->branch : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->branch : $branch), "class='form-control chosen'")?> module) ? $case->module : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->module : ''), "class='form-control chosen'")?>