* Finish task#8751. Add batch unlink stakerholders.

This commit is contained in:
qiyu-xie
2020-12-26 16:13:10 +08:00
parent 33e2b79be2
commit dcca3d0c04
2 changed files with 47 additions and 10 deletions
+40 -9
View File
@@ -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.
*
+7 -1
View File
@@ -27,8 +27,8 @@
<table class='table has-sort-head' id='userList'>
<thead>
<tr>
<?php $vars = "programID=$programID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
<th class='c-id'>
<div class='checkbox-primary check-all' title="<?php echo $this->lang->selectAll;?>"><label></label></div>
<?php echo $lang->idAB;?>
</th>
<th><?php echo $lang->user->realname;?></th>
@@ -45,6 +45,7 @@
<?php foreach($stakeholders as $stakeholder):?>
<tr>
<td class='c-id'>
<?php echo html::checkbox('stakeholderIDList', array($stakeholder->id => ''));?>
<?php printf('%03d', $stakeholder->id);?>
</td>
<?php $isKey = $stakeholder->key ? " <i class='icon icon-star-empty'></i>" : '';?>
@@ -68,6 +69,11 @@
</table>
<?php if($stakeholders):?>
<div class='table-footer'>
<div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
<div class="table-actions">
<?php $actionLink = $this->createLink('program', 'batchUnlinkStakeholders', "programID=$programID");?>
<?php echo html::commonButton($lang->delete, "onclick=\"setFormAction('$actionLink', 'hiddenwin')\"");?>
</div>
<?php $pager->show('right', 'pagerjs');?>
</div>
<?php endif;?>