From dcca3d0c04586f22a2630f29e7c881bca92edeca Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Sat, 26 Dec 2020 16:13:10 +0800 Subject: [PATCH] * Finish task#8751. Add batch unlink stakerholders. --- module/program/control.php | 49 +++++++++++++++++---- module/program/view/pgmstakeholder.html.php | 8 +++- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 0d99c08d21..51975b7c8c 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -503,6 +503,7 @@ class program extends control /** * Unlink program stakeholder. * + * @param int $stakeholderID * @param int $programID * @param string $confirm * @access public @@ -520,20 +521,50 @@ class program extends control $this->dao->delete()->from(TABLE_STAKEHOLDER)->where('id')->eq($stakeholderID)->exec(); $this->loadModel('user')->updateUserView($programID, 'program', array($account)); - - /* Update children user view. */ - $childPGMList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); - $childPRJList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('project')->fetchPairs(); - $childProducts = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs(); - - if(!empty($childPGMList)) $this->user->updateUserView($childPGMList, 'program', array($account)); - if(!empty($childPRJList)) $this->user->updateUserView($childPRJList, 'project', array($account)); - if(!empty($childProducts)) $this->user->updateUserView($childProducts, 'product', array($account)); + $this->updateChildUserView($programID, $account); die(js::reload('parent')); } } + /** + * Batch unlink program stakeholders. + * + * @param int $programID + * @access public + * @return void + */ + function batchUnlinkStakeholders($programID = 0) + { + $stakeholderIDList = $this->post->stakeholderIDList; + $account = $this->dao->select('user')->from(TABLE_STAKEHOLDER)->where('id')->in($stakeholderIDList)->fetchPairs('user'); + $this->dao->delete()->from(TABLE_STAKEHOLDER)->where('id')->in($stakeholderIDList)->exec(); + + $this->loadModel('user')->updateUserView($programID, 'program', $account); + $this->updateChildUserView($programID, $account); + + die(js::reload('parent')); + } + + /** + * Update children user view. + * + * @param int $programID + * @param array $account + * @access public + * @return void + */ + function updateChildUserView($programID = 0, $account = array()) + { + $childPGMList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childPRJList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('project')->fetchPairs(); + $childProducts = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs(); + + if(!empty($childPGMList)) $this->user->updateUserView($childPGMList, 'program', array($account)); + if(!empty($childPRJList)) $this->user->updateUserView($childPRJList, 'project', array($account)); + if(!empty($childProducts)) $this->user->updateUserView($childProducts, 'product', array($account)); + } + /** * Export program. * diff --git a/module/program/view/pgmstakeholder.html.php b/module/program/view/pgmstakeholder.html.php index b909f186f6..ef46a2a30b 100644 --- a/module/program/view/pgmstakeholder.html.php +++ b/module/program/view/pgmstakeholder.html.php @@ -27,8 +27,8 @@ - recTotal}&recPerPage={$pager->recPerPage}";?> @@ -45,6 +45,7 @@ key ? " " : '';?> @@ -68,6 +69,11 @@
+
idAB;?>
user->realname;?>
+ id => ''));?> id);?>