diff --git a/module/action/model.php b/module/action/model.php index 8c289f283e..f665e432e9 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1424,10 +1424,11 @@ class actionModel extends model * @param array $actions * @param string $direction * @param string $type all|today|yesterday|thisweek|lastweek|thismonth|lastmonth + * @param string $orderBy date_desc|date_asc * @access public * @return array */ - public function buildDateGroup($actions, $direction = 'next', $type = 'today') + public function buildDateGroup($actions, $direction = 'next', $type = 'today', $orderBy = 'date_desc') { $dateGroup = array(); foreach($actions as $action) @@ -1455,7 +1456,17 @@ class actionModel extends model } } - if($direction != 'next') $dateGroup = array_reverse($dateGroup); + /* Modify date to the corrret order. */ + if($this->app->rawModule != 'company' and $direction != 'next') + { + $dateGroup = array_reverse($dateGroup); + } + elseif($this->app->rawModule == 'company' and (($direction == 'next' and $orderBy == 'date_asc') or ($direction == 'pre' and $orderBy == 'date_desc'))) + { + $dateGroup = array_reverse($dateGroup); + foreach($dateGroup as $key => $dateItem) $dateGroup[$key] = array_reverse($dateItem); + } + return $dateGroup; } diff --git a/module/company/control.php b/module/company/control.php index ca4c93f11c..1ce38f6366 100644 --- a/module/company/control.php +++ b/module/company/control.php @@ -167,7 +167,7 @@ class company extends control * @param int $productID * @param int $projectID * @param int $executionID - * @param string $orderBy + * @param string $orderBy date_deac|date_asc * @access public * @return void */ @@ -204,7 +204,8 @@ class company extends control $pager = new pager($recTotal, $recPerPage = 50, $pageID = 1); /* Append id for secend sort. */ - $sort = $this->loadModel('common')->appendOrder($orderBy); + $order = $direction == 'next' ? 'date_desc' : 'date_asc'; + $sort = $this->loadModel('common')->appendOrder($order); $queryID = ($browseType == 'bysearch') ? (int)$param : 0; $date = empty($date) ? '' : date('Y-m-d', $date); @@ -289,7 +290,7 @@ class company extends control $this->view->userID = $userID; $this->view->param = $param; $this->view->browseType = $browseType; - $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction, $browseType); + $this->view->dateGroups = $this->action->buildDateGroup($actions, $direction, $browseType, $orderBy); $this->view->direction = $direction; $this->display(); } diff --git a/module/company/view/dynamic.html.php b/module/company/view/dynamic.html.php index 3c5bc77f7e..65620af0ed 100644 --- a/module/company/view/dynamic.html.php +++ b/module/company/view/dynamic.html.php @@ -96,8 +96,8 @@ $firstDate = date('Y-m-d', strtotime($firstAction->originalDate) + 24 * 3600); $lastDate = substr($action->originalDate, 0, 10); $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); -$preLink = $hasPre ? inlink('dynamic', "browseType=$browseType¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; -$nextLink = $hasNext ? inlink('dynamic', "browseType=$browseType¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; +$preLink = $hasPre ? inlink('dynamic', "browseType=$browseType¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . "&direction=pre&userID=$userID&productID=$productID&projectID=$projectID&executionID=$executionID&orderBy=$orderBy") : 'javascript:;'; +$nextLink = $hasNext ? inlink('dynamic', "browseType=$browseType¶m=$param&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . "&direction=next&userID=$userID&productID=$productID&projectID=$projectID&executionID=$executionID&orderBy=$orderBy") : 'javascript:;'; ?>