diff --git a/module/common/lang/en.php b/module/common/lang/en.php
index 8c0f61f444..c2d556c299 100644
--- a/module/common/lang/en.php
+++ b/module/common/lang/en.php
@@ -196,7 +196,6 @@ $lang->product->menu->roadmap = 'Roadmap|product|roadmap|productID=%s';
$lang->product->menu->doc = array('link' => 'Document|doc|objectLibs|type=product&objectID=%s&from=product', 'subModule' => 'doc');
$lang->product->menu->branch = '@branch@|branch|manage|productID=%s';
$lang->product->menu->module = 'Module|tree|browse|productID=%s&view=story';
-$lang->product->menu->category = 'Category|tree|browse|productID=%s&view=category';
$lang->product->menu->view = array('link' => 'Overview|product|view|productID=%s', 'alias' => 'edit');
$lang->product->menu->project = "{$lang->projectCommon}|product|project|status=all&productID=%s";
$lang->product->menu->create = array('link' => " Add{$lang->productCommon}|product|create", 'float' => 'right');
diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php
index 48271a6558..b6b235bfa2 100644
--- a/module/common/lang/zh-cn.php
+++ b/module/common/lang/zh-cn.php
@@ -196,7 +196,6 @@ $lang->product->menu->roadmap = '路线图|product|roadmap|productID=%s';
$lang->product->menu->doc = array('link' => '文档|doc|objectLibs|type=product&objectID=%s&from=product', 'subModule' => 'doc');
$lang->product->menu->branch = '@branch@|branch|manage|productID=%s';
$lang->product->menu->module = '模块|tree|browse|productID=%s&view=story';
-$lang->product->menu->category = '目录|tree|browse|productID=%s&view=category';
$lang->product->menu->view = array('link' => '概况|product|view|productID=%s', 'alias' => 'edit');
$lang->product->menu->project = "{$lang->projectCommon}|product|project|status=all&productID=%s";
$lang->product->menu->create = array('link' => " 添加{$lang->productCommon}|product|create", 'float' => 'right');
@@ -788,7 +787,6 @@ if(isset($config->global->flow) and $config->global->flow == 'onlyTest')
unset($lang->product->menu->roadmap);
unset($lang->product->menu->doc);
unset($lang->product->menu->module);
- unset($lang->product->menu->category);
unset($lang->product->menu->index);
$lang->product->menu->build = array('link' => '版本|product|build', 'subModule' => 'build');
diff --git a/module/doc/js/common.js b/module/doc/js/common.js
index 161cd7f325..57c87d4479 100644
--- a/module/doc/js/common.js
+++ b/module/doc/js/common.js
@@ -222,7 +222,7 @@ function toggleAcl(acl)
$(document).ready(function()
{
- $('[data-id="create"] a').modalTrigger({type: 'iframe', width: 800});
+ $('[data-id="create"] a[href*=doc][href*=createLib]').modalTrigger({type: 'iframe', width: 800});
$('#modulemenu .nav li').removeClass('active');
if(typeof(type) != 'undefined') $('#modulemenu .nav li[data-id="' + type + '"]').addClass('active');
diff --git a/module/product/control.php b/module/product/control.php
index ce91e9174e..2310c03d58 100644
--- a/module/product/control.php
+++ b/module/product/control.php
@@ -394,6 +394,7 @@ class product extends control
$this->view->actions = $this->loadModel('action')->getList('product', $productID);
$this->view->users = $this->user->getPairs('noletter');
$this->view->groups = $this->loadModel('group')->getPairs();
+ $this->view->categories = $this->loadModel('tree')->getOptionMenu($rootID = 0, $type = 'category');
$this->display();
}
@@ -584,7 +585,23 @@ class product extends control
$productsPinyin = common::convert2Pinyin($productPairs);
foreach($products as $key => $product) $product->key = $productsPinyin[$product->name];
- $this->view->products = $products;
+
+ /* Sort products as categories' order first. */
+ $categories = $this->loadModel('tree')->getOptionMenu($rootID = 0, $type = 'category');
+ $productList = array();
+ foreach($categories as $id => $category)
+ {
+ foreach($products as $product)
+ {
+ if($product->category == $id)
+ {
+ $product->name = ltrim($category. '/' . $product->name, '/');
+ $productList[] = $product;
+ }
+ }
+ }
+
+ $this->view->products = $productList;
$this->display();
}
@@ -631,6 +648,7 @@ class product extends control
* All product.
*
* @param int $productID
+ * @param int $category
* @param string $status
* @param string $orderBy
* @param int $recTotal
@@ -639,7 +657,7 @@ class product extends control
* @access public
* @return void
*/
- public function all($productID = 0, $status = 'noclosed', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
+ public function all($productID = 0, $category = 0, $status = 'noclosed', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
{
$this->session->set('productList', $this->app->getURI(true));
$productID = $this->product->saveState($productID, $this->products);
@@ -652,13 +670,13 @@ class product extends control
$this->app->loadLang('my');
$this->view->title = $this->lang->product->allProduct;
$this->view->position[] = $this->lang->product->allProduct;
- $this->view->productStats = $this->product->getStats($orderBy, $pager, $status);
+ $this->view->productStats = $this->product->getStats($orderBy, $pager, $status, $category);
+ $this->view->categoryTree = $this->loadModel('tree')->getTreeMenu(0, $viewType = 'category', $startModuleID = 0, array('treeModel', 'createCategoryLink'), array('productID' => $productID, 'status' => $status));
$this->view->productID = $productID;
- $this->view->pager = $pager;
- $this->view->recTotal = $pager->recTotal;
- $this->view->recPerPage = $pager->recPerPage;
- $this->view->orderBy = $orderBy;
+ $this->view->category = $category;
$this->view->status = $status;
+ $this->view->orderBy = $orderBy;
+ $this->view->pager = $pager;
$this->display();
}
diff --git a/module/product/model.php b/module/product/model.php
index fbf7193973..0f44888c01 100644
--- a/module/product/model.php
+++ b/module/product/model.php
@@ -181,6 +181,8 @@ class productModel extends model
{
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProduct();
$product = $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch();
+ if(!$product) return false;
+
return $this->loadModel('file')->replaceImgURL($product, 'desc');
}
@@ -201,13 +203,15 @@ class productModel extends model
*
* @param string $status
* @param int $limit
+ * @param int $category
* @access public
* @return array
*/
- public function getList($status = 'all', $limit = 0)
+ public function getList($status = 'all', $limit = 0, $category = 0)
{
return $this->dao->select('*')->from(TABLE_PRODUCT)
->where('deleted')->eq(0)
+ ->beginIF($category > 0)->andWhere('category')->eq($category)->fi()
->beginIF($status == 'noclosed')->andWhere('status')->ne('closed')->fi()
->beginIF($status != 'all' and $status != 'noclosed' and $status != 'involved')->andWhere('status')->in($status)->fi()
->beginIF($status == 'involved')
@@ -664,17 +668,19 @@ class productModel extends model
* Get product stats.
*
* @param string $orderBy
- * @param int $pager
+ * @param object $pager
+ * @param string $status
+ * @param int $category
* @access public
* @return array
*/
- public function getStats($orderBy = 'order_desc', $pager = null, $status = 'noclosed')
+ public function getStats($orderBy = 'order_desc', $pager = null, $status = 'noclosed', $category = 0)
{
$this->loadModel('report');
$this->loadModel('story');
$this->loadModel('bug');
- $products = $this->getList($status);
+ $products = $this->getList($status, $limit = 0, $category);
foreach($products as $productID => $product)
{
if(!$this->checkPriv($product)) unset($products[$productID]);
diff --git a/module/product/view/all.html.php b/module/product/view/all.html.php
index 250e5133d0..dfdb47bd47 100644
--- a/module/product/view/all.html.php
+++ b/module/product/view/all.html.php
@@ -20,89 +20,106 @@
createLink('product', 'create'), " " . $lang->product->create,'', "class='btn'") ?>
- " . html::a(inlink("all", "productID=$productID&status=noclosed"), $lang->product->unclosed) . '';?>
- " . html::a(inlink("all", "productID=$productID&status=closed"), $lang->product->statusList['closed']) . '';?>
- " . html::a(inlink("all", "productID=$productID&status=all"), $lang->product->allProduct) . '';?>
+ " . html::a(inlink("all", "productID=$productID&category=&status=noclosed"), $lang->product->unclosed) . '';?>
+ " . html::a(inlink("all", "productID=$productID&category=&status=closed"), $lang->product->statusList['closed']) . '';?>
+ " . html::a(inlink("all", "productID=$productID&category=&status=all"), $lang->product->allProduct) . '';?>
-
-
-
-
-
-
-
my->home->noProductsTip ?>
- createLink('product', 'create'), "
" . $lang->my->home->createProduct,'', "class='btn btn-success'") ?>
+
+
+
+
+
icons['product']);?> product->category;?>
+
+
+
+ tree->manageCategory);?>
+
+
-
-
-
+
diff --git a/module/product/view/close.html.php b/module/product/view/close.html.php
index 6146041c29..9d2c225134 100644
--- a/module/product/view/close.html.php
+++ b/module/product/view/close.html.php
@@ -24,11 +24,12 @@
diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php
index 58e942f997..455a512e42 100644
--- a/module/product/view/create.html.php
+++ b/module/product/view/create.html.php
@@ -32,7 +32,8 @@
| product->category;?> |
- | |
+ |
+ tree->manageCategory);?> |
| product->PO;?> |
diff --git a/module/product/view/edit.html.php b/module/product/view/edit.html.php
index 961b106b03..20636ca010 100644
--- a/module/product/view/edit.html.php
+++ b/module/product/view/edit.html.php
@@ -33,7 +33,8 @@
| product->category;?> |
- category, "class='form-control chosen'");?> | |
+ category, "class='form-control chosen'");?> |
+ tree->manageCategory);?> |
| product->PO;?> |
diff --git a/module/product/view/view.html.php b/module/product/view/view.html.php
index ac5c808e5f..a418237504 100644
--- a/module/product/view/view.html.php
+++ b/module/product/view/view.html.php
@@ -69,6 +69,10 @@
product->code;?> |
code;?> |
+
+ | product->category;?> |
+ category);?> |
+
| product->PO;?> |
PO);?> |
diff --git a/module/productplan/control.php b/module/productplan/control.php
index 40b9ebc602..28df9505ce 100644
--- a/module/productplan/control.php
+++ b/module/productplan/control.php
@@ -26,7 +26,7 @@ class productplan extends control
$this->view->product = $product;
$this->view->branch = $branch;
$this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID);
- $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$this->view->product->id}&branch=$branch"), $this->view->product->name);
+ $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$productID}&branch=$branch"), $product->name);
$this->product->setMenu($this->product->getPairs(), $productID, $branch);
}
diff --git a/module/project/model.php b/module/project/model.php
index 5471b83242..7e7b92ca43 100644
--- a/module/project/model.php
+++ b/module/project/model.php
@@ -1217,11 +1217,13 @@ class projectModel extends model
/* Link stories. */
$projectStories = $this->loadModel('story')->getProjectStoryPairs($projectID);
+ $lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
foreach($stories as $storyID)
{
if(!isset($projectStories[$storyID]))
{
$story = $this->dao->findById($storyID)->fields("$projectID as project, id as story, product, version")->from(TABLE_STORY)->fetch();
+ $story->order = ++$lastOrder;
$this->dao->insert(TABLE_PROJECTSTORY)->data($story)->exec();
}
}
@@ -1377,7 +1379,8 @@ class projectModel extends model
{
if($this->post->stories == false) return false;
$this->loadModel('action');
- $versions = $this->loadModel('story')->getVersions($this->post->stories);
+ $versions = $this->loadModel('story')->getVersions($this->post->stories);
+ $lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
foreach($this->post->stories as $key => $storyID)
{
$productID = (int)$this->post->products[$storyID];
@@ -1386,6 +1389,7 @@ class projectModel extends model
$data->product = $productID;
$data->story = $storyID;
$data->version = $versions[$storyID];
+ $data->order = ++$lastOrder;
$this->dao->insert(TABLE_PROJECTSTORY)->data($data)->exec();
$this->story->setStage($storyID);
$this->action->create('story', $storyID, 'linked2project', '', $projectID);
@@ -1403,8 +1407,18 @@ class projectModel extends model
public function unlinkStory($projectID, $storyID)
{
$this->dao->delete()->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('story')->eq($storyID)->limit(1)->exec();
+
+ $order = 1;
+ $storys = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order')->fetchAll();
+ foreach($storys as $projectstory)
+ {
+ if($projectstory->order != $order) $this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('project')->eq($projectID)->andWhere('story')->eq($projectstory->story)->exec();
+ $order++;
+ }
+
$this->loadModel('story')->setStage($storyID);
$this->loadModel('action')->create('story', $storyID, 'unlinkedfromproject', '', $projectID);
+
$tasks = $this->dao->select('id')->from(TABLE_TASK)->where('story')->eq($storyID)->andWhere('project')->eq($projectID)->andWhere('status')->in('wait,doing')->fetchPairs('id');
$this->dao->update(TABLE_TASK)->set('status')->eq('cancel')->where('id')->in($tasks)->exec();
foreach($tasks as $taskID)
diff --git a/module/story/model.php b/module/story/model.php
index f3d876ff5b..d3c73d8229 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -186,11 +186,13 @@ class storyModel extends model
if($projectID != 0 and $story->status != 'draft')
{
+ $lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
$this->dao->insert(TABLE_PROJECTSTORY)
->set('project')->eq($projectID)
->set('product')->eq($this->post->product)
->set('story')->eq($storyID)
->set('version')->eq(1)
+ ->set('order')->eq($lastOrder + 1)
->exec();
}
diff --git a/module/testsuite/model.php b/module/testsuite/model.php
index f2a1f288d7..ff2ea3d1e0 100644
--- a/module/testsuite/model.php
+++ b/module/testsuite/model.php
@@ -177,7 +177,7 @@ class testsuiteModel extends model
*/
public function getById($suiteID, $setImgSize = false)
{
- $suite = $this->dao->select("*")->from(TABLE_TESTSUITE)->where('id')->eq((int)$suiteID)->fetch();
+ $suite = $this->dao->select('*')->from(TABLE_TESTSUITE)->where('id')->eq((int)$suiteID)->fetch();
$suite = $this->loadModel('file')->replaceImgURL($suite, 'desc');
if($setImgSize) $suite->desc = $this->file->setImgSize($suite->desc);
return $suite;
diff --git a/module/tree/control.php b/module/tree/control.php
index 0730e767c0..a6c121eba0 100644
--- a/module/tree/control.php
+++ b/module/tree/control.php
@@ -28,7 +28,7 @@ class tree extends control
if(strpos('story|bug|case|category', $viewType) !== false)
{
$product = $this->loadModel('product')->getById($rootID);
- if($product->type != 'normal')
+ if(!empty($product->type) && $product->type != 'normal')
{
$branches = $this->loadModel('branch')->getPairs($product->id);
if($currentModuleID)
diff --git a/module/tree/js/browse.js b/module/tree/js/browse.js
index c7232c3e90..5fce104d12 100644
--- a/module/tree/js/browse.js
+++ b/module/tree/js/browse.js
@@ -71,6 +71,5 @@ function toggleCopy()
$(document).ready(function()
{
toggleCopy();
- $('[data-id="create"] a').modalTrigger({type: 'iframe', width: 500});
$('[data-id="edit"] a').modalTrigger({type: 'iframe', width: 500});
});
diff --git a/module/tree/model.php b/module/tree/model.php
index 4944937fc7..97271cd1da 100644
--- a/module/tree/model.php
+++ b/module/tree/model.php
@@ -752,20 +752,38 @@ class treeModel extends model
/**
* Create link of a story.
*
- * @param object $module
+ * @param string $type
+ * @param object $module
* @access public
* @return string
*/
public function createStoryLink($type, $module)
{
- $linkHtml = html::a(helper::createLink('product', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('product', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
+ }
+
+ /**
+ * Create link of a product.
+ *
+ * @param string $type
+ * @param object $module
+ * @param array $extra
+ * @access public
+ * @return string
+ */
+ public function createCategoryLink($type, $module, $extra)
+ {
+ $productID = $extra['productID'];
+ $status = $extra['status'];
+ return html::a(helper::createLink('product', 'all', "productID={$productID}&category={$module->id}&status={$status}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
* Create link of a task.
*
- * @param object $module
+ * @param string $type
+ * @param object $module
+ * @param array $extra
* @access public
* @return string
*/
@@ -773,8 +791,7 @@ class treeModel extends model
{
$projectID = $extra['projectID'];
$productID = $extra['productID'];
- $linkHtml = html::a(helper::createLink('project', 'task', "root={$projectID}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('project', 'task', "root={$projectID}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -790,8 +807,7 @@ class treeModel extends model
{
$projectID = $extra['projectID'];
$productID = $extra['productID'];
- $linkHtml = html::a(helper::createLink('project', 'story', "root={$projectID}&orderBy=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('project', 'story', "root={$projectID}&orderBy=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -803,9 +819,7 @@ class treeModel extends model
*/
public function createDocLink($type, $module, $extra = '')
{
- $libID = $module->root;
- $linkHtml = html::a(helper::createLink('doc', 'browse', "libID={$libID}&browseType=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('doc', 'browse', "libID={$module->root}&browseType=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -877,8 +891,7 @@ class treeModel extends model
*/
public function createBugLink($type, $module)
{
- $linkHtml = html::a(helper::createLink('bug', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('bug', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -890,8 +903,7 @@ class treeModel extends model
*/
public function createCaseLink($type, $module)
{
- $linkHtml = html::a(helper::createLink('testcase', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('testcase', 'browse', "root={$module->root}&branch=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -903,8 +915,7 @@ class treeModel extends model
*/
public function createTestTaskLink($type, $module, $extra)
{
- $linkHtml = html::a(helper::createLink('testtask', 'cases', "taskID=$extra&type=byModule&module={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('testtask', 'cases', "taskID=$extra&type=byModule&module={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -917,8 +928,7 @@ class treeModel extends model
*/
public function createCaseLibLink($type, $module)
{
- $linkHtml = html::a(helper::createLink('testsuite', 'library', "root={$module->root}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
- return $linkHtml;
+ return html::a(helper::createLink('testsuite', 'library', "root={$module->root}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
}
/**
@@ -935,7 +945,7 @@ class treeModel extends model
{
if($type == 'story') return html::a(helper::createLink('product', 'browse', "productID={$rootID}&branch=$branchID"), $branch, '_self', "id='branch{$branchID}'");
if($type == 'bug') return html::a(helper::createLink('bug', 'browse', "productID={$rootID}&branch=$branchID"), $branch, '_self', "id='branch{$branchID}'");
- if($type == 'case') return html::a(helper::createLink('testcase', 'browse', "productID={$rootID}&branch=$branchID"), $branch, '_self', "id='branch{$branchID}'");
+ if($type == 'case') return html::a(helper::createLink('testcase', 'browse', "productID={$rootID}&branch=$branchID"), $branch, '_self', "id='branch{$branchID}'");
}
/**
@@ -1195,6 +1205,8 @@ class treeModel extends model
*/
public function manageChild($rootID, $type, $parentModuleID, $childs)
{
+ if($type == 'category') $rootID = 0;
+
$this->checkUnique($rootID, $type, $parentModuleID, $childs);
$parentModule = $this->getByID($parentModuleID);
diff --git a/module/tree/view/browse.html.php b/module/tree/view/browse.html.php
index 0a71eccc18..50ce4a4317 100644
--- a/module/tree/view/browse.html.php
+++ b/module/tree/view/browse.html.php
@@ -11,7 +11,8 @@
*/
?>
-type != 'normal') ? true : false;?>
+
+type) && $root->type != 'normal')) ? true : false;?>
tree->category : $lang->tree->name;?>
tree->manageCategory : $lang->tree->common;?>
@@ -28,7 +29,7 @@
-