From e41dc21372d64dba7e21454933c65fe0b275a810 Mon Sep 17 00:00:00 2001 From: zenggang Date: Thu, 12 May 2022 09:06:35 +0000 Subject: [PATCH 01/14] * Fix bugs --- module/program/control.php | 12 +++++++++++- module/program/js/browse.js | 15 +++++---------- module/program/lang/en.php | 2 +- module/program/lang/zh-cn.php | 2 +- module/program/model.php | 13 +++++++++---- module/program/view/browse.html.php | 1 - module/program/view/browsebylist.html.php | 5 ++++- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 3c8d716d36..2c3631f536 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -47,7 +47,7 @@ class program extends control if(strtolower($status) == 'bysearch') { $queryID = (int)$param; - $programs = $this->program->getListBySearch($orderBy, $pager, $queryID); + $programs = $this->program->getListBySearch($orderBy, $queryID); } else { @@ -55,6 +55,15 @@ class program extends control $programIds = array(); foreach($topPrograms as $programID => $program) $programIds[] = $programID; $programs = $this->program->getList($status, $orderBy, null, 'child', $programIds); + + /* Get summary. */ + $topCount = $indCount = 0; + foreach($programs as $program) + { + if($program->type == 'program' and $program->parent == 0) $topCount ++; + if($program->type == 'project' and $program->parent == 0) $indCount ++; + } + $summary = sprintf($this->lang->program->summary, $topCount, $indCount); } } @@ -78,6 +87,7 @@ class program extends control $this->view->programs = $programs; $this->view->status = $status; $this->view->orderBy = $orderBy; + $this->view->summary = isset($summary) ? $summary : ''; $this->view->pager = $pager; $this->view->users = $this->user->getPairs('noletter'); $this->view->userIdPairs = $this->user->getPairs('noletter|showid'); diff --git a/module/program/js/browse.js b/module/program/js/browse.js index dc14dca89b..e716e7b4b2 100644 --- a/module/program/js/browse.js +++ b/module/program/js/browse.js @@ -43,13 +43,6 @@ $(function() $('#programForm').removeClass('has-row-checked'); } }); - - var myPager = $('.pager').data('zui.pager'); - if(status != 'bySearch' && myPager) - { - myPager.lang.pageSize = pageSize; - myPager.set(); - } }); function showEditCheckbox(show) @@ -76,13 +69,15 @@ function showEditCheckbox(show) }); if(show) { - var tableFooter = ""; - $('#programForm').attr('action', createLink('project', 'batchEdit', 'from=program')).append(tableFooter); + var tableFooter = "
"; + $('#programForm').attr('action', createLink('project', 'batchEdit', 'from=program')); + $('.table-footer').prepend(tableFooter).show(); $('body').scroll(); } else { - $('#programForm').find('.table-footer').remove(); + $('#programForm').find('.editCheckbox').remove(); + if($('#programForm .pager').length == 0) $('.table-footer').hide(); $('#programForm').removeAttr('action'); } } diff --git a/module/program/lang/en.php b/module/program/lang/en.php index 754323b538..81b18e13dc 100644 --- a/module/program/lang/en.php +++ b/module/program/lang/en.php @@ -74,7 +74,7 @@ $lang->program->moreProgram = 'More program'; $lang->program->stakeholderType = 'Stakeholder type'; $lang->program->parentBudget = 'Parent program surplus budget:'; $lang->program->isStakeholderKey = 'Key stakeholder'; -$lang->program->pageSize = '{recPerPage} Top Programs per page'; +$lang->program->summary = 'This page contains %d top programs and %d independent projects.'; $lang->program->stakeholderTypeList['inside'] = 'Inside'; $lang->program->stakeholderTypeList['outside'] = 'Outside'; diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php index f4279b673c..f263294a29 100644 --- a/module/program/lang/zh-cn.php +++ b/module/program/lang/zh-cn.php @@ -74,7 +74,7 @@ $lang->program->moreProgram = '更多项目集'; $lang->program->stakeholderType = '干系人类型'; $lang->program->parentBudget = '所属项目集剩余预算:'; $lang->program->isStakeholderKey = '关键干系人'; -$lang->program->pageSize = '每页 {recPerPage} 项顶级项目集'; +$lang->program->summary = '本页共 %d 个顶级项目集,%d 个独立项目。'; $lang->program->stakeholderTypeList['inside'] = '内部'; $lang->program->stakeholderTypeList['outside'] = '外部'; diff --git a/module/program/model.php b/module/program/model.php index a34cce9774..8cbf51dbc0 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -168,12 +168,11 @@ class programModel extends model * Get program list by search. * * @param string $orderBy - * @param object $pager * @param int $queryID * @access public * @return void */ - public function getListBySearch($orderBy = 'id_asc', $pager = NULL, $queryID = 0) + public function getListBySearch($orderBy = 'id_asc', $queryID = 0) { if($queryID) { @@ -194,7 +193,7 @@ class programModel extends model } $query = $this->session->programQuery; - return $this->dao->select('*')->from(TABLE_PROGRAM) + $programs = $this->dao->select('*')->from(TABLE_PROGRAM) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->andWhere('((type')->eq('program') @@ -206,8 +205,14 @@ class programModel extends model ->beginIF(!$this->cookie->showClosed)->andWhere('status')->ne('closed')->fi() ->beginIF($query)->andWhere($query)->fi() ->orderBy($orderBy) - ->page($pager) ->fetchAll('id'); + + /* Do not display project separately. */ + foreach($programs as $id => $program) + { + if($program->type == 'project' and !isset($programs[$program->parent])) unset($programs[$id]); + } + return $programs; } /** diff --git a/module/program/view/browse.html.php b/module/program/view/browse.html.php index abbf959b56..75e70e538f 100644 --- a/module/program/view/browse.html.php +++ b/module/program/view/browse.html.php @@ -15,7 +15,6 @@ edit);?> selectAll);?> -program->pageSize);?> diff --git a/module/program/view/browsebylist.html.php b/module/program/view/browsebylist.html.php index 834d949a36..39511dc8fe 100644 --- a/module/program/view/browsebylist.html.php +++ b/module/program/view/browsebylist.html.php @@ -138,7 +138,10 @@ - +