diff --git a/module/design/config.php b/module/design/config.php index 3dd9d6c3d1..7ce74a9c84 100644 --- a/module/design/config.php +++ b/module/design/config.php @@ -5,3 +5,26 @@ $config->design->editor->create = array('id' => 'desc', 'tools' => 'simpleTools' $config->design->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); $config->design->affectedFixedNum = 7; + +global $lang; +$config->design->search['module'] = 'design'; +$config->design->search['fields']['id'] = $lang->design->id; +$config->design->search['fields']['name'] = $lang->design->name; +$config->design->search['fields']['type'] = $lang->design->type; +$config->design->search['fields']['commit'] = $lang->design->submission; +$config->design->search['fields']['commitBy'] = $lang->design->commitBy; +$config->design->search['fields']['commitDate'] = $lang->design->commitDate; +$config->design->search['fields']['createdBy'] = $lang->design->createdBy; +$config->design->search['fields']['createdDate'] = $lang->design->createdDate; +$config->design->search['fields']['assignedTo'] = $lang->design->assignedTo; +$config->design->search['fields']['story'] = $lang->design->story; + +$config->design->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->design->search['params']['type'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->design->typeList); +$config->design->search['params']['commit'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->design->search['params']['commitBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->design->search['params']['commitDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->design->search['params']['createdBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->design->search['params']['createdDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->design->search['params']['assignedTo'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->design->search['params']['story'] = array('operator' => '=', 'control' => 'select', 'values' => ''); diff --git a/module/design/control.php b/module/design/control.php index 74e0554192..f2d10cc164 100644 --- a/module/design/control.php +++ b/module/design/control.php @@ -23,10 +23,15 @@ class design extends control * @access public * @return void */ - public function browse($productID = 0, $type = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($productID = 0, $type = 'all', $param = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode')); + $queryID = ($type == 'bySearch') ? (int)$param : 0; + /* Build the search form. */ + $actionURL = $this->createLink('design', 'browse', "productID=$productID&type=bySearch&queryID=myQueryID"); + $this->design->buildSearchForm($queryID, $actionURL); + $this->design->setProductMenu($productID); $product = $this->loadModel('product')->getById($productID); $program = $this->loadModel('project')->getById($product->program); @@ -37,7 +42,7 @@ class design extends control if($this->app->getViewType() == 'mhtml') $recPerPager = 10; $pager = pager::init($recTotal, $recPerPage, $pageID); - $designs = $this->design->getList($productID, $type, $orderBy, $pager); + $designs = $this->design->getList($productID, $type, $queryID, $orderBy, $pager); $this->view->title = $this->lang->design->browse; $this->view->position[] = $this->lang->design->browse; @@ -99,6 +104,42 @@ class design extends control $this->display(); } + /** + * Batch create + * + * @access public + * @return void + */ + public function batchCreate($productID = 0) + { + if($_POST) + { + $this->design->batchCreate($productID); + + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); + } + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + $response['locate'] = inlink('browse'); + + $this->send($response); + } + + $this->view->title = $this->lang->design->batchCreate; + $this->view->position[] = $this->lang->design->batchCreate; + + $typeList = (array)$this->lang->design->typeList; + $typeList[''] = ''; + + $this->view->typeList = $typeList; + $this->view->stories = $this->loadModel('story')->getProductStoryPairs($productID); + $this->view->users = $this->loadModel('user')->getPairs('noclosed'); + $this->display(); + } /** * View a design. * @@ -224,7 +265,7 @@ class design extends control } public function revision($repoID) - { + { $repo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq($repoID)->fetch(); $repoURL = $this->createLink('repo', 'revision', "repoID=$repo->repo&revistion=$repo->revision"); header("location:" . $repoURL); diff --git a/module/design/css/browse.css b/module/design/css/browse.css index e86f93c99b..5bcd361b88 100644 --- a/module/design/css/browse.css +++ b/module/design/css/browse.css @@ -1,3 +1,4 @@ #featurebar{display:inline-block;} .modal-dialog{width:70% !important} -table td{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;} +table td{white-space:nowrap;text-overflow:ellipsis;} +#querybox #searchform{border-bottom: 1px solid #ddd; margin-bottom: 20px;} diff --git a/module/design/lang/zh-cn.php b/module/design/lang/zh-cn.php index 15dda2b700..c5e250e67f 100644 --- a/module/design/lang/zh-cn.php +++ b/module/design/lang/zh-cn.php @@ -9,16 +9,22 @@ $lang->design->actions = '操作'; $lang->design->delete = '删除'; $lang->design->confirmDelete = '您确定要删除这个设计吗?'; $lang->design->edit = '变更'; +$lang->design->byQuery = '搜索'; $lang->design->products = '所属产品'; $lang->design->story = '相关需求'; $lang->design->file = '附件'; +$lang->design->id = '编号'; +$lang->design->story = '需求'; +$lang->design->ditto = '同上'; $lang->design->type = '设计类型'; $lang->design->name = '设计名称'; $lang->design->create = '创建设计'; +$lang->design->batchCreate = '批量创建'; $lang->design->view = '查看设计'; $lang->design->desc = '设计描述'; $lang->design->product = '所属产品'; $lang->design->basicInfo = '基础信息'; +$lang->design->commitBy = '由谁提交'; $lang->design->commitDate = '提交时间'; $lang->design->affectedStory = "影响{$lang->storyCommon}"; $lang->design->affectedTasks = '影响任务'; diff --git a/module/design/model.php b/module/design/model.php index d14bf74f0e..a7820ad541 100644 --- a/module/design/model.php +++ b/module/design/model.php @@ -53,6 +53,39 @@ class designModel extends model return false; } + /** + * Batch create + * + * @access public + * @return bool + */ + public function batchCreate($productID = 0) + { + $data = fixer::input('post')->get(); + + $this->loadModel('action'); + foreach($data->name as $i => $name) + { + if(!$name) continue; + + $design = new stdclass(); + $design->story = $data->story[$i]; + $design->type = $data->type[$i]; + $design->name = $name; + $design->product = $productID; + $design->program = $this->session->program; + $design->createdBy = $this->app->user->account; + $design->createdDate = helper::now(); + + $this->dao->insert(TABLE_DESIGN)->data($design)->autoCheck()->exec(); + + $designID = $this->dao->lastInsertID(); + $this->action->create('design', $designID, 'Opened'); + } + + return true; + } + /** * Update a design. * @@ -135,6 +168,11 @@ class designModel extends model $this->dao->replace(TABLE_RELATION)->data($data)->autoCheck()->exec(); } + $design = new stdclass(); + $design->commit = implode(",", $revisions); + $design->commitDate = helper::now(); + $design->commitBy = $this->app->user->account; + $this->dao->update(TABLE_DESIGN)->data($design)->autoCheck()->where('id')->eq($designID)->exec(); } /** @@ -169,7 +207,7 @@ class designModel extends model $design->productName = $this->dao->findByID($design->product)->from(TABLE_PRODUCT)->fetch('name'); - $design->commit = ''; + $design->commit = ''; $relations = $this->loadModel('common')->getRelations('design', $designID, 'commit'); foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID"), "#$relation->BID", '_blank'); return $this->loadModel('file')->replaceImgURL($design, 'desc'); @@ -224,8 +262,10 @@ class designModel extends model * @access public * @return array */ - public function getList($productID, $type = 'all', $orderBy = 'id_desc', $pager = null) + public function getList($productID, $type = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) { + if($type == 'bySearch') return $this->getBySearch($param, $orderBy, $pager); + $designs = $this->dao->select('*')->from(TABLE_DESIGN) ->where('deleted')->eq(0) ->beginIF($this->session->program)->andWhere('program')->eq($this->session->program)->fi() @@ -237,11 +277,76 @@ class designModel extends model foreach($designs as $id => $design) { - $design->commit = ''; + $design->commit = ''; $relations = $this->loadModel('common')->getRelations('design', $id, 'commit'); foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '_blank'); } return $designs; } + + /** + * Get designs by search + * + * @param string $queryID + * @param string $orderBy + * @param int $pager + * @access public + * @return object + */ + public function getBySearch($queryID = 0, $orderBy = 'id_desc', $pager = null) + { + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set('designQuery', $query->sql); + $this->session->set('designForm', $query->form); + } + else + { + $this->session->set('designQuery', ' 1 = 1'); + } + } + else + { + if($this->session->designQuery == false) $this->session->set('designQuery', ' 1 = 1'); + } + + $designQuery = $this->session->designQuery; + + $designs = $this->dao->select('*')->from(TABLE_DESIGN) + ->where($designQuery) + ->andWhere('deleted')->eq('0') + ->andWhere('program')->eq($this->session->program) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + + foreach($designs as $id => $design) + { + $design->commit = ''; + $relations = $this->loadModel('common')->getRelations('design', $id, 'commit'); + foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '_blank'); + } + + return $designs; + } + + /** + * Build search form. + * + * @param int $queryID + * @param string $actionURL + * @access public + * @return void + */ + public function buildSearchForm($queryID, $actionURL) + { + $this->config->design->search['actionURL'] = $actionURL; + $this->config->design->search['queryID'] = $queryID; + + $this->loadModel('search')->setSearchParams($this->config->design->search); + } } diff --git a/module/design/view/batchcreate.html.php b/module/design/view/batchcreate.html.php new file mode 100644 index 0000000000..b67cd556ae --- /dev/null +++ b/module/design/view/batchcreate.html.php @@ -0,0 +1,46 @@ + + * @package design + * @version $Id: batchCreate.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $ + * @link http://www.zentao.net + */ +?> + +
design->noDesign;?>
@@ -53,8 +56,8 @@