diff --git a/module/action/model.php b/module/action/model.php index 233b1d1a01..c933e90787 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -560,10 +560,12 @@ class actionModel extends model * @param object $pager * @param string|int $productID all|int(like 123)|notzero all => include zeror, notzero, great than 0 * @param string|int $projectID same as productID + * @param string $date + * @param string $direction * @access public * @return array */ - public function getDynamic($account = 'all', $period = 'all', $orderBy = 'date_desc', $pager = null, $productID = 'all', $projectID = 'all') + public function getDynamic($account = 'all', $period = 'all', $orderBy = 'date_desc', $pager = null, $productID = 'all', $projectID = 'all', $date = '', $direction = 'next') { /* Computer the begin and end date of a period. */ $beginAndEnd = $this->computeBeginAndEnd($period); @@ -595,6 +597,7 @@ class actionModel extends model ->where(1) ->beginIF($period != 'all')->andWhere('date')->gt($begin)->fi() ->beginIF($period != 'all')->andWhere('date')->lt($end)->fi() + ->beginIF($date)->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'")->fi() ->beginIF($account != 'all')->andWhere('actor')->eq($account)->fi() ->beginIF(is_numeric($productID))->andWhere('product')->like("%,$productID,%")->fi() ->beginIF(is_numeric($projectID))->andWhere('project')->eq($projectID)->fi() @@ -606,6 +609,8 @@ class actionModel extends model ->orderBy($orderBy)->page($pager)->fetchAll(); if(!$actions) return array(); + + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'action'); return $this->transformActions($actions); } @@ -617,10 +622,12 @@ class actionModel extends model * @param int $queryID * @param string $orderBy * @param object $pager + * @param string $date + * @param string $direction * @access public * @return array */ - public function getDynamicBySearch($products, $projects, $queryID, $orderBy = 'date_desc', $pager) + public function getDynamicBySearch($products, $projects, $queryID, $orderBy = 'date_desc', $pager = null, $date = '', $direction = 'next') { $query = $queryID ? $this->loadModel('search')->getQuery($queryID) : ''; @@ -663,7 +670,9 @@ class actionModel extends model $actionQuery = str_replace("`product` = '$productID'", "`product` LIKE '%,$productID,%'", $actionQuery); + if($date) $actionQuery = "($actionQuery) AND " . ('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'"); $actions = $this->getBySQL($actionQuery, $orderBy, $pager); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'action'); if(!$actions) return array(); return $this->transformActions($actions); } @@ -981,10 +990,11 @@ class actionModel extends model * Build date group by actions * * @param array $actions + * @param string $direction * @access public * @return array */ - public function buildDateGroup($actions) + public function buildDateGroup($actions, $direction = 'next') { $dateGroup = array(); foreach($actions as $action) @@ -995,6 +1005,43 @@ class actionModel extends model $dateGroup[$date][] = $action; } + if($dateGroup) + { + $lastDateActions = $this->dao->select('*')->from(TABLE_ACTION)->where($this->session->actionQueryCondition)->andWhere('`date`')->like(substr($action->originalDate, 0, 10) . '%')->orderBy($this->session->actionOrderBy)->fetchAll('id'); + if(count($dateGroup[$date]) < count($lastDateActions)) + { + unset($dateGroup[$date]); + $lastDateActions = $this->transformActions($lastDateActions); + foreach($lastDateActions as $action) + { + $timeStamp = strtotime(isset($action->originalDate) ? $action->originalDate : $action->date); + $date = date(DT_DATE4, $timeStamp); + $action->time = date(DT_TIME2, $timeStamp); + $dateGroup[$date][] = $action; + } + } + } + + if($direction != 'next') $dateGroup = array_reverse($dateGroup); return $dateGroup; } + + /** + * Check Has pre or next. + * + * @param string $date + * @param string $direction + * @access public + * @return bool + */ + public function hasPreOrNext($date, $direction = 'next') + { + $condition = $this->session->actionQueryCondition; + /* Remove date condition for direction. */ + $condition = preg_replace("/AND +date[\<\>]'\d{4}\-\d{2}\-\d{2}'/", '', $condition); + $count = $this->dao->select('count(*) as count')->from(TABLE_ACTION)->where($condition) + ->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'") + ->fetch('count'); + return $count > 0; + } } diff --git a/module/block/view/admin.html.php b/module/block/view/admin.html.php index 463eeff3e5..01a89a8f14 100644 --- a/module/block/view/admin.html.php +++ b/module/block/view/admin.html.php @@ -39,7 +39,7 @@ include '../../common/view/chosen.html.php';
-   +
diff --git a/module/block/view/dashboard.html.php b/module/block/view/dashboard.html.php index c6914f3efb..36d4292e00 100644 --- a/module/block/view/dashboard.html.php +++ b/module/block/view/dashboard.html.php @@ -32,20 +32,20 @@ $useGuest = $this->app->user->account == 'guest';