diff --git a/module/block/config.php b/module/block/config.php index 4d42c10ddc..0285d745dc 100644 --- a/module/block/config.php +++ b/module/block/config.php @@ -12,3 +12,6 @@ $config->block = new stdclass(); $config->block->editor = new stdclass(); $config->block->editor->set = array('id' => 'html', 'tools' => 'simple'); + +$config->statistic = new stdclass(); +$config->statistic->storyStages = array('wait', 'planned', 'developing', 'testing', 'released'); diff --git a/module/block/control.php b/module/block/control.php index db45cccc07..4929316c2c 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -239,6 +239,12 @@ class block extends control $block->moreLink = $this->createLink('company', 'dynamic'); } + $block->actionLink = ''; + if($block->block == 'overview' && common::hasPriv('product', 'create')) + { + $block->actionLink = html::a($this->createLink('product', 'create'), " " . $this->lang->product->create, '', "class='btn'"); + } + if($this->block->isLongBlock($block)) { $longBlocks[$key] = $block; @@ -688,17 +694,18 @@ class block extends control } /** - * Print report block. + * Print statistic block. * * @access public * @return void */ - public function printReportBlock() + public function printStatisticBlock() { if(!empty($this->params->type) and preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) die(); $status = isset($this->params->type) ? $this->params->type : ''; $orderBy = isset($this->params->type) ? $this->params->orderBy : 'id_asc'; + $num = isset($this->params->num) ? (int)$this->params->num : 0; /* Get products. */ $products = $this->loadModel('product')->getList($status); @@ -715,11 +722,11 @@ class block extends control $products = $this->dao->select('*')->from(TABLE_PRODUCT) ->where('id')->in($productIDList) ->orderBy($orderBy) + ->beginIF($this->viewType != 'json')->limit($num)->fi() ->fetchAll('id'); /* Get stories. */ - $stories = $this->dao->select('product, stage, COUNT(status) AS count') - ->from(TABLE_STORY) + $stories = $this->dao->select('product, stage, COUNT(status) AS count')->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('product')->in($productIDList) ->groupBy('product, stage') @@ -750,9 +757,9 @@ class block extends control if($plan->end >= helper::today()) $unexpired++; } - $plan = new stdclass; - $plan->expired = $expired; - $plan->unexpired = $unexpired; + $plan = array(); + $plan['expired'] = $expired; + $plan['unexpired'] = $unexpired; $plans[$product] = $plan; } @@ -776,30 +783,49 @@ class block extends control if($project->status != 'done' && $project->status != 'closed' && $project->status != 'suspended' && $project->end < helper::today()) $delay++; } - $project = new stdclass(); - $project->doing = $doing; - $project->done = $done; - $project->delay = $delay; + $project = array(); + $project['doing'] = $doing; + $project['done'] = $done; + $project['delay'] = $delay; $projects[$product] = $project; } /* Get releases. */ - $releases = $this->dao->select('product, COUNT(*) AS count') - ->from(TABLE_RELEASE) + $releases = $this->dao->select('product, status, COUNT(*) AS count')->from(TABLE_RELEASE) ->where('deleted')->eq(0) ->andWhere('product')->in($productIDList) + ->groupBy('product, status') + ->fetchGroup('product', 'status'); + foreach($releases as $product => $release) + { + $release['normal'] = isset($release['normal']) ? $release['normal']->count : 0; + $release['terminate'] = isset($release['terminate']) ? $release['terminate']->count : 0; + + $releases[$product] = $release; + } + + /* Get last releases. */ + $lastReleases = $this->dao->select('product, COUNT(*) AS count')->from(TABLE_RELEASE) + ->where('date')->eq(date('Y-m-d', strtotime('-1 day'))) + ->andWhere('product')->in($productIDList) ->groupBy('product') ->fetchPairs(); foreach($products as $productID => $product) { - $product->stories = isset($stories[$productID]) ? $stories[$productID] : 0; - $product->plans = isset($plans[$productID]) ? $plans[$productID] : 0; - $product->projects = isset($projects[$productID]) ? $projects[$productID] : 0; - $product->releases = isset($releases[$productID]) ? $releases[$productID] : 0; + $product->stories = isset($stories[$productID]) ? $stories[$productID] : 0; + $product->plans = isset($plans[$productID]) ? $plans[$productID] : 0; + $product->projects = isset($projects[$productID]) ? $projects[$productID] : 0; + $product->releases = isset($releases[$productID]) ? $releases[$productID] : 0; + $product->lastRelease = isset($lastReleases[$productID]) ? $lastReleases[$productID] : 0; } + $this->app->loadLang('story'); + $this->app->loadLang('productplan'); + $this->app->loadLang('project'); + $this->app->loadLang('release'); + $this->view->products = $products; } diff --git a/module/block/lang/en.php b/module/block/lang/en.php index 8493ae604f..dd17671e6d 100644 --- a/module/block/lang/en.php +++ b/module/block/lang/en.php @@ -57,11 +57,12 @@ $lang->block->hidden = 'Hide'; $lang->block->dynamicInfo = "%s, %s %s %s %s"; $lang->block->default['product']['1']['title'] = $lang->productCommon . ' Report'; -$lang->block->default['product']['1']['block'] = 'report'; +$lang->block->default['product']['1']['block'] = 'statistic'; $lang->block->default['product']['1']['grid'] = 8; $lang->block->default['product']['1']['params']['orderBy'] = 'id_desc'; $lang->block->default['product']['1']['params']['type'] = 'noclosed'; +$lang->block->default['product']['1']['params']['num'] = 5; $lang->block->default['product']['2']['title'] = $lang->productCommon . ' Overview'; $lang->block->default['product']['2']['block'] = 'overview'; @@ -223,12 +224,12 @@ $lang->block->moduleList['todo'] = 'Todo'; $lang->block->modules['product'] = new stdclass(); $lang->block->modules['product']->availableBlocks = new stdclass(); -$lang->block->modules['product']->availableBlocks->report = $lang->productCommon . ' Report'; -$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . ' Overview'; -$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . 'List'; -$lang->block->modules['product']->availableBlocks->story = 'Stories'; -$lang->block->modules['product']->availableBlocks->plan = 'Plans'; -$lang->block->modules['product']->availableBlocks->release = 'Releases'; +$lang->block->modules['product']->availableBlocks->statistic = $lang->productCommon . ' Report'; +$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . ' Overview'; +$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . 'List'; +$lang->block->modules['product']->availableBlocks->story = 'Stories'; +$lang->block->modules['product']->availableBlocks->plan = 'Plans'; +$lang->block->modules['product']->availableBlocks->release = 'Releases'; $lang->block->modules['project'] = new stdclass(); $lang->block->modules['project']->availableBlocks = new stdclass(); $lang->block->modules['project']->availableBlocks->list = $lang->projectCommon . 'List'; diff --git a/module/block/lang/zh-cn.php b/module/block/lang/zh-cn.php index 19864c430d..f34a5ab188 100644 --- a/module/block/lang/zh-cn.php +++ b/module/block/lang/zh-cn.php @@ -57,11 +57,12 @@ $lang->block->hidden = '隐藏'; $lang->block->dynamicInfo = "%s, %s %s %s %s"; $lang->block->default['product']['1']['title'] = $lang->productCommon . '统计'; -$lang->block->default['product']['1']['block'] = 'report'; +$lang->block->default['product']['1']['block'] = 'statistic'; $lang->block->default['product']['1']['grid'] = 8; $lang->block->default['product']['1']['params']['orderBy'] = 'id_desc'; $lang->block->default['product']['1']['params']['type'] = 'noclosed'; +$lang->block->default['product']['1']['params']['num'] = 5; $lang->block->default['product']['2']['title'] = $lang->productCommon . '总览'; $lang->block->default['product']['2']['block'] = 'overview'; @@ -223,12 +224,12 @@ $lang->block->moduleList['todo'] = '待办'; $lang->block->modules['product'] = new stdclass(); $lang->block->modules['product']->availableBlocks = new stdclass(); -$lang->block->modules['product']->availableBlocks->report = $lang->productCommon . '统计'; -$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . '总览'; -$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . '列表'; -$lang->block->modules['product']->availableBlocks->story = '需求列表'; -$lang->block->modules['product']->availableBlocks->plan = '计划列表'; -$lang->block->modules['product']->availableBlocks->release = '发布列表'; +$lang->block->modules['product']->availableBlocks->statistic = $lang->productCommon . '统计'; +$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . '总览'; +$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . '列表'; +$lang->block->modules['product']->availableBlocks->story = '需求列表'; +$lang->block->modules['product']->availableBlocks->plan = '计划列表'; +$lang->block->modules['product']->availableBlocks->release = '发布列表'; $lang->block->modules['project'] = new stdclass(); $lang->block->modules['project']->availableBlocks = new stdclass(); $lang->block->modules['project']->availableBlocks->list = $lang->projectCommon . '列表'; diff --git a/module/block/lang/zh-tw.php b/module/block/lang/zh-tw.php index f0d3f7f8d2..8e98127a15 100644 --- a/module/block/lang/zh-tw.php +++ b/module/block/lang/zh-tw.php @@ -57,11 +57,12 @@ $lang->block->hidden = '隱藏'; $lang->block->dynamicInfo = "%s, %s %s %s %s"; $lang->block->default['product']['1']['title'] = $lang->productCommon . '統計'; -$lang->block->default['product']['1']['block'] = 'report'; +$lang->block->default['product']['1']['block'] = 'statistic'; $lang->block->default['product']['1']['grid'] = 8; $lang->block->default['product']['1']['params']['orderBy'] = 'id_desc'; $lang->block->default['product']['1']['params']['type'] = 'noclosed'; +$lang->block->default['product']['1']['params']['num'] = 5; $lang->block->default['product']['2']['title'] = $lang->productCommon . '總覽'; $lang->block->default['product']['2']['block'] = 'overview'; @@ -223,12 +224,12 @@ $lang->block->moduleList['todo'] = '待辦'; $lang->block->modules['product'] = new stdclass(); $lang->block->modules['product']->availableBlocks = new stdclass(); -$lang->block->modules['product']->availableBlocks->report = $lang->productCommon . '統計'; -$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . '總覽'; -$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . '列表'; -$lang->block->modules['product']->availableBlocks->story = '需求列表'; -$lang->block->modules['product']->availableBlocks->plan = '計劃列表'; -$lang->block->modules['product']->availableBlocks->release = '發佈列表'; +$lang->block->modules['product']->availableBlocks->statistic = $lang->productCommon . '統計'; +$lang->block->modules['product']->availableBlocks->overview = $lang->productCommon . '總覽'; +$lang->block->modules['product']->availableBlocks->list = $lang->productCommon . '列表'; +$lang->block->modules['product']->availableBlocks->story = '需求列表'; +$lang->block->modules['product']->availableBlocks->plan = '計劃列表'; +$lang->block->modules['product']->availableBlocks->release = '發佈列表'; $lang->block->modules['project'] = new stdclass(); $lang->block->modules['project']->availableBlocks = new stdclass(); $lang->block->modules['project']->availableBlocks->list = $lang->projectCommon . '列表'; diff --git a/module/block/model.php b/module/block/model.php index 223713e21a..a3bee0f833 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -394,12 +394,12 @@ class blockModel extends model } /** - * Get product report params. + * Get product statistic params. * * @access public * @return string */ - public function getReportParams() + public function getStatisticParams() { $params = new stdclass(); $params->type['name'] = $this->lang->block->type; @@ -411,7 +411,7 @@ class blockModel extends model $params->orderBy['options'] = $this->lang->block->orderByList->product; $params->orderBy['control'] = 'select'; - return json_encode($params); + return json_encode($this->onlyNumParams($params)); } /** diff --git a/module/block/view/dashboard.html.php b/module/block/view/dashboard.html.php index 36d4292e00..31f78811af 100644 --- a/module/block/view/dashboard.html.php +++ b/module/block/view/dashboard.html.php @@ -25,15 +25,14 @@ $useGuest = $this->app->user->account == 'guest';