From bc831b9e94e67dccafae6e595fc9570fa1ca5a35 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Fri, 21 Aug 2020 15:39:39 +0800 Subject: [PATCH] * Add program statistic. --- module/block/control.php | 62 ++++++- module/block/lang/zh-cn.php | 16 +- .../block/view/programstatisticblock.html.php | 152 ++++++++++++++++++ module/design/lang/en.php | 48 ++++++ module/program/lang/zh-cn.php | 4 + 5 files changed, 273 insertions(+), 9 deletions(-) create mode 100644 module/block/view/programstatisticblock.html.php create mode 100644 module/design/lang/en.php diff --git a/module/block/control.php b/module/block/control.php index b0dca86ab2..35b6c0a885 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -705,7 +705,7 @@ class block extends control foreach($programs as $programID => $program) { $members = $this->project->getTeamMemberPairs($programID); - $consumed = $this->dao->select('sum(consumed) as consumed')->from(TABLE_TASK)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('status')->ne('cancel')->fetch('consumed'); + $consumed = $this->dao->select('sum(consumed) as consumed')->from(TABLE_TASK)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('parent')->lt(1)->fetch('consumed'); $leftTasks = $this->dao->select('count(*) as leftTasks')->from(TABLE_TASK)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('status')->in('wait,doing,pause')->fetch('leftTasks'); $leftStories = $this->dao->select('count(*) as leftStories')->from(TABLE_STORY)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('status')->eq('active')->fetch('leftStories'); $leftBugs = $this->dao->select('count(*) as leftBugs')->from(TABLE_BUG)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('status')->eq('active')->fetch('leftBugs'); @@ -762,6 +762,64 @@ class block extends control $this->$func(); } + /** + * Print project statistic block. + * + * @access public + * @return void + */ + public function printProgramStatisticBlock() + { + if(!empty($this->params->type) and preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) die(); + + $this->loadModel('project'); + $this->app->loadLang('task'); + $this->app->loadLang('story'); + + $status = isset($this->params->type) ? $this->params->type : 'all'; + $num = isset($this->params->num) ? (int)$this->params->num : 15; + + /* Get projects. */ + $programs = $this->loadModel('program')->getUserPrograms($status, 'id_desc', $num); + if(empty($programs)) + { + $this->view->programs = $programs; + return false; + } + + foreach($programs as $programID => $program) + { + $program->allStories = $program->doneStories = $program->leftStories = 0; + $program->consumed = $this->dao->select('sum(consumed) as consumed')->from(TABLE_TASK) + ->where('program')->eq($programID) + ->andWhere('deleted')->eq(0) + ->andWhere('parent')->lt(1) + ->fetch('consumed'); + + $members = $this->project->getTeamMemberPairs($programID); + $program->countMembers = count($members) ? count($members) - 1 : 0; + + $stories = $this->dao->select('id, status')->from(TABLE_STORY) + ->where('deleted')->eq(0) + ->andWhere('type')->eq('story') + ->andWhere('status')->ne('draft') + ->andWhere('program')->eq($programID) + ->fetchPairs(); + foreach($stories as $id => $status) + { + $program->allStories ++; + if($status == 'closed') $program->doneStories ++; + if($status != 'closed') $program->leftStories ++; + } + + $program->progress = $program->allStories == 0 ? 0 : ceil($program->doneStories / $program->allStories) * 100; + + //$program->projects = $this->dao->select('*') + } + + $this->view->programs = $programs; + } + /** * Print product statistic block. * @@ -1089,7 +1147,7 @@ class block extends control $this->view->people = $this->dao->select('sum(people) as people')->from(TABLE_DURATIONESTIMATION)->where('program')->eq($this->session->program)->fetch('people'); $this->view->members = count($members) ? count($members) - 1 : 0; - $this->view->consumed = $this->dao->select('sum(consumed) as consumed')->from(TABLE_TASK)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('status')->ne('cancel')->fetch('consumed'); + $this->view->consumed = $this->dao->select('sum(consumed) as consumed')->from(TABLE_TASK)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->andWhere('parent')->lt(1)->fetch('consumed'); $this->view->budget = $budget; } diff --git a/module/block/lang/zh-cn.php b/module/block/lang/zh-cn.php index 2ec271a550..95aae7d490 100644 --- a/module/block/lang/zh-cn.php +++ b/module/block/lang/zh-cn.php @@ -243,8 +243,10 @@ $lang->block->default['full']['my']['3']['grid'] = 4; $lang->block->default['full']['my']['3']['source'] = 'todo'; $lang->block->default['full']['my']['3']['params']['num'] = '20'; -$lang->block->default['full']['my']['4'] = $lang->block->default['project']['1']; -$lang->block->default['full']['my']['4']['source'] = 'project'; +$lang->block->default['full']['my']['4']['title'] = '项目统计'; +$lang->block->default['full']['my']['4']['block'] = 'statistic'; +$lang->block->default['full']['my']['4']['source'] = 'program'; +$lang->block->default['full']['my']['4']['grid'] = 8; $lang->block->default['full']['my']['5']['title'] = '个人贡献'; $lang->block->default['full']['my']['5']['block'] = 'contribute'; @@ -266,12 +268,12 @@ $lang->block->default['full']['my']['8']['title'] = '项目人力投入'; $lang->block->default['full']['my']['8']['block'] = 'programteam'; $lang->block->default['full']['my']['8']['grid'] = 8; -$lang->block->default['full']['my']['8']['title'] = '项目列表'; -$lang->block->default['full']['my']['8']['block'] = 'program'; -$lang->block->default['full']['my']['8']['grid'] = 8; +$lang->block->default['full']['my']['9']['title'] = '项目列表'; +$lang->block->default['full']['my']['9']['block'] = 'program'; +$lang->block->default['full']['my']['9']['grid'] = 8; -$lang->block->default['full']['my']['8']['params']['orderBy'] = 'id_desc'; -$lang->block->default['full']['my']['8']['params']['num'] = '15'; +$lang->block->default['full']['my']['9']['params']['orderBy'] = 'id_desc'; +$lang->block->default['full']['my']['9']['params']['num'] = '15'; $lang->block->num = '数量'; $lang->block->type = '类型'; diff --git a/module/block/view/programstatisticblock.html.php b/module/block/view/programstatisticblock.html.php new file mode 100644 index 0000000000..6f907a9864 --- /dev/null +++ b/module/block/view/programstatisticblock.html.php @@ -0,0 +1,152 @@ + + +
+
+ +
+

block->noData;?>

+
+ +
+ +
+
+ +
+
+
+
+ +
+ story->common . $lang->program->doneStories;?> + doneStories;?> +
+
+
+
+
program->allStories;?>
+
allStories;?>
+
+
+ +
program->doneStories;?>
+
doneStories;?>
+
+
+ +
program->leftStories;?>
+
leftStories;?>
+
+
+
+
+
+
program->allInput;?>
+
+ countMembers;?> + consumed;?> + budget;?> +
+
+
+
+
+
+
+ +
+ +
+
diff --git a/module/design/lang/en.php b/module/design/lang/en.php new file mode 100644 index 0000000000..5dc76bccad --- /dev/null +++ b/module/design/lang/en.php @@ -0,0 +1,48 @@ +design->common = 'Design'; +$lang->design->browse = 'List'; +$lang->design->commit = 'Link Commit'; +$lang->design->submission = 'Commit'; +$lang->design->version = 'Revision'; +$lang->design->assignedTo = 'AssignedTo'; +$lang->design->actions = 'Actions'; +$lang->design->delete = 'Delete'; +$lang->design->confirmDelete = 'Do you want to delete this design?'; +$lang->design->edit = 'Edit'; +$lang->design->products = 'Linked Product'; +$lang->design->story = 'Linked Story'; +$lang->design->file = 'File'; +$lang->design->type = 'Type'; +$lang->design->name = 'Name'; +$lang->design->create = 'Create Design'; +$lang->design->view = 'View'; +$lang->design->desc = 'Description'; +$lang->design->product = 'Linked Product'; +$lang->design->basicInfo = 'Basic Information'; +$lang->design->commitDate = 'Committed Date'; +$lang->design->affectedStory = "{$lang->storyCommon}"; +$lang->design->affectedTasks = 'Task'; +$lang->design->submit = 'Submit Review'; +$lang->design->revision = 'Linked Code'; +$lang->design->designView = 'Details'; +$lang->design->reviewObject = 'Review Object'; +$lang->design->createdBy = 'CreatedBy'; +$lang->design->createdDate = 'CreatedDate'; +$lang->design->basicInfo = 'Basic Information'; + +$lang->design->typeList = array(); +$lang->design->typeList['HLDS'] = 'High-Level'; +$lang->design->typeList['DDS'] = 'Detailed'; +$lang->design->typeList['DBDS'] = 'Database'; +$lang->design->typeList['ADS'] = 'API'; + +$lang->design->range = 'Impact'; +$lang->design->errorSelection = 'No record selected!'; +$lang->design->noDesign = 'No record.'; + +$lang->design->rangeList = array(); +$lang->design->rangeList['all'] = 'All'; +$lang->design->rangeList['assign'] = 'Selected'; + +$lang->design->featureBar['all'] = 'All'; +$lang->design->featureBar += $lang->design->typeList; diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php index 6d254ec317..5667cf91e4 100644 --- a/module/program/lang/zh-cn.php +++ b/module/program/lang/zh-cn.php @@ -53,6 +53,10 @@ $lang->program->leftTasks = '剩余任务'; $lang->program->leftBugs = '剩余Bug'; $lang->program->children = '子项目'; $lang->program->parent = '父项目'; +$lang->program->allStories = '总需求'; +$lang->program->doneStories = '已完成'; +$lang->program->leftStories = '剩余需求'; +$lang->program->allInput = '项目总投入'; $lang->program->unitList[''] = ''; $lang->program->unitList['yuan'] = '元';