diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index fdc94c5b47..3c218f40e2 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -34,6 +34,7 @@ var browseType = ''; export, '', 'class="export"'); ?> story->report->common); ?> createLink('story', 'create', "productID=$productID&moduleID=$moduleID"), $lang->story->create); ?> + createLink('story', 'batchCreate', "productID=$productID&moduleID=$moduleID"), $lang->story->batchCreate); ?>
'>
diff --git a/module/project/model.php b/module/project/model.php index 1930bde90f..f5632d75a2 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -788,7 +788,7 @@ class projectModel extends model return $sets; } - public function getBurnDataFlot($projectID = 0, $itemCounts = 20) + public function getBurnDataFlot($projectID = 0, $itemCounts = 30) { /* Get project and burn counts. */ $project = $this->getById($projectID); @@ -828,11 +828,13 @@ class projectModel extends model $current = $nextDay; } } + $count = 0; foreach($sets as $set) { $set->name = (string)strtotime("$set->name UTC") . '000'; + $count ++; } - $sets['count'] = $counts; + $sets['count'] = $count; return $sets; } diff --git a/module/story/config.php b/module/story/config.php index ed917ef425..a30b161d4e 100644 --- a/module/story/config.php +++ b/module/story/config.php @@ -1,4 +1,5 @@ story->batchCreate = 20; $config->story->create->requiredFields = 'title'; $config->story->edit->requiredFields = 'title'; $config->story->change->requiredFields = 'title'; diff --git a/module/story/control.php b/module/story/control.php index d7302fc80d..b36dd2ce82 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -99,6 +99,64 @@ class story extends control $this->display(); } + + /** + * Create a batch stories. + * + * @param int $productID + * @param int $moduleID + * @access public + * @return void + */ + public function batchCreate($productID = 0, $moduleID = 0) + { + if(!empty($_POST)) + { + $mails = $this->story->batchCreate($productID); + if(dao::isError()) die(js::error(dao::getError())); + + foreach($mails as $mail) + { + $this->sendMail($mail->storyID, $mail->actionID); + } + die(js::locate($this->createLink('product', 'browse', "productID=$productID"), 'parent')); + } + + /* Set products, users and module. */ + $product = $this->product->getById($productID); + $products = $this->product->getPairs(); + $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story'); + + /* Set menu. */ + $this->product->setMenu($products, $product->id); + + /* Init vars. */ + $planID = 0; + $pri = 0; + $estimate = ''; + $title = ''; + $spec = ''; + + $moduleOptionMenu['same'] = $this->lang->story->same; + $plans = $this->loadModel('productplan')->getPairs($productID, 'unexpired'); + $plans['same'] = $this->lang->story->same; + + $this->view->header->title = $product->name . $this->lang->colon . $this->lang->story->create; + $this->view->position[] = html::a($this->createLink('product', 'browse', "product=$productID"), $product->name); + $this->view->position[] = $this->lang->story->create; + $this->view->products = $products; + $this->view->moduleID = $moduleID; + $this->view->moduleOptionMenu = $moduleOptionMenu; + $this->view->plans = $plans; + $this->view->planID = $planID; + $this->view->pri = $pri; + $this->view->productID = $productID; + $this->view->estimate = $estimate; + $this->view->title = $title; + $this->view->spec = $spec; + + $this->display(); + } /** * The common action when edit or change a story. @@ -450,7 +508,7 @@ class story extends control private function sendmail($storyID, $actionID) { /* Get actions. */ - $action = $this->action->getById($actionID); + $action = $this->loadModel('action')->getById($actionID); $history = $this->action->getHistory($actionID); $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); if(strtolower($action->action) == 'opened') $action->comment = $story->spec; diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 30c1061c27..fca7eb2611 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -11,6 +11,7 @@ */ $lang->story->browse = "Browse"; $lang->story->create = "Create"; +$lang->story->batchCreate = "Batch create"; $lang->story->change = "Change"; $lang->story->changed = 'Changed'; $lang->story->review = 'Review'; @@ -69,6 +70,12 @@ $lang->story->reviewResult = 'Reviewed result'; $lang->story->preVersion = 'Pre version'; $lang->story->keywords = 'Keyword'; +$lang->story->use = 'Use or not'; +$lang->story->same = 'The same up'; + +$lang->story->useList[0] = 'No use'; +$lang->story->useList[1] = 'Use'; + $lang->story->statusList[''] = ''; $lang->story->statusList['draft'] = 'Draft'; $lang->story->statusList['active'] = 'Active'; @@ -102,6 +109,9 @@ $lang->story->reviewResultList['revert'] = 'Revert'; $lang->story->reviewResultList['clarify']= 'Clarify'; $lang->story->reviewResultList['reject'] = 'Reject'; +$lang->story->reviewList[0] = 'No'; +$lang->story->reviewList[1] = 'Yes'; + $lang->story->sourceList[''] = ''; $lang->story->sourceList['custom'] = 'Custom'; $lang->story->sourceList['po'] = 'PO'; @@ -141,6 +151,7 @@ $lang->story->affectedBugs = 'Affected bugs'; $lang->story->affectedCases = 'Affected cases'; $lang->story->specTemplate = "Recommend template::As <a type of user>,I want <some goals>,so that <some reason>."; +$lang->story->needReview = 'Need review'; $lang->story->needNotReview = "needn't review"; $lang->story->confirmDelete = "Are you sure to delete this story?"; $lang->story->errorFormat = 'Error format'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index a3ecdd292e..3c6aa1b930 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -11,6 +11,7 @@ */ $lang->story->browse = "需求列表"; $lang->story->create = "新增需求"; +$lang->story->batchCreate = "批量新增需求"; $lang->story->change = "变更"; $lang->story->changed = '需求变更'; $lang->story->review = '评审'; @@ -69,6 +70,12 @@ $lang->story->reviewResult = '评审结果'; $lang->story->preVersion = '之前版本'; $lang->story->keywords = '关键词'; +$lang->story->use = '是否使用'; +$lang->story->same = '同上'; + +$lang->story->useList[0] = '不使用'; +$lang->story->useList[1] = '使用'; + $lang->story->statusList[''] = ''; $lang->story->statusList['draft'] = '草稿'; $lang->story->statusList['active'] = '激活'; @@ -102,6 +109,9 @@ $lang->story->reviewResultList['revert'] = '撤销变更'; $lang->story->reviewResultList['clarify']= '有待明确'; $lang->story->reviewResultList['reject'] = '拒绝'; +$lang->story->reviewList[0] = '否'; +$lang->story->reviewList[1] = '是'; + $lang->story->sourceList[''] = ''; $lang->story->sourceList['custom'] = '客户'; $lang->story->sourceList['po'] = '产品经理'; @@ -141,6 +151,7 @@ $lang->story->affectedBugs = '影响的Bug'; $lang->story->affectedCases = '影响的用例'; $lang->story->specTemplate = "建议参考的模板:作为一名<某种类型的用户>,我希望<达成某些目的>,这样可以<开发的价值>。"; +$lang->story->needReview = '是否需要评审'; $lang->story->needNotReview = '不需要评审'; $lang->story->confirmDelete = "您确认删除该需求吗?"; $lang->story->errorFormat = '需求数据有误'; diff --git a/module/story/model.php b/module/story/model.php index e3e59940f9..432f040b5b 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -131,6 +131,69 @@ class storyModel extends model } return false; } + /** + * Create a batch stories. + * + * @access public + * @return int|bool the id of the created story or false when error. + */ + public function batchCreate($productID = 0) + { + $now = helper::now(); + $stories = fixer::input('post')->get(); + for($i = 0; $i < $this->config->story->batchCreate; $i++) + { + if($stories->use[$i] == 1) + { + $data[$i]->module = $stories->module[$i] != 'same' ? $stories->module[$i] : ($i == 0 ? 0 : $data[$i-1]->module); + $data[$i]->plan = $stories->plan[$i] == 'same' ? ($i != 0 ? $data[$i-1]->plan : 0) : ($stories->plan[$i] != '' ? $stories->plan[$i] : 0); + $data[$i]->title = $stories->title[$i] != '' ? $stories->title[$i] : ''; + $data[$i]->pri = $stories->pri[$i] != '' ? $stories->pri[$i] : 0; + $data[$i]->estimate = $stories->estimate[$i] != '' ? $stories->estimate[$i] : 0; + $data[$i]->status = $stories->needReview[$i] == 0 ? 'active' : 'draft'; + $data[$i]->product = $productID; + $data[$i]->openedBy = $this->app->user->account; + $data[$i]->openedDate = $now; + $data[$i]->version = 1; + + $this->dao->insert(TABLE_STORY) + ->data($data[$i]) + ->autoCheck() + ->batchCheck($this->config->story->create->requiredFields, 'notempty') + ->exec(); + if(dao::isError()) + { + echo js::error(dao::getError()); + die(js::reload('parent')); + } + + $storyID = $this->dao->lastInsertID(); + + $specData[$i]->story = $storyID; + $specData[$i]->version = 1; + $specData[$i]->title = $stories->title[$i]; + if($stories->spec[$i] != '') $specData[$i]->spec = $stories->spec[$i]; + $this->dao->insert(TABLE_STORYSPEC)->data($specData[$i])->exec(); + + $this->loadModel('action'); + $actionID = $this->action->create('story', $storyID, 'Opened', ''); + $mails[$i]->storyID = $storyID; + $mails[$i]->actionID = $actionID; + } + else + { + unset($stories->use[$i]); + unset($stories->module[$i]); + unset($stories->plan[$i]); + unset($stories->title[$i]); + unset($stories->spec[$i]); + unset($stories->pri[$i]); + unset($stories->estimate[$i]); + unset($stories->needReview[$i]); + } + } + return $mails; + } /** * Change a story. diff --git a/module/story/view/batchcreate.html.php b/module/story/view/batchcreate.html.php new file mode 100644 index 0000000000..b3350d8de4 --- /dev/null +++ b/module/story/view/batchcreate.html.php @@ -0,0 +1,44 @@ + + * @package story + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+ + + + + + + + + + + + story->batchCreate; $i++):?> + + + + + + + + + + + + + +
story->product; echo $lang->story->batchCreate;?>
story->use;?> + story->module;?>story->plan;?>story->title;?>story->spec;?>story->pri;?>story->estimate;?>story->needReview;?>
story->useList, 0);?> + story->priList, $pri, 'class=select-2');?>story->reviewList, 0, "id='needNotReview'");?>
+
+