diff --git a/trunk/module/product/config.php b/trunk/module/product/config.php index a7a9a7d869..53dea7774a 100644 --- a/trunk/module/product/config.php +++ b/trunk/module/product/config.php @@ -1,5 +1,6 @@ loadLang('story'); $config->product->search['module'] = 'story'; $config->product->search['fields']['id'] = $lang->story->id; $config->product->search['fields']['title'] = $lang->story->title; @@ -20,4 +21,3 @@ $config->product->search['params']['lastEditedBy'] = array('operator' => '=', $config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->story->statusList); $config->product->search['params']['pri'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->story->priList); $config->product->search['params']['mailto'] = array('operator' => 'include', 'control' => 'select', 'values' => 'users'); -*/ diff --git a/trunk/module/product/control.php b/trunk/module/product/control.php index f6b91861d9..7a8da9ef49 100644 --- a/trunk/module/product/control.php +++ b/trunk/module/product/control.php @@ -49,46 +49,58 @@ class product extends control } /* 浏览某一个产品。*/ - public function browse($productID = 0, $moduleID = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($productID = 0, $queryType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - //$this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&type=byQuery"); - //$this->assign('searchForm', $this->fetch('search', 'buildForm', $this->config->product->search)); + /* 设置搜索条件。*/ + $this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&type=bySearch"); + $this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->product->search); + + /* 设置查询格式。*/ + $queryType = strtolower($queryType); /* 设置当前的产品id和模块id。*/ $this->session->set('storyList', $this->app->getURI(true)); $productID = common::saveProductState($productID, key($this->products)); - $moduleID = (int)$moduleID; - $childModuleIds = $this->tree->getAllChildID($moduleID); + $moduleID = ($queryType == 'bymodule') ? (int)$param : 0; /* 设置菜单。*/ $this->product->setMenu($this->products, $productID); /* 设置header和导航条信息。*/ - $header['title'] = $this->lang->product->index . $this->lang->colon . $this->products[$productID]; - $position[] = $this->products[$productID]; + $this->view->header->title = $this->lang->product->index . $this->lang->colon . $this->products[$productID]; + $this->view->position[] = $this->products[$productID]; /* 加载分页类,并查询stories列表。*/ $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - $stories = $this->story->getProductStories($productID, $childModuleIds, 'all', $orderBy, $pager); - /* 设置浏览模式。*/ - $browseType = $moduleID > 0 ? 'module' : 'all'; + $stories = array(); + if($queryType == 'all') + { + $stories = $this->story->getProductStories($productID, 0, 'all', $orderBy, $pager); + } + elseif($queryType == 'bymodule') + { + $childModuleIds = $this->tree->getAllChildID($moduleID); + $stories = $this->story->getProductStories($productID, $childModuleIds, 'all', $orderBy, $pager); + } + elseif($queryType == 'bysearch') + { + if($this->session->storyQuery == false) $this->session->set('storyQuery', ' 1 = 1'); + $stories = $this->story->getByQuery($this->session->storyQuery, $orderBy, $pager); + } - $this->assign('header', $header); - $this->assign('position', $position); $this->assign('productID', $productID); $this->assign('productName', $this->products[$productID]); $this->assign('moduleID', $moduleID); $this->assign('stories', $stories); $this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'product', $rooteModuleID = 0, array('treeModel', 'createStoryLink'))); $this->assign('parentModules', $this->tree->getParents($moduleID)); - $this->assign('pager', $pager->get()); - $this->assign('recTotal', $pager->recTotal); - $this->assign('recPerPage', $pager->recPerPage); + $this->assign('pager', $pager); $this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter')); $this->assign('orderBy', $orderBy); - $this->assign('browseType', $browseType); + $this->assign('queryType', $queryType); + $this->assign('moduleID', $moduleID); $this->display(); } diff --git a/trunk/module/product/lang/zh-cn.php b/trunk/module/product/lang/zh-cn.php index e4b77d305d..f0e72c2edc 100644 --- a/trunk/module/product/lang/zh-cn.php +++ b/trunk/module/product/lang/zh-cn.php @@ -48,4 +48,5 @@ $lang->product->status = '状态'; $lang->product->desc = '产品描述'; $lang->product->moduleStory = '按模块浏览'; +$lang->product->searchStory = '搜索'; $lang->product->allStory = '全部需求'; diff --git a/trunk/module/product/view/browse.html.php b/trunk/module/product/view/browse.html.php index 88102cc07f..f9eb9f6cee 100644 --- a/trunk/module/product/view/browse.html.php +++ b/trunk/module/product/view/browse.html.php @@ -31,25 +31,39 @@ function browseByModule() { $('#mainbox').addClass('yui-t7'); $('#treebox').removeClass('hidden'); - $('#featuremodule').addClass('active'); - $('#featureall').removeClass('active'); + $('#bymoduleTab').addClass('active'); + $('#allTab').removeClass('active'); + $('#bysearchTab').removeClass('active'); + $('#querybox').addClass('hidden'); } +function search(active) +{ + $('#mainbox').removeClass('yui-t7'); + $('#treebox').addClass('hidden'); + $('#querybox').removeClass('hidden'); + $('#bymoduleTab').removeClass('active'); + $('#' + active + 'Tab').removeClass('active'); + $('#bysearchTab').addClass('active'); +} +
- createLink('product', 'browse', "productID=$productID"), $lang->product->allStory);?> - product->moduleStory;?> + product->moduleStory;?> + product->searchStory;?> + createLink('product', 'browse', "productID=$productID&type=all"), $lang->product->allStory);?>
createLink('story', 'create', "productID=$productID&moduleID=$moduleID"), $lang->story->create); ?>
+
'>
-
' id='mainbox'> -
' id='treebox'> +
' id='mainbox'> +
' id='treebox'>
@@ -66,7 +80,7 @@ function browseByModule() - + recTotal}&recPerPage={$pager->recPerPage}";?> @@ -75,7 +89,7 @@ function browseByModule() - + @@ -103,12 +117,12 @@ function browseByModule()
story->id);?> story->pri);?> story->title);?>story->openedBy);?> story->estimate);?> story->status);?>story->lastEditedDate);?>story->lastEditedDate);?> action;?>
- + show();?>
diff --git a/trunk/module/story/model.php b/trunk/module/story/model.php index cbc9a71770..0d9fd53b02 100644 --- a/trunk/module/story/model.php +++ b/trunk/module/story/model.php @@ -101,6 +101,21 @@ class storyModel extends model return $this->formatStories($stories); } + /* 按照某一个查询条件获取列表。*/ + public function getByQuery($query, $orderBy, $pager = null) + { + $tmpStories = $this->dao->select('*')->from(TABLE_STORY)->where($query)->orderBy($orderBy)->page($pager)->fetchGroup('plan'); + if(!$tmpStories) return array(); + $plans = $this->dao->select('id,title')->from(TABLE_PRODUCTPLAN)->where('id')->in(array_keys($tmpStories))->fetchPairs(); + $stories = array(); + foreach($tmpStories as $planID => $planStories) + { + foreach($planStories as $story) $story->planTitle = isset($plans[$planID]) ? $plans[$planID] : ''; + $stories[] = $story; + } + return $stories; + } + /* 获得某一个项目相关的所有需求列表。*/ function getProjectStories($projectID = 0, $orderBy='id|desc', $pager = null) { diff --git a/trunk/module/tree/model.php b/trunk/module/tree/model.php index 312e6d06e6..503bb61616 100644 --- a/trunk/module/tree/model.php +++ b/trunk/module/tree/model.php @@ -137,7 +137,7 @@ class treeModel extends model /* 生成需求链接。*/ function createStoryLink($module) { - $linkHtml = html::a(helper::createLink('product', 'browse', "product={$module->product}&module={$module->id}"), $module->name, '_self', "id='module{$module->id}'"); + $linkHtml = html::a(helper::createLink('product', 'browse', "product={$module->product}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'"); return $linkHtml; }