* finish task#1070.

This commit is contained in:
chencongzhi520@gmail.com
2013-01-05 07:24:29 +00:00
parent 17d4f9069c
commit b3b63c5063
6 changed files with 44 additions and 18 deletions

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -71,11 +71,9 @@ var browseType = '<?php echo $browseType;?>';
</tr>
</thead>
<tbody>
<?php $totalEstimate = 0.0;?>
<?php foreach($stories as $key => $story):?>
<?php
$viewLink = $this->createLink('story', 'view', "storyID=$story->id");
$totalEstimate += $story->estimate;
$canView = common::hasPriv('story', 'view');
?>
<tr class='a-center'>
@@ -124,7 +122,7 @@ var browseType = '<?php echo $browseType;?>';
echo html::commonButton($lang->story->batchClose, "onclick=\"changeAction('productStoryForm', 'batchClose', '$actionLink')\"");
}
}
printf($lang->product->storySummary, count($stories), $totalEstimate);
echo $summary;
?>
</div>
<?php $pager->show();?>

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -73,20 +73,9 @@ var browseType = '<?php echo $browseType;?>';
<th class='w-100px {sorter:false}'><?php echo $lang->actions;?></th>
</tr>
</thead>
<?php
$taskSum = $statusWait = $statusDone = $statusDoing = $statusClosed = $statusCancel = 0;
$totalEstimate = $totalConsumed = $totalLeft = 0.0;
?>
<tbody>
<?php foreach($tasks as $task):?>
<?php $class = $task->assignedTo == $app->user->account ? 'style=color:red' : '';?>
<?php
$totalEstimate += $task->estimate;
$totalConsumed += $task->consumed;
$totalLeft += (($task->status == 'cancel' or $task->closedReason == 'cancel') ? 0 : $task->left);
$statusVar = 'status' . ucfirst($task->status);
$$statusVar ++;
?>
<?php $class = $task->assignedTo == $app->user->account ? 'style=color:red' : ''; ?>
<tr class='a-center'>
<td>
<input type='checkbox' name='taskIDList[]' value='<?php echo $task->id;?>'/>
@@ -146,9 +135,9 @@ var browseType = '<?php echo $browseType;?>';
<?php $columns = $this->cookie->windowWidth > $this->config->wideSize ? 14 : 12;?>
<td colspan='<?php echo $columns;?>'>
<div class='f-left'>
<?php
if(common::hasPriv('task', 'batchEdit') and count($tasks))echo html::selectAll() . html::selectReverse() . html::submitButton($lang->task->batchEdit);
printf($lang->project->taskSummary, count($tasks), $statusWait, $statusDoing, $totalEstimate, $totalConsumed, $totalLeft);
<?php
if(common::hasPriv('task', 'batchEdit') and count($tasks))echo html::selectAll() . html::selectReverse() . html::submitButton($lang->task->batchEdit);
echo $summary;
?>
</div>
<?php $pager->show();?>