Finish task#2982 公共用例库增加导入和批量添加的功能,cost:5 left:0

This commit is contained in:
wangyidong
2017-05-03 10:33:50 +08:00
parent 99fbbbe92a
commit 22fb4f59fc
11 changed files with 897 additions and 1 deletions
+339 -1
View File
@@ -432,7 +432,7 @@ class testsuite extends control
$this->view->orderBy = $orderBy;
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter');
$this->view->modules = $this->tree->getOptionMenu($libID, $viewType = 'caselib', $startModuleID = 0);
$this->view->moduleTree = $this->tree->getTreeMenu($libID, $viewType = 'caselib', $startModuleID = 0, array('treeModel', 'createCaseLibLink'), '');
$this->view->moduleTree = $this->tree->getTreeMenu($libID, $viewType = 'caselib', $startModuleID = 0, array('treeModel', 'createCaseLibLink'));
$this->view->pager = $pager;
$this->view->browseType = $browseType;
$this->view->moduleID = $moduleID;
@@ -554,6 +554,47 @@ class testsuite extends control
$this->display();
}
/**
* Batch create case.
*
* @param int $libID
* @param int $moduleID
* @access public
* @return void
*/
public function batchCreateCase($libID, $moduleID = 0)
{
$this->loadModel('testcase');
if(!empty($_POST))
{
$caseID = $this->testsuite->batchCreateCase($libID);
if(dao::isError()) die(js::error(dao::getError()));
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('testsuite', 'library', "libID=$libID&browseType=byModule&param=$moduleID"), 'parent'));
}
$libraries = $this->testsuite->getLibraries();
if(empty($libraries)) $this->locate(inlink('createLib'));
/* Set lib menu. */
$this->testsuite->setLibMenu($libraries, $libID);
$currentModuleID = (int)$moduleID;
/* Set module option menu. */
$moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID, $viewType = 'caselib', $startModuleID = 0);
$moduleOptionMenu['ditto'] = $this->lang->testcase->ditto;
$this->view->title = $libraries[$libID] . $this->lang->colon . $this->lang->testcase->batchCreate;
$this->view->position[] = html::a($this->createLink('testsuite', 'library', "libID=$libID"), $libraries[$libID]);
$this->view->position[] = $this->lang->testcase->batchCreate;
$this->view->libID = $libID;
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->currentModuleID = $currentModuleID;
$this->display();
}
/**
* View library
*
@@ -623,4 +664,301 @@ class testsuite extends control
$this->view->keywords = $keywords;
$this->display();
}
/**
* Export templet.
*
* @param int $libID
* @access public
* @return void
*/
public function exportTemplet($libID)
{
$this->loadModel('testcase');
if($_POST)
{
if(!$this->config->testcase->needReview) unset($this->lang->testcase->statusList['wait']);
$fields['module'] = $this->lang->testcase->module;
$fields['title'] = $this->lang->testcase->title;
$fields['stepDesc'] = $this->lang->testcase->stepDesc;
$fields['stepExpect'] = $this->lang->testcase->stepExpect;
$fields['keywords'] = $this->lang->testcase->keywords;
$fields['type'] = $this->lang->testcase->type;
$fields['pri'] = $this->lang->testcase->pri;
$fields['status'] = $this->lang->testcase->status;
$fields['stage'] = $this->lang->testcase->stage;
$fields['precondition'] = $this->lang->testcase->precondition;
$fields[''] = '';
$fields['typeValue'] = $this->lang->testcase->lblTypeValue;
$fields['stageValue'] = $this->lang->testcase->lblStageValue;
$fields['statusValue'] = $this->lang->testcase->lblStatusValue;
$modules = $this->loadModel('tree')->getOptionMenu($libID, $viewType = 'caselib', $startModuleID = 0);
$rows = array();
foreach($modules as $moduleID => $module)
{
$row = new stdclass();
$row->module = $module . "(#$moduleID)";
$row->stepDesc = "1. \n2. \n3.";
$row->stepExpect = "1. \n2. \n3.";
if(empty($rows))
{
$row->typeValue = join("\n", $this->lang->testcase->typeList);
$row->stageValue = join("\n", $this->lang->testcase->stageList);
$row->statusValue = join("\n", $this->lang->testcase->statusList);
}
$rows[] = $row;
}
$this->post->set('fields', $fields);
$this->post->set('kind', 'testcase');
$this->post->set('rows', $rows);
$this->post->set('extraNum', $this->post->num);
$this->post->set('fileName', 'templet');
$this->fetch('file', 'export2csv', $_POST);
}
$this->display();
}
/**
* Import case csv file.
*
* @param int $libID
* @access public
* @return void
*/
public function import($libID)
{
$this->loadModel('testcase');
if($_FILES)
{
$file = $this->loadModel('file')->getUpload('file');
$file = $file[0];
move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
$fileName = $this->file->savePath . $file['pathname'];
$rows = $this->file->parseCSV($fileName);
$fields = $this->testcase->getImportFields($productID);
$fields = array_flip($fields);
$header = array();
foreach($rows[0] as $i => $rowValue)
{
if(empty($rowValue)) break;
$header[$i] = $rowValue;
}
unset($rows[0]);
$columnKey = array();
foreach($header as $title)
{
if(!isset($fields[$title])) continue;
$columnKey[] = $fields[$title];
}
if(count($columnKey) != count($header) or $this->post->encode != 'utf-8')
{
$fc = file_get_contents($fileName);
$encode = $this->post->encode != "utf-8" ? $this->post->encode : 'gbk';
$fc = helper::convertEncoding($fc, $encode, 'utf-8');
file_put_contents($fileName, $fc);
$rows = $this->file->parseCSV($fileName);
$columnKey = array();
$header = array();
foreach($rows[0] as $i => $rowValue)
{
if(empty($rowValue)) break;
$header[$i] = $rowValue;
}
unset($rows[0]);
foreach($header as $title)
{
if(!isset($fields[$title])) continue;
$columnKey[] = $fields[$title];
}
if(count($columnKey) != count($header)) die(js::alert($this->lang->testcase->errorEncode));
}
$this->session->set('importFile', $fileName);
die(js::locate(inlink('showImport', "libID=$libID"), 'parent.parent'));
}
$this->display();
}
/**
* Show import case.
*
* @param int $libID
* @access public
* @return void
*/
public function showImport($libID)
{
$this->loadModel('testcase');
if($_POST)
{
$this->testsuite->createFromImport($libID);
die(js::locate(inlink('library', "libID=$libID"), 'parent'));
}
$libraries = $this->testsuite->getLibraries();
if(empty($libraries)) $this->locate(inlink('createLib'));
$this->testsuite->setMenu($libraries, $libID);
$file = $this->session->importFile;
$caseLang = $this->lang->testcase;
$caseConfig = $this->config->testcase;
$modules = $this->loadModel('tree')->getOptionMenu($libID, $viewType = 'caselib', $startModuleID = 0);
$fields = explode(',', $caseConfig->exportFields);
foreach($fields as $key => $fieldName)
{
$fieldName = trim($fieldName);
$fields[$fieldName] = isset($caseLang->$fieldName) ? $caseLang->$fieldName : $fieldName;
unset($fields[$key]);
}
$fields = array_flip($fields);
$rows = $this->loadModel('file')->parseCSV($file);
$header = array();
foreach($rows[0] as $i => $rowValue)
{
if(empty($rowValue)) break;
$header[$i] = $rowValue;
}
unset($rows[0]);
foreach($header as $title)
{
if(!isset($fields[$title])) continue;
$columnKey[] = $fields[$title];
}
$endField = end($fields);
$caseData = array();
$stepData = array();
$stepVars = 0;
foreach($rows as $row => $data)
{
$case = new stdclass();
foreach($columnKey as $key => $field)
{
if(!isset($data[$key])) continue;
$cellValue = $data[$key];
if($field == 'module')
{
$case->$field = 0;
if(strrpos($cellValue, '(#') !== false)
{
$id = trim(substr($cellValue, strrpos($cellValue,'(#') + 2), ')');
$case->$field = $id;
}
}
elseif(in_array($field, $caseConfig->export->listFields))
{
if($field == 'stage')
{
$stages = explode("\n", $cellValue);
foreach($stages as $stage) $case->stage[] = array_search($stage, $caseLang->{$field . 'List'});
$case->stage = join(',', $case->stage);
}
else
{
$case->$field = array_search($cellValue, $caseLang->{$field . 'List'});
}
}
elseif($field != 'stepDesc' and $field != 'stepExpect')
{
$case->$field = $cellValue;
}
else
{
$steps = explode("\n", $cellValue);
$stepKey = str_replace('step', '', strtolower($field));
$caseStep = array();
foreach($steps as $step)
{
$step = trim($step);
if(empty($step)) continue;
if(preg_match('/^(([0-9]+)\.[0-9]+)([.、]{1})/U', $step, $out))
{
$num = $out[1];
$parent = $out[2];
$sign = $out[3];
$signbit = $sign == '.' ? 1 : 3;
$step = trim(substr($step, strlen($num) + $signbit));
if(!empty($step)) $caseStep[$num]['content'] = $step;
$caseStep[$num]['type'] = 'item';
$caseStep[$parent]['type'] = 'group';
}
elseif(preg_match('/^([0-9]+)([.、]{1})/U', $step, $out))
{
$num = $out[1];
$sign = $out[2];
$signbit = $sign == '.' ? 1 : 3;
$step = trim(substr($step, strlen($num) + $signbit));
if(!empty($step)) $caseStep[$num]['content'] = $step;
$caseStep[$num]['type'] = 'step';
}
elseif(isset($num))
{
$caseStep[$num]['content'] .= "\n" . $step;
}
else
{
if($field == 'stepDesc')
{
$num = 1;
$caseStep[$num]['content'] = $step;
$caseStep[$num]['type'] = 'step';
}
if($field == 'stepExpect' and isset($stepData[$row]['desc']))
{
end($stepData[$row]['desc']);
$num = key($stepData[$row]['desc']);
$caseStep[$num]['content'] = $step;
}
}
}
unset($num);
unset($sign);
$stepVars += count($caseStep, COUNT_RECURSIVE) - count($caseStep);
$stepData[$row][$stepKey] = $caseStep;
}
}
$caseData[$row] = $case;
unset($case);
}
if(empty($caseData))
{
echo js::alert($this->lang->error->noData);
die(js::locate($this->createLink('testsuite', 'library', "libID=$libID")));
}
if(!$this->config->testcase->needReview) unset($this->lang->testcase->statusList['wait']);
/* Judge whether the editedTasks is too large and set session. */
$countInputVars = count($caseData) * 9 + $stepVars;
$showSuhosinInfo = common::judgeSuhosinSetting($countInputVars);
if($showSuhosinInfo) $this->view->suhosinInfo = extension_loaded('suhosin') ? sprintf($this->lang->suhosinInfo, $countInputVars) : sprintf($this->lang->maxVarsInfo, $countInputVars);
$this->view->title = $this->lang->caselib->common . $this->lang->colon . $this->lang->testcase->showImport;
$this->view->position[] = $this->lang->testcase->showImport;
$this->view->modules = $modules;
$this->view->cases = $this->dao->select('id,module,stage,status,pri,type')->from(TABLE_CASE)->where('lib')->eq($libID)->andWhere('deleted')->eq(0)->andWhere('product')->eq(0)->fetchAll('id');
$this->view->caseData = $caseData;
$this->view->stepData = $stepData;
$this->view->libID = $libID;
$this->display();
}
}
+2
View File
@@ -0,0 +1,2 @@
.w-180px{width:180px}
.chosen-container[id^="module"] .chosen-drop {min-width: 400px; border-top: 1px solid #ddd!important}
+2
View File
@@ -1,5 +1,7 @@
.w-220px{width:220px}
#createActionMenu .dropdown-menu {width: 100%;}
.dropdown-menu.with-search {padding: 0; min-width: 150px; overflow: hidden; max-height: 302px;}
.dropdown-menu > .menu-search .input-group {width:100%;}
.dropdown-menu > .menu-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666}
+2
View File
@@ -0,0 +1,2 @@
.table table td,.outer .table table tbody > tr:last-child td {padding: 2px 0 2px 5px!important; border: none!important;}
.chosen-container-single .chosen-drop {min-width: 300px; border-top: 1px solid #ddd!important}
+2
View File
@@ -20,6 +20,8 @@ $lang->testsuite->linkVersion = "版本";
$lang->testsuite->unlinkCase = "移除";
$lang->testsuite->batchUnlinkCases = "批量移除用例";
$lang->testsuite->deleted = '已删除';
$lang->testsuite->exportTemplet = '导出模板';
$lang->testsuite->importFile = '导入CSV';
$lang->testsuite->common = '套件';
$lang->testsuite->product = '所属' . $lang->productCommon;
+249
View File
@@ -509,4 +509,253 @@ class testsuiteModel extends model
}
return $link;
}
/**
* Create from import.
*
* @param int $libID
* @access public
* @return void
*/
public function createFromImport($libID)
{
$this->loadModel('action');
$this->loadModel('testcase');
$this->loadModel('file');
$now = helper::now();
$data = fixer::input('post')->get();
if(!empty($_POST['id']))
{
$oldSteps = $this->dao->select('t2.*')->from(TABLE_CASE)->alias('t1')
->leftJoin(TABLE_CASESTEP)->alias('t2')->on('t1.id = t2.case')
->where('t1.id')->in(($_POST['id']))
->andWhere('t1.version=t2.version')
->orderBy('t2.id')
->fetchGroup('case');
$oldCases = $this->dao->select('*')->from(TABLE_CASE)->where('id')->in($_POST['id'])->fetchAll('id');
}
$cases = array();
foreach($data->lib as $key => $lib)
{
$caseData = new stdclass();
$caseData->lib = $lib;
$caseData->module = $data->module[$key];
$caseData->title = $data->title[$key];
$caseData->pri = (int)$data->pri[$key];
$caseData->type = $data->type[$key];
$caseData->status = $data->status[$key];
$caseData->stage = join(',', $data->stage[$key]);
$caseData->keywords = $data->keywords[$key];
$caseData->frequency = 1;
$caseData->precondition = $data->precondition[$key];
if(isset($this->config->testcase->create->requiredFields))
{
$requiredFields = explode(',', $this->config->testcase->create->requiredFields);
foreach($requiredFields as $requiredField)
{
$requiredField = trim($requiredField);
if(empty($caseData->$requiredField)) die(js::alert(sprintf($this->lang->testcase->noRequire, $key, $this->lang->testcase->$requiredField)));
}
}
$cases[$key] = $caseData;
}
$forceReview = $this->testcase->forceReview();
foreach($cases as $key => $caseData)
{
if(!empty($_POST['id'][$key]) and empty($_POST['insert']))
{
$caseID = $data->id[$key];
$stepChanged = false;
$steps = array();
$oldStep = isset($oldSteps[$caseID]) ? $oldSteps[$caseID] : array();
$oldCase = $oldCases[$caseID];
/* Remove the empty setps in post. */
$steps = array();
if(isset($_POST['desc'][$key]))
{
foreach($data->desc[$key] as $id => $desc)
{
$desc = trim($desc);
if(empty($desc))continue;
$step = new stdclass();
$step->type = $data->stepType[$key][$id];
$step->desc = $desc;
$step->expect = trim($data->expect[$key][$id]);
$steps[] = $step;
}
}
/* If step count changed, case changed. */
if((!$oldStep != !$steps) or (count($oldStep) != count($steps)))
{
$stepChanged = true;
}
else
{
/* Compare every step. */
foreach($oldStep as $id => $oldStep)
{
if(trim($oldStep->desc) != trim($steps[$id]->desc) or trim($oldStep->expect) != $steps[$id]->expect)
{
$stepChanged = true;
break;
}
}
}
$version = $stepChanged ? $oldCase->version + 1 : $oldCase->version;
$caseData->version = $version;
$changes = common::createChanges($oldCase, $caseData);
if(!$changes and !$stepChanged) continue;
if($changes or $stepChanged)
{
$caseData->lastEditedBy = $this->app->user->account;
$caseData->lastEditedDate = $now;
if($stepChanged and $forceReview) $caseData->status = 'wait';
$this->dao->update(TABLE_CASE)->data($caseData)->where('id')->eq($caseID)->autoCheck()->exec();
if($stepChanged)
{
$parentStepID = 0;
foreach($steps as $id => $step)
{
$step = (array)$step;
if(empty($step['desc'])) continue;
$stepData = new stdclass();
$stepData->type = ($step['type'] == 'item' and $parentStepID == 0) ? 'step' : $step['type'];
$stepData->parent = ($stepData->type == 'item') ? $parentStepID : 0;
$stepData->case = $caseID;
$stepData->version = $version;
$stepData->desc = htmlspecialchars($step['desc']);
$stepData->expect = htmlspecialchars($step['expect']);
$this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec();
if($stepData->type == 'group') $parentStepID = $this->dao->lastInsertID();
if($stepData->type == 'step') $parentStepID = 0;
}
}
$oldCase->steps = $this->joinStep($oldStep);
$caseData->steps = $this->joinStep($steps);
$changes = common::createChanges($oldCase, $caseData);
$actionID = $this->action->create('case', $caseID, 'Edited');
$this->action->logHistory($actionID, $changes);
}
}
else
{
$caseData->version = 1;
$caseData->openedBy = $this->app->user->account;
$caseData->openedDate = $now;
$caseData->branch = isset($data->branch[$key]) ? $data->branch[$key] : $branch;
if($forceReview) $caseData->status = 'wait';
$this->dao->insert(TABLE_CASE)->data($caseData)->autoCheck()->exec();
if(!dao::isError())
{
$caseID = $this->dao->lastInsertID();
$parentStepID = 0;
foreach($data->desc[$key] as $id => $desc)
{
$desc = trim($desc);
if(empty($desc)) continue;
$stepData = new stdclass();
$stepData->type = ($data->stepType[$key][$id] == 'item' and $parentStepID == 0) ? 'step' : $data->stepType[$key][$id];
$stepData->parent = ($stepData->type == 'item') ? $parentStepID : 0;
$stepData->case = $caseID;
$stepData->version = 1;
$stepData->desc = htmlspecialchars($desc);
$stepData->expect = htmlspecialchars($data->expect[$key][$id]);
$this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec();
if($stepData->type == 'group') $parentStepID = $this->dao->lastInsertID();
if($stepData->type == 'step') $parentStepID = 0;
}
$this->action->create('case', $caseID, 'Opened');
}
}
}
unlink($this->session->importFile);
unset($_SESSION['importFile']);
}
/**
* Batch create case for lib.
*
* @param int $libID
* @access public
* @return void
*/
public function batchCreateCase($libID)
{
$this->loadModel('testcase');
$this->loadModel('action');
$now = helper::now();
$cases = fixer::input('post')->get();
$batchNum = count(reset($cases));
$result = $this->loadModel('common')->removeDuplicate('case', $cases, "lib={$libID}");
$cases = $result['data'];
for($i = 0; $i < $batchNum; $i++)
{
if(!empty($cases->title[$i]) and empty($cases->type[$i])) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->type)));
}
$module = 0;
$type = '';
$pri = 3;
for($i = 0; $i < $batchNum; $i++)
{
$module = $cases->module[$i] == 'ditto' ? $module : $cases->module[$i];
$type = $cases->type[$i] == 'ditto' ? $type : $cases->type[$i];
$pri = $cases->pri[$i] == 'ditto' ? $pri : $cases->pri[$i];
$cases->module[$i] = (int)$module;
$cases->type[$i] = $type;
$cases->pri[$i] = $pri;
}
$forceReview = $this->testcase->forceReview();
for($i = 0; $i < $batchNum; $i++)
{
if($cases->type[$i] != '' and $cases->title[$i] != '')
{
$data[$i] = new stdclass();
$data[$i]->lib = $libID;
$data[$i]->module = $cases->module[$i];
$data[$i]->type = $cases->type[$i];
$data[$i]->pri = $cases->pri[$i];
$data[$i]->stage = empty($cases->stage[$i]) ? '' : implode(',', $cases->stage[$i]);
$data[$i]->color = $cases->color[$i];
$data[$i]->title = $cases->title[$i];
$data[$i]->precondition = $cases->precondition[$i];
$data[$i]->keywords = $cases->keywords[$i];
$data[$i]->openedBy = $this->app->user->account;
$data[$i]->openedDate = $now;
$data[$i]->status = $forceReview ? 'wait' : 'normal';
$data[$i]->version = 1;
$this->dao->insert(TABLE_CASE)->data($data[$i])
->autoCheck()
->batchCheck($this->config->testcase->create->requiredFields, 'notempty')
->exec();
if(dao::isError())
{
echo js::error(dao::getError());
die(js::reload('parent'));
}
$caseID = $this->dao->lastInsertID();
$actionID = $this->action->create('case', $caseID, 'Opened');
}
}
}
}
@@ -0,0 +1,93 @@
<?php
/**
* The batch create case view of testsuite module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package testsuite
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('testcaseBatchCreateNum', $config->testcase->batchCreate);?>
<?php js::set('libID', $libID);?>
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['testcase']);?></span>
<strong>
<small class='text-muted'><?php echo html::icon($lang->icons['batchCreate']);?></small>
<?php echo $lang->testcase->batchCreate;?>
</strong>
<div class='actions'>
<?php echo html::commonButton($lang->pasteText, "data-toggle='myModal' ")?>
</div>
</div>
</div>
<form class='form-condensed' method='post' enctype='multipart/form-data' target='hiddenwin'>
<table align='center' class='table table-form table-fixed'>
<thead>
<tr>
<th class='w-50px'> <?php echo $lang->idAB;?></th>
<th class='w-180px'><?php echo $lang->testcase->module;?></th>
<th><?php echo $lang->testcase->title;?> <span class='required'></span></th>
<th class='w-100px'><?php echo $lang->testcase->type;?> <span class='required'></span></th>
<th class='w-80px'> <?php echo $lang->testcase->pri;?></th>
<th class='w-150px'><?php echo $lang->testcase->precondition;?></th>
<th class='w-100px'><?php echo $lang->testcase->keywords;?></th>
<th class='w-200px'><?php echo $lang->testcase->stage;?></th>
</tr>
</thead>
<?php unset($lang->testcase->typeList['']);?>
<?php for($i = 0; $i < $config->testcase->batchCreate; $i++):?>
<?php
if($i != 0) $currentModuleID = 'ditto';
if($i != 0) $lang->testcase->typeList['ditto'] = $lang->testcase->ditto;
if($i != 0) $lang->testcase->priList['ditto'] = $lang->testcase->ditto;
$type = $i == 0 ? 'feature' : 'ditto';
$pri = $i == 0 ? 3 : 'ditto';
?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left' style='overflow:visible'><?php echo html::select("module[$i]", $moduleOptionMenu, $currentModuleID, "class='form-control chosen'");?></td>
<td style='overflow:visible'>
<div class='input-group'>
<?php echo html::hidden("color[$i]", '', "data-provide='colorpicker' data-wrapper='input-group-btn fix-border-right' data-pull-menu-right='false' data-btn-tip='{$lang->testcase->colorTag}' data-update-text='#title\\[{$i}\\]'");?>
<?php echo html::input("title[$i]", '', "class='form-control' autocomplete='off'");?>
</div>
</td>
<td><?php echo html::select("type[$i]", $lang->testcase->typeList, $type, "class=form-control");?></td>
<td><?php echo html::select("pri[$i]", $lang->testcase->priList, $pri, "class=form-control");?></td>
<td><?php echo html::textarea("precondition[$i]", '', "rows='1' class='form-control autosize'")?></td>
<td><?php echo html::input("keywords[$i]", '', "class='form-control' autocomplete='off'");?></td>
<td class='text-left' style='overflow:visible'><?php echo html::select("stage[$i][]", $lang->testcase->stageList, '', "class='form-control chosen' multiple");?></td>
</tr>
<?php endfor;?>
<tfoot>
<tr><td colspan='8' class='text-center'><?php echo html::submitButton() . html::backButton();?></td></tr>
</tfoot>
</table>
</form>
<table class='hide' id='trTemp'>
<tbody>
<tr class='text-center'>
<td>%s</td>
<td class='text-left' style='overflow:visible'><?php echo html::select("module[%s]", $moduleOptionMenu, $currentModuleID, "class='form-control'");?></td>
<td style='overflow:visible'>
<div class='input-group'>
<?php echo html::hidden("color[%s]", '', "data-wrapper='input-group-btn fix-border-right' data-pull-menu-right='false' data-btn-tip='{$lang->testcase->colorTag}' data-update-text='#title\\[%s\\]'");?>
<?php echo html::input("title[%s]", '', "class='form-control' autocomplete='off'");?></td>
</div>
</td>
<td><?php echo html::select("type[%s]", $lang->testcase->typeList, $type, "class=form-control");?></td>
<td><?php echo html::select("pri[%s]", $lang->testcase->priList, $pri, "class=form-control");?></td>
<td><?php echo html::textarea("precondition[%s]", '', "class='form-control'")?></td>
<td><?php echo html::input("keywords[%s]", '', "class='form-control' autocomplete='off'");?></td>
<td class='text-left' style='overflow:visible'><?php echo html::select("stage[%s][]", $lang->testcase->stageList, '', "class='form-control' multiple");?></td>
</tr>
</tbody>
</table>
<?php include '../../common/view/pastetext.html.php';?>
<?php include '../../common/view/footer.html.php';?>
@@ -0,0 +1,49 @@
<?php include '../../common/view/header.lite.html.php';?>
<script>
function setDownloading()
{
if($.browser.opera) return true; // Opera don't support, omit it.
$.cookie('downloading', 0);
time = setInterval("closeWindow()", 300);
return true;
}
function closeWindow()
{
if($.cookie('downloading') == 1)
{
parent.$.closeModal();
$.cookie('downloading', null);
clearInterval(time);
}
}
</script>
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['export']);?></span>
<strong><?php echo $lang->testcase->exportTemplet;?></strong>
</div>
</div>
<form class='form-condensed' method='post' target='hiddenwin' onsubmit='setDownloading();' style='padding: 40px 5%'>
<table class='w-p100'>
<tr>
<td>
<div class='input-group'>
<span class='input-group-addon'><?php echo $lang->testcase->num;?></span>
<?php
echo html::input('num', '10', "class='form-control' autocomplete='off'");
?>
</div>
</td>
<td class='w-100px'>
<?php echo html::select('encode', $config->charsets[$this->cookie->lang], 'utf-8', "class='form-control'");?>
</td>
<td>
<?php echo html::submitButton();?>
</td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.lite.html.php';?>
+19
View File
@@ -0,0 +1,19 @@
<?php include '../../common/view/header.lite.html.php';?>
<div class='container mw-600px'>
<form class='form-condensed' method='post' enctype='multipart/form-data' target='hiddenwin'>
<table class='table table-form'>
<tr>
<td align='center' style="padding:30px">
<input type='file' name='file' class='form-control'/>
</td>
<td>
<?php echo html::select('encode', $config->charsets[$this->cookie->lang], 'utf-8', "class='form-control'");?>
</td>
<td>
<?php echo html::submitButton();?>
</td>
</tr>
</table>
</form>
</div>
<?php include '../../common/view/footer.lite.html.php';?>
+19
View File
@@ -45,6 +45,15 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete);
?>
</div>
<div class='actions'>
<div class='btn-group'>
<?php
$link = common::hasPriv('testsuite', 'exportTemplet') ? $this->createLink('testsuite', 'exportTemplet', "libID=$libID") : '#';
if(common::hasPriv('testsuite', 'exportTemplet')) echo html::a($link, "<i class='icon-download-alt'></i> " . $lang->testsuite->exportTemplet, '', "class='btn export'");
$link = common::hasPriv('testsuite', 'import') ? $this->createLink('testsuite', 'import', "libID=$libID") : '#';
if(common::hasPriv('testsuite', 'import')) echo html::a($link, "<i class='icon-upload-alt'></i> " . $lang->testsuite->importFile, '', "class='btn export'");
?>
</div>
<div class='btn-group'>
<div class='btn-group' id='createActionMenu'>
<?php
@@ -52,6 +61,16 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete);
$link = common::hasPriv('testsuite', 'createCase') ? $this->createLink('testsuite', 'createCase', "libID=$libID&moduleID=" . (isset($moduleID) ? $moduleID : 0)) : '#';
echo html::a($link, "<i class='icon-plus'></i>" . $lang->testcase->create, '', $misc);
?>
<button type='button' class='btn btn-primary dropdown-toggle' data-toggle='dropdown'>
<span class='caret'></span>
</button>
<ul class='dropdown-menu pull-right'>
<?php
$misc = common::hasPriv('testsuite', 'batchCreateCase') ? '' : "class=disabled";
$link = common::hasPriv('testsuite', 'batchCreateCase') ? $this->createLink('testsuite', 'batchCreateCase', "libID=$libID&moduleID=" . (isset($moduleID) ? $moduleID : 0)) : '#';
echo "<li>" . html::a($link, $lang->testcase->batchCreate, '', $misc) . "</li>";
?>
</ul>
</div>
</div>
</div>
+121
View File
@@ -0,0 +1,121 @@
<?php include '../../common/view/header.html.php';?>
<style>
.affix {position:fixed; top:0px; width:95.6%;z-index:10000;}
</style>
<?php if(isset($suhosinInfo)):?>
<div class='alert alert-info'><?php echo $suhosinInfo?></div>
<?php else:?>
<form target='hiddenwin' method='post' class='form-condensed'>
<table class='table table-fixed active-disabled table-custom'>
<thead>
<tr>
<th class='w-70px'><?php echo $lang->testcase->id?></th>
<th><?php echo $lang->testcase->title?></th>
<th class='w-100px'><?php echo $lang->testcase->module?></th>
<th class='w-70px'><?php echo $lang->testcase->pri?></th>
<th class='w-100px'><?php echo $lang->testcase->type?></th>
<th class='w-100px'><?php echo $lang->testcase->status?></th>
<th><?php echo $lang->testcase->stage?></th>
<th class='w-80px'><?php echo $lang->testcase->keywords?></th>
<th><?php echo $lang->testcase->precondition?></th>
<th class='w-300px'>
<table class='w-p100 table-borderless'>
<tr>
<th><?php echo $lang->testcase->stepDesc?></th>
<th><?php echo $lang->testcase->stepExpect?></th>
</tr>
</table>
</th>
</tr>
</thead>
<tbody>
<?php $insert = true;?>
<?php foreach($caseData as $key => $case):?>
<?php if(empty($case->title)) continue;?>
<?php if(!empty($case->id) and !isset($cases[$case->id])) $case->id = 0;?>
<tr valign='top' align='center'>
<td>
<?php
if(!empty($case->id))
{
echo $case->id . html::hidden("id[$key]", $case->id);
$insert = false;
}
else
{
echo $key . " <sub class='gray' style='vertical-align:sub;'>{$lang->testcase->new}</sub>";
}
echo html::hidden("lib[$key]", $libID);
?>
</td>
<td><?php echo html::input("title[$key]", $case->title, "class='form-control' style='margin-top:2px' autocomplete='off'")?></td>
<td class='text-left' style='overflow:visible'><?php echo html::select("module[$key]", $modules, isset($case->module) ? $case->module : (!empty($case->id) ? $cases[$case->id]->module : ''), "class='form-control chosen'")?></td>
<td><?php echo html::select("pri[$key]", $lang->testcase->priList, isset($case->pri) ? $case->pri : (!empty($case->id) ? $cases[$case->id]->pri : ''), "class='form-control'")?></td>
<td><?php echo html::select("type[$key]", $lang->testcase->typeList, isset($case->type) ? $case->type : (!empty($case->id) ? $cases[$case->id]->type : ''), "class='form-control'")?></td>
<td><?php echo html::select("status[$key]", $lang->testcase->statusList, isset($case->status) ? $case->status : (!empty($case->id) ? $cases[$case->id]->status : 'normal'), "class='form-control'")?></td>
<td class='text-left' style='overflow:visible'><?php echo html::select("stage[$key][]", $lang->testcase->stageList, !empty($case->stage) ? $case->stage : (!empty($case->id) ? $cases[$case->id]->stage : ''), "multiple='multiple' class='form-control chosen'")?></td>
<td><?php echo html::input("keywords[$key]", isset($case->keywords) ? $case->keywords : "", "class='form-control' autocomplete='off'")?></td>
<td><?php echo html::textarea("precondition[$key]", isset($case->precondition) ? htmlspecialchars($case->precondition) : "", "class='form-control'")?></td>
<td>
<?php if(isset($stepData[$key]['desc'])):?>
<table class='w-p100 bd-0'>
<?php foreach($stepData[$key]['desc'] as $id => $desc):?>
<?php if(empty($desc['content'])) continue;?>
<tr class='step'>
<td><?php echo $id . html::hidden("stepType[$key][$id]", $desc['type'])?></td>
<td><?php echo html::textarea("desc[$key][$id]", htmlspecialchars($desc['content']), "class='form-control'")?></td>
<td><?php if($desc['type'] != 'group') echo html::textarea("expect[$key][$id]", isset($stepData[$key]['expect'][$id]['content']) ? htmlspecialchars($stepData[$key]['expect'][$id]['content']) : '', "class='form-control'")?></td>
</tr>
<?php endforeach;?>
</table>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='10' class='text-center'>
<?php
if(!$insert)
{
include '../../common/view/noticeimport.html.php';
echo "<button type='button' data-toggle='myModal' class='btn btn-primary'>{$lang->save}</button>";
}
else
{
echo html::submitButton();
}
echo ' &nbsp; ' . html::backButton()
?>
</td>
</tr>
</tfoot>
</table>
</form>
<?php endif;?>
<script>
$(function(){affix('thead')})
function affix(obj)
{
var fixH = $(obj).offset().top;
var first = true;
$(window).scroll(function()
{
var scroH = $(this).scrollTop();
if(scroH>=fixH && first)
{
$(obj).parent().parent().before("<table id='headerClone' class='table'></table>");
$('#headerClone').append($(obj).clone()).addClass('affix');
$('.active-disabled ' + obj + ' th').each(function(i){$('#headerClone ' + obj + ' th').eq(i).width($(this).width())});
first = false;
}
else if(scroH<fixH)
{
$("#headerClone").remove();
first = true;
}
});
}
</script>
<?php include '../../common/view/footer.html.php';?>