From 3c98a21d5bc18aeacd555730a02d724cb01b6c5c Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Sun, 18 Sep 2011 07:48:31 +0000 Subject: [PATCH] * adjust the index page. --- module/my/config.php | 2 +- module/my/control.php | 3 +- module/my/js/index.js | 25 +++-------- module/my/view/blockproducts.html.php | 37 +++++++++------- module/my/view/blockprojects.html.php | 43 +++++++++++-------- module/my/view/index.html.php | 14 +++--- module/product/lang/en.php | 6 ++- module/product/lang/zh-cn.php | 6 ++- module/product/model.php | 56 +++++++++++++++++++++--- module/project/lang/en.php | 4 ++ module/project/lang/zh-cn.php | 4 ++ module/project/model.php | 61 +++++++++++++++++++++------ 12 files changed, 173 insertions(+), 88 deletions(-) diff --git a/module/my/config.php b/module/my/config.php index 8d8c8c55c7..c7a5525584 100644 --- a/module/my/config.php +++ b/module/my/config.php @@ -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; diff --git a/module/my/control.php b/module/my/control.php index 5ff1a77d88..e7c5a3f78b 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -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; diff --git a/module/my/js/index.js b/module/my/js/index.js index bea8803cc0..a2c933d982 100644 --- a/module/my/js/index.js +++ b/module/my/js/index.js @@ -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'}); }) }); diff --git a/module/my/view/blockproducts.html.php b/module/my/view/blockproducts.html.php index 435c79c440..cc6046abfb 100644 --- a/module/my/view/blockproducts.html.php +++ b/module/my/view/blockproducts.html.php @@ -1,5 +1,5 @@ -
- +
+ @@ -12,20 +12,27 @@
my->home->products;?>
- - - +
- $chart):?> -

my->home->products . $lang->colon . $productStats['products'][$productID]->name;?>

-
- createLink('product', 'browse', "productID=$productID"), $lang->my->home->productHome); - ?> -
- -
+ + + + + + + + + + + + + + + + + + +
product->name;?>story->statusList['active'] . $lang->story->common;?>story->statusList['changed'] . $lang->story->common;?>story->statusList['draft'] . $lang->story->common;?>story->statusList['closed'] . $lang->story->common;?>product->plans;?>product->releases;?>
createLink('product', 'view', 'product=' . $product->id), $product->name);?>stories['active']?>stories['changed']?>stories['draft']?>stories['closed']?>plans?>releases?>
diff --git a/module/my/view/blockprojects.html.php b/module/my/view/blockprojects.html.php index 7e37727805..438e0ee972 100644 --- a/module/my/view/blockprojects.html.php +++ b/module/my/view/blockprojects.html.php @@ -1,5 +1,5 @@ -
- +
+ @@ -7,23 +7,30 @@
my->home->projects;?>
- - - +
- $chart):?> -

my->home->projects . $lang->colon . $projectStats['projects'][$projectID]->name;?>

-
- 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')); - ?> -
- -
+ + + + + + + + + + + + + + + + + + +
project->name;?>project->end;?>project->totalEstimate;?>project->totalConsumed;?>project->totalLeft;?>project->progess;?>project->burn;?>
createLink('project', 'index', 'project=' . $project->id), $project->name);?>end;?>hours->totalEstimate;?>hours->totalConsumed;?>hours->totalLeft;?> + hours->progress;?> height='13' text-align: /> + hours->progress;?>% + burns);?>'>
diff --git a/module/my/view/index.html.php b/module/my/view/index.html.php index aaba27df62..435b810986 100644 --- a/module/my/view/index.html.php +++ b/module/my/view/index.html.php @@ -10,12 +10,14 @@ */ ?> - + - - +
+
+ +
@@ -26,10 +28,4 @@ - diff --git a/module/product/lang/en.php b/module/product/lang/en.php index b022089c7b..bfd58bc798 100644 --- a/module/product/lang/en.php +++ b/module/product/lang/en.php @@ -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) "; diff --git a/module/product/lang/zh-cn.php b/module/product/lang/zh-cn.php index 2d08b7a0cf..29765a037e 100644 --- a/module/product/lang/zh-cn.php +++ b/module/product/lang/zh-cn.php @@ -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) "; diff --git a/module/product/model.php b/module/product/model.php index b352cea285..87718c94e0 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -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; } } diff --git a/module/project/lang/en.php b/module/project/lang/en.php index 4e2a20263d..bd15eb464f 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -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'; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index e8a4afdbae..55e46c05ac 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -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 = '用户'; diff --git a/module/project/model.php b/module/project/model.php index a3e822e69d..6810d04af2 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -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; } /**