* adjust for batch create.
This commit is contained in:
+24
-16
@@ -111,15 +111,6 @@ class bugModel extends model
|
||||
$result = $this->loadModel('common')->removeDuplicate('bug', $data, "product={$productID}");
|
||||
$data = $result['data'];
|
||||
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
if(!empty($data->title[$i]))
|
||||
{
|
||||
if(empty($data->modules[$i])) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->bug->module)));
|
||||
if(empty($data->openedBuilds[$i])) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->bug->openedBuild)));
|
||||
}
|
||||
}
|
||||
|
||||
/* Get pairs(moduleID => moduleOwner) for bug. */
|
||||
$stmt = $this->dbh->query($this->loadModel('tree')->buildMenuQuery($productID, 'bug', $startModuleID = 0, $branch));
|
||||
$moduleOwners = array();
|
||||
@@ -149,6 +140,7 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
if(isset($data->uploadImage)) $this->loadModel('file');
|
||||
$bugs = array();
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
if(empty($data->title[$i])) continue;
|
||||
@@ -172,6 +164,23 @@ class bugModel extends model
|
||||
$bug->browser = $data->browsers[$i];
|
||||
$bug->keywords = $data->keywords[$i];
|
||||
|
||||
if(!empty($moduleOwners[$bug->module]))
|
||||
{
|
||||
$bug->assignedTo = $moduleOwners[$bug->module];
|
||||
$bug->assignedDate = $now;
|
||||
}
|
||||
|
||||
foreach(explode(',', $this->config->bug->create->requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
if($field and empty($bug->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->bug->$field)));
|
||||
}
|
||||
|
||||
$bugs[$i] = $bug;
|
||||
}
|
||||
|
||||
foreach($bugs as $i => $bug)
|
||||
{
|
||||
if(!empty($data->uploadImage[$i]))
|
||||
{
|
||||
$fileName = $data->uploadImage[$i];
|
||||
@@ -197,15 +206,14 @@ class bugModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($moduleOwners[$bug->module]))
|
||||
{
|
||||
$bug->assignedTo = $moduleOwners[$bug->module];
|
||||
$bug->assignedDate = $now;
|
||||
}
|
||||
$this->dao->insert(TABLE_BUG)->data($bug)
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->bug->create->requiredFields, 'notempty')
|
||||
->exec();
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
$this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
|
||||
$bugID = $this->dao->lastInsertID();
|
||||
if(!dao::isError()) $this->loadModel('score')->create('bug', 'create', $bugID);
|
||||
$this->loadModel('score')->create('bug', 'create', $bugID);
|
||||
if(!empty($data->uploadImage[$i]) and !empty($file))
|
||||
{
|
||||
$file['objectType'] = 'bug';
|
||||
|
||||
@@ -30,8 +30,8 @@ $config->custom->requiredModules[85] = 'user';
|
||||
|
||||
$config->custom->fieldList['product']['create'] = 'name,code,line,PO,QD,RD,type,desc';
|
||||
$config->custom->fieldList['product']['edit'] = 'name,code,line,PO,QD,RD,type,desc,status';
|
||||
$config->custom->fieldList['story']['create'] = 'module,plan,source,title,pri,estimate,keywords,spec,verify';
|
||||
$config->custom->fieldList['story']['change'] = 'title,spec,verify,comment';
|
||||
$config->custom->fieldList['story']['create'] = 'module,plan,source,title,pri,estimate,keywords';
|
||||
$config->custom->fieldList['story']['change'] = 'title,comment';
|
||||
$config->custom->fieldList['story']['close'] = 'closedReason,comment';
|
||||
$config->custom->fieldList['story']['review'] = 'reviewedDate,assignedTo,reviewedBy,comment';
|
||||
$config->custom->fieldList['productplan'] = 'title,begin,end,desc';
|
||||
|
||||
+78
-68
@@ -277,84 +277,94 @@ class storyModel extends model
|
||||
if(isset($stories->uploadImage)) $this->loadModel('file');
|
||||
|
||||
$forceReview = $this->checkForceReview();
|
||||
$data = array();
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
if(!empty($stories->title[$i]))
|
||||
if(empty($stories->title[$i])) continue;
|
||||
$story = new stdclass();
|
||||
$story->branch = $stories->branch[$i];
|
||||
$story->module = $stories->module[$i];
|
||||
$story->plan = $stories->plan[$i];
|
||||
$story->color = $stories->color[$i];
|
||||
$story->title = $stories->title[$i];
|
||||
$story->source = $stories->source[$i];
|
||||
$story->pri = $stories->pri[$i];
|
||||
$story->estimate = $stories->estimate[$i];
|
||||
$story->status = ($stories->needReview[$i] == 0 and !$forceReview) ? 'active' : 'draft';
|
||||
$story->keywords = $stories->keywords[$i];
|
||||
$story->product = $productID;
|
||||
$story->openedBy = $this->app->user->account;
|
||||
$story->openedDate = $now;
|
||||
$story->version = 1;
|
||||
|
||||
foreach(explode(',', $this->config->story->create->requiredFields) as $field)
|
||||
{
|
||||
$data = new stdclass();
|
||||
$data->branch = $stories->branch[$i];
|
||||
$data->module = $stories->module[$i];
|
||||
$data->plan = $stories->plan[$i];
|
||||
$data->color = $stories->color[$i];
|
||||
$data->title = $stories->title[$i];
|
||||
$data->source = $stories->source[$i];
|
||||
$data->pri = $stories->pri[$i];
|
||||
$data->estimate = $stories->estimate[$i];
|
||||
$data->status = ($stories->needReview[$i] == 0 and !$forceReview) ? 'active' : 'draft';
|
||||
$data->keywords = $stories->keywords[$i];
|
||||
$data->product = $productID;
|
||||
$data->openedBy = $this->app->user->account;
|
||||
$data->openedDate = $now;
|
||||
$data->version = 1;
|
||||
$field = trim($field);
|
||||
if($field and empty($story->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->story->$field)));
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_STORY)->data($data)->autoCheck()
|
||||
->batchCheck($this->config->story->create->requiredFields, 'notempty')
|
||||
->exec();
|
||||
if(dao::isError())
|
||||
$data[$i] = $story;
|
||||
}
|
||||
|
||||
foreach($data as $i => $story)
|
||||
{
|
||||
$this->dao->insert(TABLE_STORY)->data($story)->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();
|
||||
$this->setStage($storyID);
|
||||
|
||||
$specData = new stdclass();
|
||||
$specData->story = $storyID;
|
||||
$specData->version = 1;
|
||||
$specData->title = $stories->title[$i];
|
||||
$specData->spec = '';
|
||||
$specData->verify = '';
|
||||
if(!empty($stories->spec[$i])) $specData->spec = nl2br($stories->spec[$i]);
|
||||
if(!empty($stories->verify[$i]))$specData->verify = nl2br($stories->verify[$i]);
|
||||
|
||||
if(!empty($stories->uploadImage[$i]))
|
||||
{
|
||||
$fileName = $stories->uploadImage[$i];
|
||||
$file = $this->session->storyImagesFile[$fileName];
|
||||
|
||||
$realPath = $file['realpath'];
|
||||
unset($file['realpath']);
|
||||
|
||||
if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname'])))
|
||||
{
|
||||
echo js::error(dao::getError());
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
|
||||
$storyID = $this->dao->lastInsertID();
|
||||
$this->setStage($storyID);
|
||||
|
||||
$specData = new stdclass();
|
||||
$specData->story = $storyID;
|
||||
$specData->version = 1;
|
||||
$specData->title = $stories->title[$i];
|
||||
$specData->spec = '';
|
||||
$specData->verify = '';
|
||||
if(!empty($stories->spec[$i])) $specData->spec = nl2br($stories->spec[$i]);
|
||||
if(!empty($stories->verify[$i]))$specData->verify = nl2br($stories->verify[$i]);
|
||||
|
||||
if(!empty($stories->uploadImage[$i]))
|
||||
{
|
||||
$fileName = $stories->uploadImage[$i];
|
||||
$file = $this->session->storyImagesFile[$fileName];
|
||||
|
||||
$realPath = $file['realpath'];
|
||||
unset($file['realpath']);
|
||||
|
||||
if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname'])))
|
||||
$file['addedBy'] = $this->app->user->account;
|
||||
$file['addedDate'] = $now;
|
||||
$file['objectType'] = 'story';
|
||||
$file['objectID'] = $storyID;
|
||||
if(in_array($file['extension'], $this->config->file->imageExtensions))
|
||||
{
|
||||
$file['addedBy'] = $this->app->user->account;
|
||||
$file['addedDate'] = $now;
|
||||
$file['objectType'] = 'story';
|
||||
$file['objectID'] = $storyID;
|
||||
if(in_array($file['extension'], $this->config->file->imageExtensions))
|
||||
{
|
||||
$file['extra'] = 'editor';
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
$file['extra'] = 'editor';
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
$fileID = $this->dao->lastInsertID();
|
||||
$specData->spec .= '<img src="{' . $fileID . '.' . $file['extension'] . '}" alt="" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
}
|
||||
$fileID = $this->dao->lastInsertID();
|
||||
$specData->spec .= '<img src="{' . $fileID . '.' . $file['extension'] . '}" alt="" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_STORYSPEC)->data($specData)->exec();
|
||||
|
||||
$actionID = $this->action->create('story', $storyID, 'Opened', '');
|
||||
if(!dao::isError()) $this->loadModel('score')->create('story', 'create',$storyID);
|
||||
$mails[$i] = new stdclass();
|
||||
$mails[$i]->storyID = $storyID;
|
||||
$mails[$i]->actionID = $actionID;
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_STORYSPEC)->data($specData)->exec();
|
||||
|
||||
$actionID = $this->action->create('story', $storyID, 'Opened', '');
|
||||
if(!dao::isError()) $this->loadModel('score')->create('story', 'create',$storyID);
|
||||
$mails[$i] = new stdclass();
|
||||
$mails[$i]->storyID = $storyID;
|
||||
$mails[$i]->actionID = $actionID;
|
||||
}
|
||||
|
||||
/* Remove upload image file and session. */
|
||||
|
||||
+19
-11
@@ -180,21 +180,14 @@ class taskModel extends model
|
||||
$result = $this->loadModel('common')->removeDuplicate('task', $tasks, "project=$projectID and story " . helper::dbIN($storyIDs));
|
||||
$tasks = $result['data'];
|
||||
|
||||
/* check estimate. */
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
if(!empty($tasks->name[$i]) and $tasks->estimate[$i] and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $tasks->estimate[$i]))
|
||||
{
|
||||
die(js::alert($this->lang->task->error->estimateNumber));
|
||||
}
|
||||
if(!empty($tasks->name[$i]) and empty($tasks->type[$i])) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->task->type)));
|
||||
}
|
||||
|
||||
$story = 0;
|
||||
$module = 0;
|
||||
$type = '';
|
||||
$assignedTo = '';
|
||||
|
||||
/* Get task data. */
|
||||
$data = array();
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
$story = !isset($tasks->story[$i]) || $tasks->story[$i] == 'ditto' ? $story : $tasks->story[$i];
|
||||
@@ -226,11 +219,26 @@ class taskModel extends model
|
||||
if($assignedTo) $data[$i]->assignedDate = $now;
|
||||
if(strpos($this->config->task->create->requiredFields, 'estStarted') !== false and empty($tasks->estStarted[$i])) $data[$i]->estStarted = '';
|
||||
if(strpos($this->config->task->create->requiredFields, 'deadline') !== false and empty($tasks->deadline[$i])) $data[$i]->deadline = '';
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_TASK)->data($data[$i])
|
||||
/* check data. */
|
||||
foreach($data as $i => $task)
|
||||
{
|
||||
if($task->estimate and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $task->estimate)) die(js::alert($this->lang->task->error->estimateNumber));
|
||||
foreach(explode(',', $this->config->task->create->requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
if($field and empty($task->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->task->$field)));
|
||||
}
|
||||
if($task->estimate) $task->estimate = (float)$task->estimate;
|
||||
}
|
||||
|
||||
foreach($data as $i => $task)
|
||||
{
|
||||
$this->dao->insert(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->task->create->requiredFields, 'notempty')
|
||||
->checkIF($data[$i]->estimate != '', 'estimate', 'float')
|
||||
->checkIF($task->estimate != '', 'estimate', 'float')
|
||||
->exec();
|
||||
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
+49
-51
@@ -167,64 +167,62 @@ class testcaseModel extends model
|
||||
}
|
||||
|
||||
$this->loadModel('story');
|
||||
$storyVersions = array();
|
||||
$forceNotReview = $this->forceNotReview();
|
||||
$storyVersions = array();
|
||||
$forceNotReview = $this->forceNotReview();
|
||||
$data = array();
|
||||
for($i = 0; $i < $batchNum; $i++)
|
||||
{
|
||||
if($cases->type[$i] != '' and $cases->title[$i] != '')
|
||||
if(empty($cases->title[$i])) continue;
|
||||
|
||||
$data[$i] = new stdclass();
|
||||
$data[$i]->product = $productID;
|
||||
$data[$i]->branch = $cases->branch[$i];
|
||||
$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]->story = $storyID ? $storyID : $cases->story[$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 = $forceNotReview || $cases->needReview[$i] == 0 ? 'normal' : 'wait';
|
||||
$data[$i]->version = 1;
|
||||
|
||||
$caseStory = $data[$i]->story;
|
||||
$data[$i]->storyVersion = isset($storyVersions[$caseStory]) ? $storyVersions[$caseStory] : 0;
|
||||
if($caseStory and !isset($storyVersions[$caseStory]))
|
||||
{
|
||||
$data[$i] = new stdclass();
|
||||
$data[$i]->product = $productID;
|
||||
$data[$i]->branch = $cases->branch[$i];
|
||||
$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]->story = $storyID ? $storyID : $cases->story[$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 = $forceNotReview || $cases->needReview[$i] == 0 ? 'normal' : 'wait';
|
||||
$data[$i]->version = 1;
|
||||
|
||||
$caseStory = $data[$i]->story;
|
||||
$data[$i]->storyVersion = isset($storyVersions[$caseStory]) ? $storyVersions[$caseStory] : 0;
|
||||
if($caseStory and !isset($storyVersions[$caseStory]))
|
||||
{
|
||||
$data[$i]->storyVersion = $this->story->getVersion($caseStory);
|
||||
$storyVersions[$caseStory] = $data[$i]->storyVersion;
|
||||
}
|
||||
|
||||
$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();
|
||||
$this->loadModel('score')->create('testcase', 'create', $caseID);
|
||||
$actionID = $this->loadModel('action')->create('case', $caseID, 'Opened');
|
||||
$data[$i]->storyVersion = $this->story->getVersion($caseStory);
|
||||
$storyVersions[$caseStory] = $data[$i]->storyVersion;
|
||||
}
|
||||
else
|
||||
|
||||
foreach(explode(',', $this->config->testcase->create->requiredFields) as $field)
|
||||
{
|
||||
unset($cases->module[$i]);
|
||||
unset($cases->type[$i]);
|
||||
unset($cases->pri[$i]);
|
||||
unset($cases->story[$i]);
|
||||
unset($cases->title[$i]);
|
||||
unset($cases->stage[$i]);
|
||||
unset($cases->precondition[$i]);
|
||||
unset($cases->keywords[$i]);
|
||||
$field = trim($field);
|
||||
if($field and empty($data[$i]->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->$field)));
|
||||
}
|
||||
}
|
||||
|
||||
foreach($data as $i => $case)
|
||||
{
|
||||
$this->dao->insert(TABLE_CASE)->data($case)
|
||||
->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();
|
||||
$this->loadModel('score')->create('testcase', 'create', $caseID);
|
||||
$actionID = $this->loadModel('action')->create('case', $caseID, 'Opened');
|
||||
}
|
||||
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchCreate');
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ foreach(explode(',', $this->config->testcase->create->requiredFields) as $field)
|
||||
if($field)
|
||||
{
|
||||
$requiredFields[$field] = '';
|
||||
if(strpos(",{$config->bug->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = '';
|
||||
if(strpos(",{$config->testcase->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = '';
|
||||
}
|
||||
}
|
||||
$colspan = count($visibleFields) + 3;
|
||||
|
||||
@@ -36,7 +36,7 @@ foreach(explode(',', $this->config->testcase->edit->requiredFields) as $field)
|
||||
if($field)
|
||||
{
|
||||
$requiredFields[$field] = '';
|
||||
if(strpos(",{$config->bug->customBatchEditFields},", ",{$field},") !== false) $visibleFields[$field] = '';
|
||||
if(strpos(",{$config->testcase->customBatchEditFields},", ",{$field},") !== false) $visibleFields[$field] = '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user