diff --git a/module/my/js/common.js b/module/my/js/common.js index 3ef321529c..09fc83f01a 100644 --- a/module/my/js/common.js +++ b/module/my/js/common.js @@ -6,6 +6,6 @@ $(function() function changeAction(formName, actionName, actionLink) { - if(actionName == 'batchClose') $('#' + formName).attr('target', 'hiddenwin'); + if(formName =='myTaskForm' && actionName == 'batchClose') $('#' + formName).attr('target', 'hiddenwin'); $('#' + formName).attr('action', actionLink).submit(); } diff --git a/module/product/view/storylist.html.php b/module/product/view/storylist.html.php index a7776ce062..446b429980 100644 --- a/module/product/view/storylist.html.php +++ b/module/product/view/storylist.html.php @@ -71,7 +71,7 @@ } if($canBatchClose) { - $actionLink = $this->createLink('story', 'batchClose', "from=productBrowse&productID=$productID&projectID=0&orderBy=$orderBy"); + $actionLink = $this->createLink('story', 'batchClose', "productID=$productID&projectID=0"); echo html::commonButton($lang->close, "onclick=\"changeAction('productStoryForm', 'batchClose', '$actionLink')\""); } } diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index 2e2fed21fb..6ad18f4758 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -106,7 +106,7 @@ } if($canBatchClose) { - $actionLink = $this->createLink('story', 'batchClose', "from=projectStory&productID=0&projectID=$project->id&orderBy=$orderBy"); + $actionLink = $this->createLink('story', 'batchClose', "productID=0&projectID=$project->id"); echo html::commonButton($lang->close, "onclick=\"changeAction('projectStoryForm', 'batchClose', '$actionLink')\""); } } diff --git a/module/story/config.php b/module/story/config.php index 1c503750a7..5c7bd276b7 100644 --- a/module/story/config.php +++ b/module/story/config.php @@ -7,6 +7,9 @@ $config->story->affectedFixedNum = 7; $config->story->batchEdit = new stdclass(); $config->story->batchEdit->columns = 10; +$config->story->batchClose = new stdclass(); +$config->story->batchClose->columns = 10; + $config->story->create = new stdclass(); $config->story->edit = new stdclass(); $config->story->change = new stdclass(); diff --git a/module/story/control.php b/module/story/control.php index 331d0f8c25..4c178e30f5 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -319,7 +319,7 @@ class story extends control $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($storyIDList)->fetchAll('id'); /* The stories of a product. */ - if($productID and !$projectID) + if($productID) { $this->product->setMenu($this->product->getPairs('nodeleted'), $productID); $product = $this->product->getByID($productID); @@ -327,7 +327,7 @@ class story extends control } /* The stories of a project. */ - elseif($productID and $projectID) + elseif($projectID) { $this->lang->story->menu = $this->lang->project->menu; $this->project->setMenu($this->project->getPairs('nodeleted'), $projectID); @@ -337,7 +337,7 @@ class story extends control $this->view->title = $project->name . $this->lang->colon . $this->lang->story->batchEdit; } /* The stories of my. */ - elseif(!$productID and !$projectID) + else { $this->lang->story->menu = $this->lang->my->menu; $this->lang->set('menugroup.story', 'my'); @@ -612,91 +612,76 @@ class story extends control /** * Batch close story. * - * @param string $from productBrowse|projectStory|storyBatchClose * @param int $productID * @param int $projectID - * @param string $orderBy * @access public * @return void */ - public function batchClose($from = '', $productID = 0, $projectID = 0, $orderBy = '') + public function batchClose($productID = 0, $projectID = 0) { - /* Get post data for product-Browse or project-Story. */ - if($from == 'productBrowse' or $from == 'projectStory') + if($this->post->closedReasons) { - /* Init vars. */ - $editedStories = array(); - $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : array(); - $columns = 4; - $showSuhosinInfo = false; + $allChanges = $this->story->batchClose(); - /* Get all stories. */ - if(!$projectID) + if($allChanges) { - /* Set menu. */ - $this->product->setMenu($this->product->getPairs('nodeleted'), $productID); - $allStories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->orderBy($orderBy)->fetchAll('id'); - } - else - { - $this->lang->story->menu = $this->lang->project->menu; - $this->lang->story->menuOrder = $this->lang->project->menuOrder; - $this->project->setMenu($this->project->getPairs('nodeleted'), $projectID); - $this->lang->set('menugroup.story', 'project'); - $allStories = $this->story->getProjectStories($projectID, $orderBy); - } - if(!$allStories) $allStories = array(); - - /* Initialize the stories whose need to edited. */ - foreach($allStories as $story) if(in_array($story->id, $storyIDList)) $editedStories[$story->id] = $story; - - /* Judge whether the editedStories is too large. */ - $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedStories), $columns); - - /* Set the sessions. */ - $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); - - /* Assign. */ - if(!$projectID) - { - $product = $this->product->getByID($productID); - $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchClose; - } - else - { - $project = $this->project->getByID($projectID); - $this->view->title = $project->name . $this->lang->colon . $this->lang->story->batchClose; - } - if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; - $this->view->position[] = $this->lang->story->common; - $this->view->position[] = $this->lang->story->batchClose; - $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story'); - $this->view->plans = $this->loadModel('productplan')->getPairs($productID); - $this->view->productID = $productID; - $this->view->editedStories = $editedStories; - - $this->display(); - } - /* Get post data for story-batchClose. */ - elseif($from == 'storyBatchClose') - { - if(!empty($_POST)) - { - - $allChanges = $this->story->batchClose(); - - if($allChanges) + foreach($allChanges as $storyID => $changes) { - foreach($allChanges as $storyID => $changes) - { - $actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comments[$storyID], ucfirst($this->post->closedReasons[$storyID])); - $this->action->logHistory($actionID); - $this->sendMail($storyID, $actionID); - } + $actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comments[$storyID], ucfirst($this->post->closedReasons[$storyID])); + $this->action->logHistory($actionID); + $this->sendMail($storyID, $actionID); } } die(js::locate($this->session->storyList, 'parent')); } + + $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent')); + + /* Get edited stories. */ + $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($storyIDList)->fetchAll('id'); + + /* The stories of a product. */ + if($productID) + { + $this->product->setMenu($this->product->getPairs('nodeleted'), $productID); + $product = $this->product->getByID($productID); + $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchClose; + } + /* The stories of a project. */ + elseif($projectID) + { + $this->lang->story->menu = $this->lang->project->menu; + $this->lang->story->menuOrder = $this->lang->project->menuOrder; + $this->project->setMenu($this->project->getPairs('nodeleted'), $projectID); + $this->lang->set('menugroup.story', 'project'); + $project = $this->project->getByID($projectID); + $this->view->title = $project->name . $this->lang->colon . $this->lang->story->batchClose; + } + /* The stories of my. */ + else + { + $this->lang->story->menu = $this->lang->my->menu; + $this->lang->set('menugroup.story', 'my'); + $this->lang->story->menuOrder = $this->lang->my->menuOrder; + $this->loadModel('my')->setMenu(); + $this->view->title = $this->lang->story->batchEdit; + } + + /* Judge whether the editedStories is too large and set session. */ + $showSuhosinInfo = false; + $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($stories), $this->config->story->batchClose->columns); + $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); + if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; + + $this->view->position[] = $this->lang->story->common; + $this->view->position[] = $this->lang->story->batchClose; + $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story'); + $this->view->plans = $this->loadModel('productplan')->getPairs($productID); + $this->view->productID = $productID; + $this->view->stories = $stories; + $this->view->storyIDList = $storyIDList; + + $this->display(); } /** diff --git a/module/story/view/batchclose.html.php b/module/story/view/batchclose.html.php index 4da433d750..4888406f69 100755 --- a/module/story/view/batchclose.html.php +++ b/module/story/view/batchclose.html.php @@ -22,37 +22,37 @@ story->closedReason;?> story->comment;?> - + - id . html::hidden("storyIDList[$story->id]", $story->id);?> - title;?> - story->statusList[$story->status];?> + + title;?> + story->statusList[$stories[$storyID]->status];?> - status != 'closed'):?> + status != 'closed'):?>
status == 'draft') unset($this->lang->story->reasonList['cancel']); - echo html::select("closedReasons[$story->id]", $lang->story->reasonList, 'done', "class=w-70px onchange=setDuplicateAndChild(this.value,$story->id)"); + if($stories[$storyID]->status == 'draft') unset($this->lang->story->reasonList['cancel']); + echo html::select("closedReasons[$storyID]", $lang->story->reasonList, 'done', "class=w-70px onchange=setDuplicateAndChild(this.value,$storyID)"); ?>
-
id;?>' closedReason != 'duplicate') echo "style='display:none'";?>> - id]", '', "class=w-30px placeholder='{$lang->idAB}'");?> +
' closedReason != 'duplicate') echo "style='display:none'";?>> + idAB}'");?>
-
id;?>' closedReason != 'subdivided') echo "style='display:none'";?>> - id]", '', "class=w-30px placeholder='{$lang->idAB}'");?> +
' closedReason != 'subdivided') echo "style='display:none'";?>> + idAB}'");?>
- id]", $lang->story->reasonList, $story->closedReason, 'class="w-70px" disabled="disabled"');?> + story->reasonList, $stories[$storyID]->closedReason, 'class="w-70px" disabled="disabled"');?>
- id]", '', "class='area-1'");?> +