From 30204c15685cb2ed2658827171feb06c30b728bf Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 17 Nov 2021 14:39:37 +0800 Subject: [PATCH] * Finish task #44369. --- module/bug/control.php | 27 +++++++++++++++ module/bug/model.php | 29 ++++++++++++++++ module/productplan/control.php | 4 +-- module/productplan/view/view.html.php | 49 ++++++++++++++++++++++++--- 4 files changed, 103 insertions(+), 6 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index e53565f090..7da6bcdd66 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1168,6 +1168,33 @@ class bug extends control die(js::locate($this->session->bugList, 'parent')); } + /** + * Batch change the plan of bug. + * + * @param int $planID + * @access public + * @return void + */ + public function batchChangePlan($planID) + { + if($this->post->bugIDList) + { + $bugIDList = $this->post->bugIDList; + $bugIDList = array_unique($bugIDList); + unset($_POST['bugIDList']); + $allChanges = $this->bug->batchChangePlan($bugIDList, $planID); + if(dao::isError()) die(js::error(dao::getError())); + foreach($allChanges as $bugID => $changes) + { + $this->loadModel('action'); + $actionID = $this->action->create('bug', $bugID, 'Edited'); + $this->action->logHistory($actionID, $changes); + } + } + $this->loadModel('score')->create('ajax', 'batchOther'); + die(js::locate($this->session->bugList, 'parent')); + } + /** * Batch update assign of bug. * diff --git a/module/bug/model.php b/module/bug/model.php index 8cfa5e97a6..99be798c96 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1093,6 +1093,35 @@ class bugModel extends model return $allChanges; } + /** + * Batch change the plan of bug. + * + * @param array $bugIDList + * @param int $planID + * @access public + * @return array + */ + public function batchChangePlan($bugIDList, $planID) + { + $now = helper::now(); + $allChanges = array(); + $oldBugs = $this->getByList($bugIDList); + foreach($bugIDList as $bugID) + { + $oldBug = $oldBugs[$bugID]; + if($planID == $oldBug->plan) continue; + + $bug = new stdclass(); + $bug->lastEditedBy = $this->app->user->account; + $bug->lastEditedDate = $now; + $bug->plan = $planID; + + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec(); + if(!dao::isError()) $allChanges[$bugID] = common::createChanges($oldBug, $bug); + } + return $allChanges; + } + /** * Batch resolve bugs. * diff --git a/module/productplan/control.php b/module/productplan/control.php index 56b6ab3845..f8119b9301 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -313,7 +313,7 @@ class productplan extends control $this->view->canBeChanged = $canBeChanged; if($this->app->getViewType() == 'json') - { + { unset($this->view->storyPager); unset($this->view->bugPager); } @@ -629,7 +629,7 @@ class productplan extends control */ public function batchUnlinkBug($planID, $orderBy = 'id_desc') { - foreach($this->post->unlinkBugs as $bugID) $this->productplan->unlinkBug($bugID); + foreach($this->post->bugIDList as $bugID) $this->productplan->unlinkBug($bugID); die(js::locate($this->createLink('productplan', 'view', "planID=$planID&type=bug&orderBy=$orderBy"), 'parent')); } } diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index 10e407a608..c4c97f4e54 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -361,7 +361,12 @@
id&orderBy=$orderBy");?>"> - + id}&type=bug&orderBy=%s&link=$link¶m=$param"; ?> @@ -386,7 +391,7 @@
- id => sprintf('%03d', $bug->id)));?> + id => sprintf('%03d', $bug->id)));?> id);?> @@ -415,10 +420,46 @@