diff --git a/module/action/config.php b/module/action/config.php index 66ace538c1..d04cbfdf99 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -79,6 +79,9 @@ $config->action->needGetProjectType = 'build,task,bug,case,testcase,caseli $config->action->needGetRelateField = ',branch,story,productplan,release,task,build,bug,testcase,case,testtask,testreport,doc,doclib,issue,risk,opportunity,trainplan,gapanalysis,team,whitelist,researchplan,researchreport,meeting,kanbanlane,kanbancolumn,module,review,'; $config->action->noLinkModules = ',doclib,module,webhook,gitlab,instance,gitea,gogs,sonarqube,pipeline,jenkins,kanban,kanbanspace,kanbancolumn,kanbanlane,kanbanregion,kanbancard,execution,project,traincategory,apistruct,program,product,user,entry,repo,pivot,scene,'; $config->action->ignoreObjectType4Dynamic = 'kanbanregion,kanbanlane,kanbancolumn'; +$config->action->ignoreActions4Dynamic = 'disconnectxuanxuan,reconnectxuanxuan,loginxuanxuan,logoutxuanxuan,editmr,removemr'; + +$config->action->latestDateList = array('today', 'yesterday', 'thisWeek', 'lastWeek', 'thisMonth'); $config->action->preferredTypeNum = 10; diff --git a/module/action/model.php b/module/action/model.php index 2c6bdedd42..bc6a655e52 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -656,7 +656,7 @@ class actionModel extends model * @param string $account * @param string $period * @param string $orderBy - * @param object $pager + * @param int $limit * @param string|int $productID all|int(like 123)|notzero all => include zero, notzero, greater than 0 * @param string|int $projectID same as productID * @param string|int $executionID same as productID @@ -665,7 +665,7 @@ class actionModel extends model * @access public * @return array */ - public function getDynamic(string $account = 'all', string $period = 'all', string $orderBy = 'date_desc', object $pager = null, string|int $productID = 'all', string|int $projectID = 'all', string|int $executionID = 'all', string $date = '', string $direction = 'next'): array + public function getDynamic(string $account = 'all', string $period = 'all', string $orderBy = 'date_desc', int $limit = 50, string|int $productID = 'all', string|int $projectID = 'all', string|int $executionID = 'all', string $date = '', string $direction = 'next'): array { /* 计算时间段的开始和结束时间。 */ /* Computer the begin and end date of a period. */ @@ -698,6 +698,14 @@ class actionModel extends model $beginDate = $year . '-01-01'; } + /* 查询项目动态时,只查项目创建日期之后的动态。 */ + /* When you query project actions, only the actions after the date the project was created. */ + if(is_numeric($projectID)) + { + $openedDate = $this->dao->select('openedDate')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('openedDate'); + $beginDate = $openedDate > $beginDate ? $openedDate : $beginDate; + } + $this->actionTao->processEffortCondition($condition, $period, $begin, $end, $beginDate); $noMultipleExecutions = $this->dao->select('id')->from(TABLE_PROJECT)->where('multiple')->eq(0)->andWhere('type')->in('sprint,kanban')->fetchPairs(); @@ -705,7 +713,7 @@ class actionModel extends model $condition = "({$condition})"; - $actions = $this->actionTao->getActionListByCondition($condition, $date, $period, $begin, $end, $direction, $account, $beginDate, $productID, $projectID, $executionID, $executions, $actionCondition, $orderBy, $pager); + $actions = $this->actionTao->getActionListByCondition($condition, $date, $period, $begin, $end, $direction, $account, $beginDate, $productID, $projectID, $executionID, $executions, $actionCondition, $orderBy, $limit); if(!$actions) return array(); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'action'); @@ -742,13 +750,13 @@ class actionModel extends model * * @param int $queryID * @param string $orderBy - * @param object $pager + * @param int $limit * @param string $date * @param string $direction * @access public * @return array */ - public function getDynamicBySearch(int $queryID, string $orderBy = 'date_desc', object $pager = null, string $date = '', string $direction = 'next'): array + public function getDynamicBySearch(int $queryID, string $orderBy = 'date_desc', int $limit = 50, string $date = '', string $direction = 'next'): array { $query = $queryID ? $this->loadModel('search')->getQuery($queryID) : ''; @@ -786,7 +794,7 @@ class actionModel extends model if($this->config->vision == 'lite') $actionQuery .= " AND objectType != 'product'"; $actionQuery .= " AND vision = '{$this->config->vision}'"; - $actions = $this->getBySQL($actionQuery, $orderBy, $pager); + $actions = $this->getBySQL($actionQuery, $orderBy, $limit); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'action'); return $actions ? $this->transformActions($actions) : array(); @@ -798,18 +806,18 @@ class actionModel extends model * * @param string $sql * @param string $orderBy - * @param object $pager + * @param int $limit * @access public * @return array */ - public function getBySQL(string $sql, string $orderBy, object $pager = null): array + public function getBySQL(string $sql, string $orderBy, int $limit = 50): array { $actionCondition = $this->getActionCondition(); return $this->dao->select('*')->from(TABLE_ACTION) ->where($sql) ->beginIF(!empty($actionCondition))->andWhere("($actionCondition)")->fi() ->orderBy($orderBy) - ->page($pager) + ->limit($limit) ->fetchAll(); } @@ -1258,16 +1266,17 @@ class actionModel extends model * @param array $actions * @param string $direction * @param string $orderBy date_desc|date_asc + * @param string $type all|today|yesterday|thisweek|lastweek|thismonth|lastmonth * @access public * @return array */ - public function buildDateGroup(array $actions, string $direction = 'next', string $orderBy = 'date_desc'): array + public function buildDateGroup(array $actions, string $direction = 'next', string $type = 'today', string $orderBy = 'date_desc'): array { $dateGroup = array(); foreach($actions as $action) { $timeStamp = strtotime(isset($action->originalDate) ? $action->originalDate : $action->date); - $date = date(DT_DATE3, $timeStamp); + $date = $type == 'all' ? date(DT_DATE3, $timeStamp) : date(DT_DATE4, $timeStamp); $action->time = date(DT_TIME2, $timeStamp); $dateGroup[$date][] = $action; } @@ -1284,7 +1293,7 @@ class actionModel extends model foreach($lastDateActions as $action) { $timeStamp = strtotime(isset($action->originalDate) ? $action->originalDate : $action->date); - $date = date(DT_DATE3, $timeStamp); + $date = $type == 'all' ? date(DT_DATE3, $timeStamp) : date(DT_DATE4, $timeStamp); $action->time = date(DT_TIME2, $timeStamp); $dateGroup[$date][] = $action; } @@ -1926,4 +1935,20 @@ class actionModel extends model $action->extra = sprintf($this->lang->execution->action->extra, '' . join(', ', $linkedProducts) . ''); } } + + /** + * 获取动态的数量。 + * Get dynamic count. + * + * @access public + * @return int + */ + public function getDynamicCount(): int + { + $condition = $this->session->actionQueryCondition ? $this->session->actionQueryCondition : '1=1'; + + return $this->dao->select('count(1) as count')->from(TABLE_ACTION) + ->where($condition) + ->fetch('count'); + } } diff --git a/module/action/tao.php b/module/action/tao.php index 3f68337ef9..799c0935e8 100644 --- a/module/action/tao.php +++ b/module/action/tao.php @@ -705,28 +705,31 @@ class actionTao extends actionModel * 通过条件获取操作记录列表。 * Get action list by condition. * - * @param string $condition - * @param string $date - * @param string $period - * @param string $begin - * @param string $end - * @param string $direction - * @param string $account - * @param string $beginDate - * @param string $productID - * @param string $projectID - * @param string $executionID - * @param array $executions - * @param string $actionCondition - * @param string $orderBy - * @param object $pager + * @param string $condition + * @param string $date + * @param string $period + * @param string $begin + * @param string $end + * @param string $direction + * @param string $account + * @param string $beginDate + * @param string $productID + * @param string $projectID + * @param string $executionID + * @param array $executions + * @param string $actionCondition + * @param string $orderBy + * @param int $limit * @access protected * @return array|bool */ - protected function getActionListByCondition(string $condition, string $date, string $period, string $begin, string $end, string $direction, string $account, string $beginDate, string $productID, string $projectID, string $executionID, array $executions, string $actionCondition, string $orderBy, object $pager = null): array|bool + protected function getActionListByCondition(string $condition, string $date, string $period, string $begin, string $end, string $direction, string $account, string $beginDate, string $productID, string $projectID, string $executionID, array $executions, string $actionCondition, string $orderBy, int $limit = 50): array|bool { - return $this->dao->select('*')->from(TABLE_ACTION) + $actionTable = in_array($period, $this->config->action->latestDateList) ? TABLE_ACTIONRECENT : TABLE_ACTION; + + return $this->dao->select('*')->from($actionTable) ->where('objectType')->notIN($this->config->action->ignoreObjectType4Dynamic) + ->andWhere('action')->notIN($this->config->action->ignoreActions4Dynamic) ->andWhere('vision')->eq($this->config->vision) ->beginIF($period != 'all')->andWhere('date')->gt($begin)->andWhere('date')->lt($end)->fi() ->beginIF($date)->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'")->fi() @@ -747,11 +750,8 @@ class actionTao extends actionModel ->beginIF($executionID == 'notzero')->andWhere('execution')->gt(0)->fi() ->andWhere($condition) ->beginIF($actionCondition)->andWhere("($actionCondition)")->fi() - /* 过滤客户端的登陆登出操作。 */ - /* Filter out client login/logout actions. */ - ->andWhere('action')->notin('disconnectxuanxuan,reconnectxuanxuan,loginxuanxuan,logoutxuanxuan,editmr,removemr') ->orderBy($orderBy) - ->page($pager) + ->limit($limit) ->fetchAll(); } diff --git a/module/action/test/action.class.php b/module/action/test/action.class.php index 8c28fdc03d..11c473dabb 100644 --- a/module/action/test/action.class.php +++ b/module/action/test/action.class.php @@ -224,7 +224,7 @@ class actionTest $objects = $this->objectModel->getHistory($actionID); if(dao::isError()) return dao::getError(); - + return isset($objects[$actionID])? $objects[$actionID] : false; } @@ -271,13 +271,13 @@ class actionTest * @param array $executions * @param int $queryID * @param string $orderBy - * @param object $pager + * @param int $limit * @param string $date * @param string $direction * @access public * @return array */ - public function getDynamicBySearchTest(int $queryID, string $orderBy = 'date_desc', object $pager = null, string $date = '', string $direction = 'next') + public function getDynamicBySearchTest(int $queryID, string $orderBy = 'date_desc', int $limit = 50, string $date = '', string $direction = 'next') { if($queryID) { @@ -286,7 +286,7 @@ class actionTest } $date = $date == 'today' ? date('Y-m-d', time()) : $date; - $objects = $this->objectModel->getDynamicBySearch($queryID, $orderBy, $pager, $date, $direction); + $objects = $this->objectModel->getDynamicBySearch($queryID, $orderBy, $limit, $date, $direction); if(dao::isError()) return dao::getError(); @@ -309,7 +309,7 @@ class actionTest public function getDynamicTest($account = 'all', $period = 'all', $productID = 'all', $projectID = 'all', $executionID = 'all', $date = '', $direction = 'next') { $date = $date == 'today' ? date('Y-m-d', time()) : $date; - $objects = $this->objectModel->getDynamic($account, $period, 'date_desc', null, $productID, $projectID, $executionID, $date, $direction); + $objects = $this->objectModel->getDynamic($account, $period, 'date_desc', 50, $productID, $projectID, $executionID, $date, $direction); if(dao::isError()) return dao::getError(); @@ -503,7 +503,7 @@ class actionTest * Test update comment of a action. * * @param int $actionID - + */ public function updateCommentTest(int $actionID, string $comment, string $uid = '') { @@ -516,7 +516,7 @@ class actionTest } $this->objectModel->updateComment($actionID, $comment, $uid); - + unset($_POST); if(dao::isError()) return dao::getError(); @@ -600,7 +600,7 @@ class actionTest $firstGroupColumn = current(current($objects)); $endGroupColumn = current(end($objects)); - if(($direction == 'next' && $orderBy == 'date_desc') && strtotime($firstGroupColumn->originalDate) < strtotime($endGroupColumn->originalDate)) return array('count' => 0, 'sort' => false); + if(($direction == 'next' && $orderBy == 'date_desc') && strtotime($firstGroupColumn->originalDate) < strtotime($endGroupColumn->originalDate)) return array('count' => 0, 'sort' => false); if(($direction == 'pre' && $orderBy == 'date_asc') && strtotime($firstGroupColumn->originalDate) > strtotime($endGroupColumn->originalDate)) return array('count' => 0, 'sort' => false); $count = 0; @@ -635,11 +635,11 @@ class actionTest return false; } - + /** * 测试获取重复的对象。 * Test get repeat object. - * + * * @param object $object * @param string $table * @access public diff --git a/module/action/test/model/getdynamicbysearch.php b/module/action/test/model/getdynamicbysearch.php index 878892c123..f748120506 100755 --- a/module/action/test/model/getdynamicbysearch.php +++ b/module/action/test/model/getdynamicbysearch.php @@ -26,14 +26,14 @@ pid=1 $queryID = array(0, 1); $orderByList = array('date_desc', 'date_asc'); -$pager = null; +$limit = 50; $dateList = array('', 'today'); $directionList = array('next', 'pre'); $action = new actionTest(); -r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的所有动态 -r($action->getDynamicBySearchTest($queryID[0], $orderByList[1], $pager, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('65,caselib;1,product'); // 获取排序为date正序的所有动态 -r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的今年之后的动态 -r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[1], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('63,module;31,bug'); // 获取排序为date倒序的今天之前的动态 -r($action->getDynamicBySearchTest($queryID[1], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('0:id,objectType') && e('1,product'); // 获取排序为date倒序的今年之后的动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $limit, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的所有动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[1], $limit, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('65,caselib;1,product'); // 获取排序为date正序的所有动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $limit, $dateList[0], $directionList[1])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的今年之后的动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $limit, $dateList[1], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('63,module;31,bug'); // 获取排序为date倒序的今天之前的动态 +r($action->getDynamicBySearchTest($queryID[1], $orderByList[0], $limit, $dateList[0], $directionList[1])) && p('0:id,objectType') && e('1,product'); // 获取排序为date倒序的今年之后的动态 diff --git a/module/company/control.php b/module/company/control.php index 3a8e0715c1..e9bb88c98e 100755 --- a/module/company/control.php +++ b/module/company/control.php @@ -207,10 +207,6 @@ class company extends control $this->session->set('meetingList', $uri, 'project'); $this->session->set('meetingroomList', $uri, 'admin'); - /* Set the pager. */ - $this->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage = 50, $pageID = 1); - /* Append id for second sort. */ if($direction == 'next') $orderBy = 'date_desc'; if($direction == 'pre') $orderBy = 'date_asc'; @@ -258,11 +254,11 @@ class company extends control if(!$productID) $productID = 'all'; if(!$projectID) $projectID = 'all'; if(!$executionID) $executionID = 'all'; - $actions = $this->action->getDynamic($account, $browseType, $orderBy, $pager, $productID, $projectID, $executionID, $date, $direction); + $actions = $this->action->getDynamic($account, $browseType, $orderBy, 50, $productID, $projectID, $executionID, $date, $direction); } else { - $actions = $this->action->getDynamicBySearch($queryID, $orderBy, $pager, $date, $direction); + $actions = $this->action->getDynamicBySearch($queryID, $orderBy, 50, $date, $direction); } /* Build search form. */ @@ -290,6 +286,9 @@ class company extends control $this->config->company->dynamic->search['params']['actor']['values'] = $accountPairs; $this->loadModel('search')->setSearchParams($this->config->company->dynamic->search); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $browseType, $orderBy); + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); + /* Assign. */ $this->view->recTotal = $recTotal; $this->view->browseType = $browseType; @@ -300,10 +299,9 @@ class company extends control $this->view->executionID = $executionID; $this->view->queryID = $queryID; $this->view->orderBy = $orderBy; - $this->view->pager = $pager; $this->view->userID = $userID; $this->view->param = $param; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction, $orderBy); + $this->view->dateGroups = $dateGroups; $this->view->direction = $direction; $this->display(); } diff --git a/module/execution/control.php b/module/execution/control.php index 646219da71..3f1ae76f97 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2333,10 +2333,6 @@ class execution extends control $this->execution->setMenu($executionID); $execution = $this->execution->getByID($executionID); - /* Set the pager. */ - $this->app->loadClass('pager', true); - $pager = new pager($recTotal, 50, 1); - /* Set the user and type. */ $account = 'all'; if($type == 'account') @@ -2346,11 +2342,13 @@ class execution extends control } /* 获取这个时间段的操作日志列表。*/ - $period = $type == 'account' ? 'all' : $type; - $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; - $date = empty($date) ? '' : date('Y-m-d', $date); - $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, $pager, 'all', 'all', $executionID, $date, $direction); - if(empty($recTotal)) $recTotal = count($actions); + $period = $type == 'account' ? 'all' : $type; + $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; + $date = empty($date) ? '' : date('Y-m-d', $date); + $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, 50, 'all', 'all', $executionID, $date, $direction); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $type); + + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); $this->view->title = $execution->name . $this->lang->colon . $this->lang->execution->dynamic; $this->view->userIdPairs = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted|useid'); @@ -2358,12 +2356,12 @@ class execution extends control $this->view->executionID = $executionID; $this->view->type = $type; $this->view->orderBy = $orderBy; - $this->view->pager = $pager; $this->view->account = $account; $this->view->param = $param; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction); /* 将日志按照日期分组,以日期为索引,将日志列表作为值。*/ + $this->view->dateGroups = $dateGroups; /* 将日志按照日期分组,以日期为索引,将日志列表作为值。*/ $this->view->direction = $direction; $this->view->recTotal = $recTotal; + $this->display(); } diff --git a/module/execution/ui/dynamic.html.php b/module/execution/ui/dynamic.html.php index f974c3a063..68e8bd8003 100644 --- a/module/execution/ui/dynamic.html.php +++ b/module/execution/ui/dynamic.html.php @@ -103,8 +103,8 @@ if(!empty($firstAction)) $lastDate = substr($lastAction->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); - $preLink = $hasPre ? inlink('dynamic', "executionID=$executionID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; - $nextLink = $hasNext ? inlink('dynamic', "executionID=$executionID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; + $preLink = $hasPre ? inlink('dynamic', "executionID=$executionID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; + $nextLink = $hasNext ? inlink('dynamic', "executionID=$executionID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; if($hasPre || $hasNext) { diff --git a/module/execution/zen.php b/module/execution/zen.php index 2fc9ae5b2f..3d1e1b31b5 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -495,17 +495,13 @@ class executionZen extends execution } } - /* Load pager. */ - $this->app->loadClass('pager', true); - $pager = new pager(0, 30, 1); - $this->view->users = $userPairs; $this->view->userList = $userList; $this->view->products = $products; $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), '', $linkedBranches); $this->view->planGroups = $this->execution->getPlans(array_keys($products)); $this->view->actions = $this->loadModel('action')->getList('execution', $executionID); - $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', $pager, 'all', 'all', $executionID); + $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', 50, 'all', 'all', $executionID); $this->view->teamMembers = $this->execution->getTeamMembers($executionID); $this->view->docLibs = $this->loadModel('doc')->getLibsByObject('execution', $executionID); $this->view->statData = $this->execution->statRelatedData($executionID); diff --git a/module/my/control.php b/module/my/control.php index 61d5cafa24..bdb2ff2c1b 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -1507,11 +1507,10 @@ EOF; * @param string $type * @param int $recTotal * @param string $date - * @param string $direction next|pre * @access public * @return void */ - public function dynamic($type = 'today', $recTotal = 0, $date = '', $direction = 'next', $originTotal = 0) + public function dynamic($type = 'today', $recTotal = 0, $date = '', $direction = 'next') { /* Save session. */ $uri = $this->app->getURI(true); @@ -1546,10 +1545,6 @@ EOF; $this->session->set('componentLibList', $uri, 'assetlib'); $this->session->set('opportunityList', $uri, 'project'); - /* Set the pager. */ - $this->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage = 50, $pageID = 1); - /* Append id for second sort. */ $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; @@ -1557,17 +1552,18 @@ EOF; $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->dynamic; $date = empty($date) ? '' : date('Y-m-d', $date); - $actions = $this->loadModel('action')->getDynamic($this->app->user->account, $type, $orderBy, $pager, 'all', 'all', 'all', $date, $direction); - if(empty($originTotal)) $originTotal = $pager->recTotal; + $actions = $this->loadModel('action')->getDynamic($this->app->user->account, $type, $orderBy, 50, 'all', 'all', 'all', $date, $direction); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $type); + + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); /* Assign. */ - $this->view->type = $type; - $this->view->orderBy = $orderBy; - $this->view->pager = $pager; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction); - $this->view->direction = $direction; - $this->view->originTotal = $originTotal; - $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); + $this->view->type = $type; + $this->view->orderBy = $orderBy; + $this->view->dateGroups = $dateGroups; + $this->view->direction = $direction; + $this->view->recTotal = $recTotal; + $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->display(); } diff --git a/module/my/ui/dynamic.html.php b/module/my/ui/dynamic.html.php index 87436ddf48..28b67ad0ec 100644 --- a/module/my/ui/dynamic.html.php +++ b/module/my/ui/dynamic.html.php @@ -89,8 +89,8 @@ if(!empty($firstAction)) $lastDate = substr($lastAction->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); - $preLink = $hasPre ? inlink('dynamic', "type=$type&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; - $nextLink = $hasNext ? inlink('dynamic', "type=$type&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; + $preLink = $hasPre ? inlink('dynamic', "type=$type&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; + $nextLink = $hasNext ? inlink('dynamic', "type=$type&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; if($hasPre || $hasNext) { diff --git a/module/product/control.php b/module/product/control.php index 91811cc49c..c8ecf17fa2 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -331,14 +331,10 @@ class product extends control /* Execute hooks. */ $this->executeHooks($productID); - /* Load pager. */ - $this->app->loadClass('pager', true); - $pager = new pager(0, 30, 1); - $this->view->title = $product->name . $this->lang->colon . $this->lang->product->view; $this->view->product = $product; $this->view->actions = $this->loadModel('action')->getList('product', $productID); - $this->view->dynamics = $this->action->getDynamic('all', 'all', 'date_desc', $pager, $productID); + $this->view->dynamics = $this->action->getDynamic('all', 'all', 'date_desc', 50, $productID); $this->view->users = $this->user->getPairs('noletter'); $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->branches = $this->loadModel('branch')->getPairs($productID); @@ -435,9 +431,11 @@ class product extends control } /* Get actions. */ - list($actions, $pager) = $this->productZen->getActionsForDynamic($account, $orderBy, $productID, $type, $recTotal, $date, $direction); + list($actions, $dateGroups) = $this->productZen->getActionsForDynamic($account, $orderBy, $productID, $type, $recTotal, $date, $direction); if(empty($recTotal)) $recTotal = count($actions); + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); + /* Assign. */ $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->product->dynamic; $this->view->userIdPairs = $this->user->getPairs('noletter|nodeleted|noclosed|useid'); @@ -448,8 +446,7 @@ class product extends control $this->view->account = $account; $this->view->user = isset($user) ? $user : ''; $this->view->param = $param; - $this->view->pager = $pager; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction); + $this->view->dateGroups = $dateGroups; $this->view->direction = $direction; $this->view->recTotal = $recTotal; diff --git a/module/product/ui/dynamic.html.php b/module/product/ui/dynamic.html.php index 472c4f52a2..1bc61d3d3c 100644 --- a/module/product/ui/dynamic.html.php +++ b/module/product/ui/dynamic.html.php @@ -106,8 +106,8 @@ $firstDate = date('Y-m-d', strtotime($firstAction->originalDate) + 24 * 3600); $lastDate = substr($lastAction->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); -$preLink = $hasPre ? inlink('dynamic', "productID=$productID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; -$nextLink = $hasNext ? inlink('dynamic', "productID=$productID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; +$preLink = $hasPre ? inlink('dynamic', "productID=$productID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; +$nextLink = $hasNext ? inlink('dynamic', "productID=$productID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; if($hasPre || $hasNext) { diff --git a/module/product/zen.php b/module/product/zen.php index b3f926cb89..7a8620bb01 100644 --- a/module/product/zen.php +++ b/module/product/zen.php @@ -1202,17 +1202,13 @@ class productZen extends product */ protected function getActionsForDynamic(string $account, string $orderBy, int $productID, string $type, int $recTotal, string $date, string $direction): array { - /* Load pager. */ - $this->app->loadClass('pager', true); - /* Build parameters. */ - $pager = new pager($recTotal, 50, 1); - $period = $type == 'account' ? 'all' : $type; - $date = empty($date) ? '' : date('Y-m-d', (int)$date); + $period = $type == 'account' ? 'all' : $type; + $date = empty($date) ? '' : date('Y-m-d', (int)$date); + $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, 50, $productID, 'all', 'all', $date, $direction); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $type); - $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, $pager, $productID, 'all', 'all', $date, $direction); - - return array($actions, $pager); + return array($actions, $dateGroups); } /** diff --git a/module/project/control.php b/module/project/control.php index 9dbe3c84cd..e07558547e 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -580,10 +580,6 @@ class project extends control } } - /* Load pager. */ - $this->app->loadClass('pager', true); - $pager = new pager(0, 30, 1); - $this->executeHooks($projectID); list($userPairs, $userList) = $this->projectZen->buildUsers(); @@ -597,7 +593,7 @@ class project extends control $this->view->workhour = $this->project->getWorkhour($projectID); $this->view->planGroup = $this->loadModel('execution')->getPlans(array_keys($products)); $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), '', $linkedBranches); - $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', $pager, 'all', $projectID); + $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', 50, 'all', $projectID); $this->view->programList = $this->loadModel('program')->getPairsByList(explode(',', trim($project->path, ','))); $this->view->users = $userPairs; $this->view->userList = $userList; @@ -685,10 +681,6 @@ class project extends control /* Append id for second sort. */ $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; - /* Set the pager. */ - $this->app->loadClass('pager', true); - $pager = new pager($recTotal, 50, 1); - /* Set the user and type. */ $account = 'all'; if($type == 'account') @@ -697,9 +689,12 @@ class project extends control if($user) $account = $user->account; } - $period = $type == 'account' ? 'all' : $type; - $date = empty($date) ? '' : date('Y-m-d', $date); - $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, $pager, 'all', $projectID, 'all', $date, $direction); + $period = $type == 'account' ? 'all' : $type; + $date = empty($date) ? '' : date('Y-m-d', $date); + $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, 50, 'all', $projectID, 'all', $date, $direction); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $type); + + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); /* The header and position. */ $project = $this->project->getByID($projectID); @@ -712,12 +707,11 @@ class project extends control $this->view->projectID = $projectID; $this->view->type = $type; $this->view->orderBy = $orderBy; - $this->view->pager = $pager; $this->view->account = $account; $this->view->param = $param; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction); + $this->view->dateGroups = $dateGroups; $this->view->direction = $direction; - $this->view->recTotal = $pager->recTotal; + $this->view->recTotal = $recTotal; $this->display(); } diff --git a/module/project/ui/dynamic.html.php b/module/project/ui/dynamic.html.php index 5f9954fe5a..37aa0848b2 100644 --- a/module/project/ui/dynamic.html.php +++ b/module/project/ui/dynamic.html.php @@ -96,8 +96,8 @@ if(!empty($firstAction)) $lastDate = substr($lastAction->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); - $preLink = $hasPre ? inlink('dynamic', "projectID=$projectID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; - $nextLink = $hasNext ? inlink('dynamic', "projectID=$projectID&type=$type¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; + $preLink = $hasPre ? inlink('dynamic', "projectID=$projectID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; + $nextLink = $hasNext ? inlink('dynamic', "projectID=$projectID&type=$type¶m=$param&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; if($hasPre || $hasNext) { diff --git a/module/user/control.php b/module/user/control.php index 46e086b136..24dc4ef5ac 100755 --- a/module/user/control.php +++ b/module/user/control.php @@ -1199,24 +1199,21 @@ class user extends control $this->session->set('caseList', $uri, 'qa'); $this->session->set('testtaskList', $uri, 'qa'); - /* Set the pager. */ - $this->app->loadClass('pager', $static = true); - $pager = pager::init($recTotal, $recPerPage = 50, $pageID = 1); - /* Append id for second sort. */ - $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; - $date = empty($date) ? '' : date('Y-m-d', $date); + $orderBy = $direction == 'next' ? 'date_desc' : 'date_asc'; + $date = empty($date) ? '' : date('Y-m-d', $date); + $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, 50, 'all', 'all', 'all', $date, $direction); + $dateGroups = $this->action->buildDateGroup($actions, $direction, $period); - $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, $pager, 'all', 'all', 'all', $date, $direction); - - $this->view->title = $this->lang->user->common . $this->lang->colon . $this->lang->user->dynamic; + if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($actions) : $this->action->getDynamicCount(); /* Assign. */ + $this->view->title = $this->lang->user->common . $this->lang->colon . $this->lang->user->dynamic; $this->view->type = $period; $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->pager = $pager; + $this->view->recTotal = $recTotal; $this->view->user = $user; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction); + $this->view->dateGroups = $dateGroups; $this->view->direction = $direction; $this->display(); } diff --git a/module/user/ui/dynamic.html.php b/module/user/ui/dynamic.html.php index 84afa190dc..3c64b62225 100644 --- a/module/user/ui/dynamic.html.php +++ b/module/user/ui/dynamic.html.php @@ -97,8 +97,8 @@ if(!empty($firstAction)) $lastDate = substr($lastAction->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); - $preLink = $hasPre ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; - $nextLink = $hasNext ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; + $preLink = $hasPre ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; + $nextLink = $hasNext ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; if($hasPre || $hasNext) {