diff --git a/module/testcase/control.php b/module/testcase/control.php index 4145eeb93b..a41da64252 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -727,7 +727,7 @@ class testcase extends control $this->view->cases = $cases; $this->display(); - } + } /** * Review case. @@ -806,6 +806,21 @@ class testcase extends control } } + /** + * Batch delete cases. + * + * @param int $productID + * @access public + * @return void + */ + public function batchDelete($productID = 0) + { + $caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList)); + + foreach($caseIDList as $caseID) $this->testcase->delete(TABLE_CASE, $caseID); + die(js::locate($this->session->caseList)); + } + /** * Batch change the module of case. * @@ -833,18 +848,19 @@ class testcase extends control } /** - * Batch delete cases. + * Batch review case. * - * @param int $productID + * @param string $result * @access public * @return void */ - public function batchDelete($productID = 0) + public function batchCaseTypeChange($result) { - $caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList)); + $caseIdList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList, 'parent')); + $this->testcase->batchCaseTypeChange($caseIdList, $result); - foreach($caseIDList as $caseID) $this->testcase->delete(TABLE_CASE, $caseID); - die(js::locate($this->session->caseList)); + if(dao::isError()) die(js::error(dao::getError())); + die(js::locate($this->session->caseList, 'parent')); } /** diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index f9eb794bce..07738e1c91 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -77,6 +77,7 @@ $lang->testcase->batchChangeModule = "批量修改模块"; $lang->testcase->delete = "删除"; $lang->testcase->batchDelete = "批量删除 "; $lang->testcase->batchConfirmStoryChange = "确认变更"; +$lang->testcase->batchCaseTypeChange = "用例类型"; $lang->testcase->browse = "用例列表"; $lang->testcase->groupCase = "分组浏览用例"; $lang->testcase->import = "导入"; diff --git a/module/testcase/model.php b/module/testcase/model.php index e671af5945..ef6185fc95 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -798,9 +798,36 @@ class testcaseModel extends model $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq((int)$caseID)->exec(); if(!dao::isError()) $allChanges[$caseID] = common::createChanges($oldCase, $case); } + return $allChanges; } + /** + * Batch case type change. + * + * @param array $caseIDList + * @param string $result + * @access public + * @return array + */ + public function batchCaseTypeChange($caseIdList, $result) + { + $now = helper::now(); + $actions = array(); + $this->loadModel('action'); + + foreach($caseIdList as $caseID) + { + $case = new stdClass(); + $case->lastEditedBy = $this->app->user->account; + $case->lastEditedDate = $now; + $case->type = $result; + + $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq($caseID)->exec(); + $this->action->create('case', $caseID, 'Edited', '', ucfirst($result)); + } + } + /** * Join steps to a string, thus can diff them. * diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index cb78a5b775..36fea77d82 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -85,9 +85,17 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete); echo '
  • ' . html::a('javascript:;', $lang->testcase->review, '', $class) . '
  • '; } - $actionLink = $this->createLink('testcase', 'batchConfirmStoryChange', "productID=$productID"); - $misc = common::hasPriv('testcase', 'batchConfirmStoryChange') ? "onclick=\"setFormAction('$actionLink')\"" : $class; - echo "
  • " . html::a('#', $lang->testcase->batchConfirmStoryChange, '', $misc) . "
  • "; + if(common::hasPriv('testcase', 'batchConfirmStoryChange')) + { + $actionLink = $this->createLink('testcase', 'batchConfirmStoryChange', "productID=$productID"); + $misc = common::hasPriv('testcase', 'batchConfirmStoryChange') ? "onclick=\"setFormAction('$actionLink')\"" : $class; + echo "
  • " . html::a('#', $lang->testcase->batchConfirmStoryChange, '', $misc) . "
  • "; + } + else + { + echo '
  • ' . html::a('javascript:;', $lang->testcase->batchConfirmStoryChange, '', $class) . '
  • '; + } + $actionLink = $this->createLink('testtask', 'batchRun', "productID=$productID&orderBy=$orderBy"); $misc = common::hasPriv('testtask', 'batchRun') ? "onclick=\"setFormAction('$actionLink')\"" : $class; @@ -113,6 +121,25 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete); { echo '
  • ' . html::a('javascript:;', $lang->testcase->moduleAB, '', $class) . '
  • '; } + + if(common::hasPriv('testcase', 'batchCaseTypeChange')) + { + echo "'; + } + else + { + echo '
  • ' . html::a('javascript:;', $lang->testcase->batchCaseTypeChange, '', $class) . '
  • '; + } + ?>