* finish task #2785.

This commit is contained in:
chenfeiCF
2016-11-24 17:28:53 +08:00
parent fcb0f2d969
commit f52c5ab5e3
6 changed files with 61 additions and 4 deletions
+16 -3
View File
@@ -202,10 +202,11 @@ class story extends control
*
* @param int $productID
* @param int $moduleID
* @param int $storyID
* @access public
* @return void
*/
public function batchCreate($productID = 0, $branch = 0, $moduleID = 0)
public function batchCreate($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0)
{
if(!empty($_POST))
{
@@ -213,6 +214,17 @@ class story extends control
if(dao::isError()) die(js::error(dao::getError()));
foreach($mails as $mail) $this->sendmail($mail->storyID, $mail->actionID);
/* If storyID not equal zero, subdivide this story to child stories and close it. */
if($storyID)
{
$actionID = $this->story->subdivide($storyID, $mails);
if(dao::isError()) die(js::error(dao::getError()));
$this->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate(inlink('view', "storyID=$storyID"), 'parent'));
}
die(js::locate($this->createLink('product', 'browse', "productID=$productID&branch=$branch"), 'parent'));
}
@@ -268,11 +280,12 @@ class story extends control
$this->view->customFields = $customFields;
$this->view->showFields = $showFields;
$this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchCreate;
$this->view->title = $product->name . $this->lang->colon . ($storyID ? $this->lang->story->subdivide : $this->lang->story->batchCreate);
$this->view->productName = $product->name;
$this->view->position[] = html::a($this->createLink('product', 'browse', "product=$productID&branch=$branch"), $product->name);
$this->view->position[] = $this->lang->story->common;
$this->view->position[] = $this->lang->story->batchCreate;
$this->view->position[] = $storyID ? $this->lang->story->subdivide : $this->lang->story->batchCreate;
$this->view->storyID = $storyID;
$this->view->products = $products;
$this->view->product = $product;
$this->view->moduleID = $moduleID;
+1
View File
@@ -17,6 +17,7 @@ $lang->story->review = 'Review';
$lang->story->batchReview = 'Batch Review';
$lang->story->edit = "Edit";
$lang->story->batchEdit = "Batch Edit";
$lang->story->subdivide = 'Subdivide';
$lang->story->close = 'Close';
$lang->story->batchClose = 'Batch Close';
$lang->story->activate = 'Activate';
+1
View File
@@ -17,6 +17,7 @@ $lang->story->review = '评审';
$lang->story->batchReview = '批量评审';
$lang->story->edit = "编辑";
$lang->story->batchEdit = "批量编辑";
$lang->story->subdivide = '细分';
$lang->story->close = '关闭';
$lang->story->batchClose = '批量关闭';
$lang->story->activate = '激活';
+34
View File
@@ -685,6 +685,40 @@ class storyModel extends model
return $actions;
}
public function subdivide($storyID, $stories)
{
$now = helper::now();
$oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
/* Set childStories. */
$childStories = '';
foreach($stories as $story) $childStories .= $story->storyID . ',';
$childStories = trim($childStories, ',');
$newStory = new stdClass();
$newStory->plan = 0;
$newStory->lastEditedBy = $this->app->user->account;
$newStory->lastEditedDate = $now;
$newStory->closedDate = $now;
$newStory->closedBy = $this->app->user->account;
$newStory->assignedTo = 'closed';
$newStory->assignedDate = $now;
$newStory->status = 'closed';
$newStory->closedReason = 'subdivided';
$newStory->childStories = $childStories;
/* Subdivide story and close it. */
$this->dao->update(TABLE_STORY)->data($newStory)
->autoCheck()
->batchCheck($this->config->story->close->requiredFields, 'notempty')
->where('id')->eq($storyID)->exec();
$changes = common::createChanges($oldStory, $newStory);
$actionID = $this->action->create('story', $storyID, 'Closed', '', 'Subdivided');
$this->action->logHistory($actionID, $changes);
return $actionID;
}
/**
* Close a story.
*
+1 -1
View File
@@ -16,7 +16,7 @@
<span class='prefix'><?php echo html::icon($lang->icons['story']);?></span>
<strong>
<small class='text-muted'><?php echo html::icon($lang->icons['batchCreate']);?></small>
<?php echo $lang->story->batchCreate;?>
<?php echo $storyID ? $lang->story->subdivide : $lang->story->batchCreate;?>
<?php if($product->type !== 'normal') echo '<span class="label label-info">' . $branches[$branch] . '</span>';?>
</strong>
<div class='actions'>
+8
View File
@@ -43,6 +43,14 @@
echo "<div class='btn-group'>";
common::printIcon('story', 'change', "storyID=$story->id", $story);
common::printIcon('story', 'review', "storyID=$story->id", $story);
if($story->status != 'closed')
{
$misc = common::hasPriv('story', 'batchCreate') ? "class='btn' data-toggle='modal' data-type='iframe' data-width='95%'" : "class='disabled'";
$link = common::hasPriv('story', 'batchCreate') ? $this->createLink('story', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id", '', true) : '#';
echo html::a($link, "<i class='icon icon-node'></i> " . $lang->story->subdivide, '', $misc);
}
common::printIcon('story', 'close', "storyID=$story->id", $story, 'button', '', '', 'iframe text-danger', true);
common::printIcon('story', 'activate', "storyID=$story->id", $story, 'button', '', '', 'iframe text-success', true);