* adjust the index page.

This commit is contained in:
wangchunsheng
2011-09-18 07:48:31 +00:00
parent 67fcf63043
commit 3c98a21d5b
12 changed files with 173 additions and 88 deletions

View File

@@ -3,7 +3,7 @@ $config->my->editprofile->requiredFields = 'account,realname';
$config->my->productCounts = 5;
$config->my->projectCounts = 5;
$config->my->dynamicCounts = 10;
$config->my->dynamicCounts = 16;
$config->my->todoCounts = 10;
$config->my->taskCounts = 10;
$config->my->bugCounts = 10;

View File

@@ -40,9 +40,8 @@ class my extends control
$productStats = $this->loadModel('product')->getStats($this->config->my->productCounts);
/* Set the dynamic pager. */
$maxCounts = max(count($projectStats['charts']), count($productStats['charts'])); // Get the max counts of projects and products, thus to get more dynamics to keep smae high.
$this->app->loadClass('pager', true);
$pager = new pager(0, $this->config->my->dynamicCounts + $maxCounts);
$pager = new pager(0, $this->config->my->dynamicCounts);
$this->view->projectStats = $projectStats;
$this->view->productStats = $productStats;

View File

@@ -1,28 +1,17 @@
$(function()
{
$("#projectbox").tabs("#projectbox div.pane", {tabs: 'h2', effect: 'fade', initialIndex: 0});
$("#productbox").tabs("#productbox div.pane", {tabs: 'h2', effect: 'fade', initialIndex: 0});
/* Set the heights of every block to keep them same height. */
row1Height = $('#row1').height() - 10;
projectBoxHeight = $('#projectbox').height();
productBoxHeight = $('#productbox').height();
if(projectBoxHeight < 180) $('#projectbox').css('height', 180);
if(productBoxHeight < 180) $('#productbox').css('height', 180);
row2Height = $('#row2').height() - 10;
row1Height = row1Height > 200 ? row1Height : 200; // Min height is 200px.
row2Height = row2Height > 200 ? row2Height : 200;
$('#row1 .block').each(function(){$(this).css('height', row1Height);})
$('#row2 .block').each(function(){$(this).css('height', row2Height);})
/* Set the height of charts. */
var tabTitleHeight = 29; // The tab-title height.
var linkHeight = 10 // The product or project link height.
$('#projectbox .chartDiv').each(function()
$('.projectline').each(function()
{
chartHeight = row1Height - tabTitleHeight * projectCounts - linkHeight;
$(this).css('height', chartHeight);
})
$('#productbox .chartDiv').each(function()
{
chartHeight = row1Height - tabTitleHeight * productCounts - linkHeight;
$(this).css('height', chartHeight);
$(this).sparkline('html', {height:'25px'});
})
});

View File

@@ -1,5 +1,5 @@
<div class='block'>
<?php if(empty($productStats['charts'])):?>
<div class='block' id='productbox'>
<?php if(empty($productStats)):?>
<table class='table-1 a-center' height='100%'>
<caption><?php echo $lang->my->home->products;?></caption>
<tr>
@@ -12,20 +12,27 @@
</tr>
</table>
<?php else:?>
<table class='table-1 tab-box' id='productbox' height='100%'>
<tr>
<td valign='top'>
<?php foreach($productStats['charts'] as $productID => $chart):?>
<h2 class='tab-title' ><?php echo $lang->my->home->products . $lang->colon . $productStats['products'][$productID]->name;?></h2>
<div class='pane a-center'>
<?php
echo $chart;
echo html::a($this->createLink('product', 'browse', "productID=$productID"), $lang->my->home->productHome);
?>
</div>
<?php endforeach;?>
</td>
<table class='table-1 colored fixed' height='100%'>
<tr class='colhead'>
<th class='w-150px'><?php echo $lang->product->name;?></th>
<th><?php echo $lang->story->statusList['active'] . $lang->story->common;?></th>
<th><?php echo $lang->story->statusList['changed'] . $lang->story->common;?></th>
<th><?php echo $lang->story->statusList['draft'] . $lang->story->common;?></th>
<th><?php echo $lang->story->statusList['closed'] . $lang->story->common;?></th>
<th><?php echo $lang->product->plans;?></th>
<th><?php echo $lang->product->releases;?></th>
</tr>
<?php foreach($productStats as $product):?>
<tr class='a-center' style='height:30px'>
<td class='a-left'><?php echo html::a($this->createLink('product', 'view', 'product=' . $product->id), $product->name);?></td>
<td><?php echo $product->stories['active']?></td>
<td><?php echo $product->stories['changed']?></td>
<td><?php echo $product->stories['draft']?></td>
<td><?php echo $product->stories['closed']?></td>
<td><?php echo $product->plans?></td>
<td><?php echo $product->releases?></td>
</tr>
<?php endforeach;?>
</table>
</div>
<?php endif;?>

View File

@@ -1,5 +1,5 @@
<div class='block'>
<?php if(count($projectStats['charts']) == 0):?>
<div class='block' id='projectbox'>
<?php if(count($projectStats) == 0):?>
<table class='table-1 a-center' height='100%'>
<caption><?php echo $lang->my->home->projects;?></caption>
<tr>
@@ -7,23 +7,30 @@
</tr>
</table>
<?php else:?>
<table class='table-1 tab-box' id='projectbox'>
<tr>
<td>
<?php foreach($projectStats['charts'] as $projectID => $chart):?>
<h2 class='tab-title' ><?php echo $lang->my->home->projects . $lang->colon . $projectStats['projects'][$projectID]->name;?></h2>
<div class='pane a-center'>
<?php
echo $chart;
echo html::a($this->createLink('project', 'browse', "projectid=$projectID"), $lang->my->home->projectHome);
common::printLink('project', 'burn', "projectID=$projectID", $lang->project->largeBurnChart);
common::printLink('project', 'computeBurn', 'reload=yes', $lang->project->computeBurn, 'hiddenwin');
printf($lang->project->howToUpdateBurn, $this->createLink('help', 'field', 'module=project&method-burn&field=updateburn'));
?>
</div>
<?php endforeach;?>
</td>
<table class='table-1 fixed colored'>
<tr class='colhead'>
<th class='w-150px'><?php echo $lang->project->name;?></th>
<th class='w-date'><?php echo $lang->project->end;?></th>
<th class='w-50px'><?php echo $lang->project->totalEstimate;?></th>
<th class='w-50px'><?php echo $lang->project->totalConsumed;?></th>
<th class='w-50px'><?php echo $lang->project->totalLeft;?></th>
<th class='w-150px'><?php echo $lang->project->progess;?></th>
<th><?php echo $lang->project->burn;?></th>
</tr>
<?php foreach($projectStats as $project):?>
<tr class='a-center'>
<td class='a-left'><?php echo html::a($this->createLink('project', 'index', 'project=' . $project->id), $project->name);?></td>
<td><?php echo $project->end;?></td>
<td><?php echo $project->hours->totalEstimate;?></td>
<td><?php echo $project->hours->totalConsumed;?></td>
<td><?php echo $project->hours->totalLeft;?></td>
<td class='a-left w-150px'>
<img src='theme/default/images/main/green.png' width=<?php echo $project->hours->progress;?> height='13' text-align: />
<small><?php echo $project->hours->progress;?>%</small>
</td>
<td class='projectline a-left' values='<?php echo join(',', $project->burns);?>'></td>
</tr>
<?php endforeach;?>
</table>
<?php endif;?>
</div>

View File

@@ -10,12 +10,14 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/jquerytools.html.php';?>
<?php include '../../common/view/sparkline.html.php';?>
<?php include '../../common/view/colorize.html.php';?>
<table class='cont' id='row1'>
<tr valign='top'>
<td width='33%' style='padding-right:20px'><?php include './blockprojects.html.php';?></td>
<td width='33%' style='padding-right:20px'><?php include './blockproducts.html.php';?></td>
<td width='66%' style='padding-right:20px'>
<?php include './blockprojects.html.php';?> <br />
<?php include './blockproducts.html.php';?>
</td>
<td width='33%'><?php include './blockdynamic.html.php';?></td>
</tr>
</table>
@@ -26,10 +28,4 @@
<td width='33%'><?php include './blockbugs.html.php';?></td>
</tr>
</table>
<script language='Javascript'>
var projectCounts = <?php echo count($projectStats['charts']);?>;
var productCounts = <?php echo count($productStats['charts']);?>;
<?php for($i = 1; $i <= count($projectStats['charts']); $i ++) echo "createChart$i();"; ?>
<?php for($j = $i; $j < count($productStats['charts']) + $i; $j ++) echo "createChart$j();"; ?>
</script>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -18,8 +18,10 @@ $lang->product->create = "Create";
$lang->product->read = "Info";
$lang->product->delete = "Delete";
$lang->product->roadmap = 'Roadmap';
$lang->product->doc = 'Coc';
$lang->product->plans = 'Plans';
$lang->product->releases = 'Releases';
$lang->product->roadmap = 'Roadmap';
$lang->product->doc = 'Doc';
$lang->product->selectProduct = "Select product";
$lang->product->saveButton = " Save (S) ";

View File

@@ -18,8 +18,10 @@ $lang->product->create = "新增产品";
$lang->product->read = "产品详情";
$lang->product->delete = "删除产品";
$lang->product->roadmap = '路线图';
$lang->product->doc = '文档列表';
$lang->product->plans = '计划数';
$lang->product->releases = '发布数';
$lang->product->roadmap = '路线图';
$lang->product->doc = '文档列表';
$lang->product->selectProduct = "请选择产品";
$lang->product->saveButton = " 保存 (S) ";

View File

@@ -301,17 +301,59 @@ class productModel extends model
$this->loadModel('story');
$products = $this->getList(',normal');
$charts = array();
$i = 1;
$stats = array();
$i = 1;
$stories = $this->dao->select('product, status, count(status) AS count')
->from(TABLE_STORY)
->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->groupBy('product, status')
->fetchGroup('product', 'status');
/* Padding the stories to sure all products have records. */
$emptyStory = array_keys($this->lang->story->statusList);
foreach(array_keys($products) as $productID)
{
if(!isset($stories[$productID])) $stories[$productID] = $emptyStory;
}
/* Padding the stories to sure all status have records. */
foreach($stories as $key => $story)
{
foreach(array_keys($this->lang->story->statusList) as $status)
{
$story[$status] = isset($story[$status]) ? $story[$status]->count : 0;
}
$stories[$key] = $story;
}
$plans = $this->dao->select('product, count(*) AS count')
->from(TABLE_PRODUCTPLAN)
->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->andWhere('end')->gt(helper::now())
->groupBy('product')
->fetchPairs();
$releases = $this->dao->select('product, count(*) AS count')
->from(TABLE_RELEASE)
->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->groupBy('product')
->fetchPairs();
foreach($products as $key => $product)
{
if($this->checkPriv($product))
{
if($i <= $counts and $product->status == 'normal')
if($i <= $counts and $product->status != 'closed')
{
$this->session->set('storyReport', "product = '{$product->id}' AND deleted = '0'");
$dataXML = $this->report->createSingleXML($this->story->getDataOfStorysPerStatus($product->id), $this->lang->story->report->options->graph);
$charts[$product->id] = $this->report->createJSChart('pie2d', $dataXML, 'auto', 210);
$product->stories = $stories[$product->id];
$product->plans = isset($plans[$product->id]) ? $plans[$product->id] : 0;
$product->releases= isset($releases[$product->id]) ? $releases[$product->id] : 0;
$stats[] = $product;
$i ++;
}
}
@@ -321,6 +363,6 @@ class productModel extends model
}
}
return array('products' => $products, 'charts' => $charts);
return $stats;
}
}

View File

@@ -40,6 +40,10 @@ $lang->project->teamname = 'Team name';
$lang->project->products = 'Products';
$lang->project->childProjects= 'Child projects';
$lang->project->whitelist = 'Whitelist';
$lang->project->totalEstimate= 'Est';
$lang->project->totalConsumed= 'Done';
$lang->project->totalLeft = 'Left';
$lang->project->progess = 'Progess';
$lang->project->noProduct = 'No product';
$lang->team->account = 'Account';

View File

@@ -40,6 +40,10 @@ $lang->project->teamname = '团队名称';
$lang->project->products = '相关产品';
$lang->project->childProjects= '子项目';
$lang->project->whitelist = '分组白名单';
$lang->project->totalEstimate= '总预计';
$lang->project->totalConsumed= '总消耗';
$lang->project->totalLeft = '总剩余';
$lang->project->progess = '进度';
$lang->project->noProduct = '无产品项目';
$lang->team->account = '用户';

View File

@@ -273,36 +273,69 @@ class projectModel extends model
{
$this->loadModel('report');
$this->lang->project->charts->burn->graph->caption = '';
$this->lang->project->charts->burn->graph->xAxisName = "";
$this->lang->project->charts->burn->graph->yAxisName = "";
$burns = array();
$projects = $this->getList(',wait, doing');
$charts = array();
$i = 1;
$stats = array();
$i = 1;
/* Get total estimate, consumed and left hours of project. */
$emptyHour = (object)array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0);
$hours = $this->dao->select('project, SUM(estimate) AS totalEstimate, SUM(consumed) AS totalConsumed, SUM(`left`) AS totalLeft')
->from(TABLE_TASK)
->where('project')->in(array_keys($projects))
->andWhere('status')->ne('cancel')
->andWhere('deleted')->eq(0)
->groupBy('project')
->fetchAll('project');
/* Round them. */
foreach($hours as $hour)
{
$hour->totalEstimate = round($hour->totalEstimate, 1);
$hour->totalConsumed = round($hour->totalConsumed, 1);
$hour->totalLeft = round($hour->totalLeft, 1);
$hour->progress = round($hour->totalConsumed / ($hour->totalConsumed + $hour->totalLeft), 3) * 100;
}
/* Get tasks stats group by status. */
$tasks = $this->dao->select('project, status, count(status) AS count')
->from(TABLE_TASK)
->where('project')->in(array_keys($projects))
->andWhere('deleted')->eq(0)
->groupBy('project, status')
->fetchGroup('project', 'status');
/* Process projects. */
foreach($projects as $key => $project)
{
if($this->checkPriv($project))
{
if($i <= $counts and $project->status == 'doing')
{
/* By flash.*/
$dataXML = $this->report->createSingleXML($this->getBurnData($project->id), $this->lang->project->charts->burn->graph, $this->lang->report->singleColor);
$charts[$project->id] = $this->report->createJSChart('line', $dataXML, 'auto', 210);
// Process the end time.
$project->end = date(DT_DATE4, strtotime($project->end));
/* By flot.*/
//$dataXML = $this->report->createSingleXMLFlot($this->getBurnData($project->id));
//$charts[$project->id] = $this->report->createJSChartFlot($project->name, $dataXML, 'auto', 210);
/* Process the burns. */
$project->burns = array();
$burnData = $this->getBurnData($project->id);
foreach($burnData as $data) $project->burns[] = $data->value;
$stats[] = $project;
/* Process the hours. */
$project->hours = isset($hours[$project->id]) ? $hours[$project->id] : $emptyHour;
/* Process the tasks. */
$project->tasks = isset($tasks[$project->id]) ? $tasks[$project->id] : array();
}
}
else
{
unset($projects[$key]);
}
$i ++;
}
return array('projects' => $projects, 'charts' => $charts);
return $stats;
}
/**