diff --git a/module/product/control.php b/module/product/control.php index e8ef61a3c3..d4f969b7bd 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -145,6 +145,7 @@ class product extends control $this->view->productName = $this->products[$productID]; $this->view->moduleID = $moduleID; $this->view->stories = $stories; + $this->view->summary = $this->product->summary($stories); $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'story', $startModuleID = 0, array('treeModel', 'createStoryLink')); $this->view->parentModules = $this->tree->getParents($moduleID); $this->view->pager = $pager; diff --git a/module/product/model.php b/module/product/model.php index 785f1fe7ee..68b86e65eb 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -552,4 +552,18 @@ class productModel extends model } return $products; } + + /** + * Get the summary of product's stories. + * + * @param array $stories + * @access public + * @return string. + */ + public function summary($stories) + { + $totalEstimate = 0.0; + foreach($stories as $key => $story) $totalEstimate += $story->estimate; + return sprintf($this->lang->product->storySummary, count($stories), $totalEstimate); + } } diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index f31fcda1cb..f084bfb6ec 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -71,11 +71,9 @@ var browseType = ''; - $story):?> createLink('story', 'view', "storyID=$story->id"); - $totalEstimate += $story->estimate; $canView = common::hasPriv('story', 'view'); ?> @@ -124,7 +122,7 @@ var browseType = ''; echo html::commonButton($lang->story->batchClose, "onclick=\"changeAction('productStoryForm', 'batchClose', '$actionLink')\""); } } - printf($lang->product->storySummary, count($stories), $totalEstimate); + echo $summary; ?> show();?> diff --git a/module/project/control.php b/module/project/control.php index 0024094ddd..dc8fec2531 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -187,6 +187,7 @@ class project extends control /* Assign. */ $this->view->tasks = $tasks; + $this->view->summary = $this->project->summary($tasks); $this->view->tabID = 'task'; $this->view->pager = $pager; $this->view->recTotal = $pager->recTotal; diff --git a/module/project/model.php b/module/project/model.php index 95db4583b7..3f1eb64178 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1235,4 +1235,27 @@ class projectModel extends model ->page($pager) ->fetchAll(); } + + /** + * Get the summary of project. + * + * @param array $tasks + * @access public + * @return string + */ + public function summary($tasks) + { + $taskSum = $statusWait = $statusDone = $statusDoing = $statusClosed = $statusCancel = 0; + $totalEstimate = $totalConsumed = $totalLeft = 0.0; + foreach($tasks as $task) + { + $totalEstimate += $task->estimate; + $totalConsumed += $task->consumed; + $totalLeft += (($task->status == 'cancel' or $task->closedReason == 'cancel') ? 0 : $task->left); + $statusVar = 'status' . ucfirst($task->status); + $$statusVar ++; + } + + return sprintf($this->lang->project->taskSummary, count($tasks), $statusWait, $statusDoing, $totalEstimate, $totalConsumed, $totalLeft); + } } diff --git a/module/project/view/task.html.php b/module/project/view/task.html.php index 8b8ce8e581..5edef97e8f 100644 --- a/module/project/view/task.html.php +++ b/module/project/view/task.html.php @@ -73,20 +73,9 @@ var browseType = ''; actions;?> - - assignedTo == $app->user->account ? 'style=color:red' : '';?> - estimate; - $totalConsumed += $task->consumed; - $totalLeft += (($task->status == 'cancel' or $task->closedReason == 'cancel') ? 0 : $task->left); - $statusVar = 'status' . ucfirst($task->status); - $$statusVar ++; - ?> + assignedTo == $app->user->account ? 'style=color:red' : ''; ?> @@ -146,9 +135,9 @@ var browseType = ''; cookie->windowWidth > $this->config->wideSize ? 14 : 12;?>
- task->batchEdit); - printf($lang->project->taskSummary, count($tasks), $statusWait, $statusDoing, $totalEstimate, $totalConsumed, $totalLeft); + task->batchEdit); + echo $summary; ?>
show();?>