From 506aaa3d741ac578e0eab12bc786a8172867c99c Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 6 Aug 2019 18:05:31 +0800 Subject: [PATCH] * Change sub status when status is changed and sub status is not set, and record the changes. --- module/common/model.php | 21 +++++++++++++++------ module/product/view/edit.html.php | 2 +- module/story/control.php | 29 ++++++++++++++++++++--------- module/story/model.php | 6 ++++-- module/testcase/control.php | 11 ++++++++--- module/testcase/model.php | 11 ++++++++--- 6 files changed, 56 insertions(+), 24 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index de2fab9091..f4690ddb5e 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1085,23 +1085,32 @@ EOD; global $app, $config; /** - * 当主状态改变并且未设置子状态的值时把子状态的值置空并记录日志。 + * 当主状态改变并且未设置子状态的值时把子状态的值设置为默认值并记录日志。 * Change sub status when status is changed and sub status is not set, and record the changes. */ if(isset($config->bizVersion)) { $oldID = zget($old, 'id', ''); $oldStatus = zget($old, 'status', ''); - $oldSubStatus = zget($old, 'subStatus', ''); $newStatus = zget($new, 'status', ''); $newSubStatus = zget($new, 'subStatus', ''); - if($oldID && $oldStatus && $oldSubStatus && $newStatus && !$newSubStatus && $oldStatus != $newStatus) + if($oldID && $oldStatus && $newStatus && !$newSubStatus && $oldStatus != $newStatus) { - $table = zget($config->objectTables, $app->getModuleName()); - $app->dbh->exec("UPDATE $table SET `subStatus` = '' WHERE `id` = $oldID"); + $moduleName = $app->getModuleName(); - $new->subStatus = ''; + $field = $app->dbh->query('SELECT options FROM ' . TABLE_WORKFLOWFIELD . " WHERE `module` = '$moduleName' AND `field` = 'subStatus'")->fetch(); + if(!empty($field->options)) $field->options = json_decode($field->options, true); + + if(!empty($field->options[$newStatus]['default'])) + { + $flow = $app->dbh->query('SELECT `table` FROM ' . TABLE_WORKFLOW . " WHERE `module`='$moduleName'")->fetch(); + $default = $field->options[$newStatus]['default']; + + $app->dbh->exec("UPDATE `$flow->table` SET `subStatus` = '$default' WHERE `id` = '$oldID'"); + + $new->subStatus = $default; + } } } diff --git a/module/product/view/edit.html.php b/module/product/view/edit.html.php index c5dd629798..b8a6b4d35c 100644 --- a/module/product/view/edit.html.php +++ b/module/product/view/edit.html.php @@ -62,7 +62,7 @@ product->desc;?> desc), "rows='8' class='form-control'");?> - printExtendFields($product, 'table', 'columns=2');?> + printExtendFields($product, 'table', 'columns=1');?> product->acl;?> product->aclList, $product->acl, "onclick='setWhite(this.value);'", 'block'));?> diff --git a/module/story/control.php b/module/story/control.php index 5cc915f284..a0ced2d673 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -653,9 +653,14 @@ class story extends control { if(!empty($_POST)) { - $this->story->activate($storyID); + $changes = $this->story->activate($storyID); if(dao::isError()) die(js::error(dao::getError())); - $actionID = $this->action->create('story', $storyID, 'Activated', $this->post->comment); + + if($changes) + { + $actionID = $this->action->create('story', $storyID, 'Activated', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } $this->executeHooks($storyID); @@ -769,13 +774,15 @@ class story extends control { if(!empty($_POST)) { - $this->story->review($storyID); + $changes = $this->story->review($storyID); if(dao::isError()) die(js::error(dao::getError())); - $result = $this->post->result; - $actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result)); - if($this->post->result == 'reject') + + if($changes) { - $this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason)); + $result = $this->post->result; + $actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result)); + if($result == 'reject') $actionID = $this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason)); + $this->action->logHistory($actionID, $changes); } $this->executeHooks($storyID); @@ -846,8 +853,12 @@ class story extends control { $changes = $this->story->close($storyID); if(dao::isError()) die(js::error(dao::getError())); - $actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : '')); - $this->action->logHistory($actionID, $changes); + + if($changes) + { + $actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : '')); + $this->action->logHistory($actionID, $changes); + } $this->executeHooks($storyID); diff --git a/module/story/model.php b/module/story/model.php index fc077f8238..35bb341d62 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -749,7 +749,8 @@ class storyModel extends model $this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->eq($storyID)->andWhere('extra')->eq($oldStory->version)->exec(); } if($this->post->result != 'reject') $this->setStage($storyID); - return true; + + return common::createChanges($oldStory, $story); } /** @@ -1163,7 +1164,8 @@ class storyModel extends model ->get(); $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec(); $this->setStage($storyID); - return true; + + return common::createChanges($oldStory, $story); } /** diff --git a/module/testcase/control.php b/module/testcase/control.php index 2c825205d0..62438778e3 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -776,10 +776,15 @@ class testcase extends control { if($_POST) { - $this->testcase->review($caseID); + $changes = $this->testcase->review($caseID); if(dao::isError()) die(js::error(dao::getError())); - $result = $this->post->result; - $this->loadModel('action')->create('case', $caseID, 'Reviewed', $this->post->comment, ucfirst($result)); + + if($changes) + { + $result = $this->post->result; + $actionID = $this->loadModel('action')->create('case', $caseID, 'Reviewed', $this->post->comment, ucfirst($result)); + $this->action->logHistory($actionID, $changes); + } $this->executeHooks($caseID); diff --git a/module/testcase/model.php b/module/testcase/model.php index 2fd95369eb..9c32697450 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -721,11 +721,13 @@ class testcaseModel extends model * * @param int $caseID * @access public - * @return bool + * @return bool | array */ public function review($caseID) { - if($this->post->result == false) die(js::alert($this->lang->testcase->mustChooseResult)); + if($this->post->result == false) die(js::alert($this->lang->testcase->mustChooseResult)); + + $oldCase = $this->getById($caseID); $now = helper::now(); $status = $this->getStatus('review', $caseID); @@ -739,7 +741,10 @@ class testcaseModel extends model ->get(); $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq($caseID)->exec(); - return true; + + if(dao::isError()) return false; + + return common::createChanges($oldCase, $case); } /**