* finish task #2543.
* adjust method name createGroupLink to createGroupManageMemberLink.
This commit is contained in:
+45
-12
@@ -112,20 +112,20 @@ class deptModel extends model
|
||||
|
||||
/**
|
||||
* Get the treemenu of departments.
|
||||
*
|
||||
* @param int $rootDeptID
|
||||
* @param string $userFunc
|
||||
* @param int $groupID
|
||||
*
|
||||
* @param int $rootDeptID
|
||||
* @param string $userFunc
|
||||
* @param array|int $param
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getTreeMenu($rootDeptID = 0, $userFunc, $groupID = 0)
|
||||
public function getTreeMenu($rootDeptID = 0, $userFunc, $param = 0)
|
||||
{
|
||||
$deptMenu = array();
|
||||
$stmt = $this->dbh->query($this->buildMenuQuery($rootDeptID));
|
||||
while($dept = $stmt->fetch())
|
||||
{
|
||||
$linkHtml = call_user_func($userFunc, $dept, $groupID);
|
||||
$linkHtml = call_user_func($userFunc, $dept, $param);
|
||||
|
||||
if(isset($deptMenu[$dept->id]) and !empty($deptMenu[$dept->id]))
|
||||
{
|
||||
@@ -204,18 +204,33 @@ class deptModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the group Link.
|
||||
* Create the group manage members link.
|
||||
*
|
||||
* @param int $dept
|
||||
* @param int $groupID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function createGroupLink($dept, $groupID)
|
||||
public function createGroupManageMemberLink($dept, $groupID)
|
||||
{
|
||||
return html::a(helper::createLink('group', 'managemember', "groupID=$groupID&deptID={$dept->id}"), $dept->name, '_self', "id='dept{$dept->id}'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create project manage members link.
|
||||
*
|
||||
* @param int $dept
|
||||
* @param array $params
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createPrjManageMemberLink($dept, $params)
|
||||
{
|
||||
$projectID = $params['projectID'];
|
||||
$team2Import = $params['team2Import'];
|
||||
return html::a(helper::createLink('project', 'managemembers', "projectID=$projectID&team2Import=$team2Import&deptID={$dept->id}"), $dept->name, '_self', "id='dept{$dept->id}'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sons of a department.
|
||||
*
|
||||
@@ -338,16 +353,34 @@ class deptModel extends model
|
||||
* Get user pairs of a department.
|
||||
*
|
||||
* @param int $deptID
|
||||
* @param string $params
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDeptUserPairs($deptID = 0)
|
||||
public function getDeptUserPairs($deptID = 0, $params = '')
|
||||
{
|
||||
return $this->dao->select('account, realname')->from(TABLE_USER)
|
||||
$fields = 'account, realname';
|
||||
if(strpos($params, 'devfirst')!== false) $fields .= ", INSTR(',td,pm,qd,qa,dev,', role) AS roleOrder";
|
||||
$orderBy = strpos($params, 'first') !== false ? 'roleOrder DESC, account' : 'account';
|
||||
|
||||
$users = $this->dao->select($fields)->from(TABLE_USER)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($deptID)->andWhere('dept')->eq((int)$deptID)->fi()
|
||||
->orderBy('account')
|
||||
->fetchPairs();
|
||||
->orderBy($orderBy)
|
||||
->fetchAll('account');
|
||||
|
||||
/* Cycle the user records to append the first letter of his account. */
|
||||
foreach($users as $account => $user)
|
||||
{
|
||||
$firstLetter = ucfirst(substr($account, 0, 1)) . ':';
|
||||
if(strpos($params, 'noletter') !== false) $firstLetter = '';
|
||||
$users[$account] = $firstLetter . $user->realname;
|
||||
}
|
||||
|
||||
/* Append empty users. */
|
||||
if(strpos($params, 'noempty') === false) $users[''] = '';
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -235,7 +235,7 @@ class group extends control
|
||||
}
|
||||
$group = $this->group->getById($groupID);
|
||||
$groupUsers = $this->group->getUserPairs($groupID);
|
||||
$allUsers = $this->loadModel('dept')->getDeptUserPairs($deptID);
|
||||
$allUsers = $this->loadModel('dept')->getDeptUserPairs($deptID, 'noempty, noletter');
|
||||
$otherUsers = array_diff_assoc($allUsers, $groupUsers);
|
||||
|
||||
$title = $this->lang->company->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->manageMember;
|
||||
@@ -245,7 +245,7 @@ class group extends control
|
||||
$this->view->title = $title;
|
||||
$this->view->position = $position;
|
||||
$this->view->group = $group;
|
||||
$this->view->deptTree = $this->loadModel('dept')->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createGroupLink'), $groupID);
|
||||
$this->view->deptTree = $this->loadModel('dept')->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createGroupManageMemberLink'), $groupID);
|
||||
$this->view->groupUsers = $groupUsers;
|
||||
$this->view->otherUsers = $otherUsers;
|
||||
|
||||
|
||||
@@ -1367,7 +1367,7 @@ class project extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function manageMembers($projectID = 0, $team2Import = 0)
|
||||
public function manageMembers($projectID = 0, $team2Import = 0, $deptID = 0)
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
@@ -1375,22 +1375,20 @@ class project extends control
|
||||
$this->locate($this->createLink('project', 'team', "projectID=$projectID"));
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Load model. */
|
||||
$this->loadModel('user');
|
||||
$this->loadModel('dept');
|
||||
|
||||
$project = $this->project->getById($projectID);
|
||||
$users = $this->user->getPairs('noclosed, nodeleted, devfirst');
|
||||
$roles = $this->user->getUserRoles(array_keys($users));
|
||||
$allUsers = $this->user->getPairs('noclosed, nodeleted, devfirst');
|
||||
$roles = $this->user->getUserRoles(array_keys($allUsers));
|
||||
$currentMembers = $this->project->getTeamMembers($projectID);
|
||||
$members2Import = $this->project->getMembers2Import($team2Import, array_keys($currentMembers));
|
||||
$users = $this->dept->getDeptUserPairs($deptID, 'devfirst');
|
||||
$teams2Import = $this->project->getTeams2Import($this->app->user->account, $projectID);
|
||||
$teams2Import = array($this->lang->project->copyTeam) + $teams2Import;
|
||||
|
||||
/* The deleted members. */
|
||||
foreach($currentMembers as $account => $member)
|
||||
{
|
||||
if(!isset($users[$member->account])) $member->account .= $this->lang->user->deleted;
|
||||
}
|
||||
|
||||
/* Set menu. */
|
||||
$this->project->setMenu($this->projects, $project->id);
|
||||
|
||||
@@ -1402,7 +1400,9 @@ class project extends control
|
||||
$this->view->position = $position;
|
||||
$this->view->project = $project;
|
||||
$this->view->users = $users;
|
||||
$this->view->allUsers = $allUsers;
|
||||
$this->view->roles = $roles;
|
||||
$this->view->deptTree = $this->dept->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createPrjManageMemberLink'), array('projectID' => $projectID, 'team2Import' => $team2Import));
|
||||
$this->view->currentMembers = $currentMembers;
|
||||
$this->view->members2Import = $members2Import;
|
||||
$this->view->teams2Import = $teams2Import;
|
||||
|
||||
@@ -13,17 +13,25 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('projectID', $project->id);?>
|
||||
<?php js::set('roles', $roles);?>
|
||||
<div>
|
||||
<div id='titlebar'>
|
||||
<div class='heading'>
|
||||
<span class='prefix'><?php echo html::icon($lang->icons['team']);?></span>
|
||||
<strong> <?php echo $lang->project->manageMembers;?></strong>
|
||||
<small class='text-muted'><i class='icon icon-cogs'></i></small>
|
||||
</div>
|
||||
<div class='actions'>
|
||||
<button class='btn' id='itBtn'><?php echo html::icon($lang->icons['copy']) . ' ' . $lang->project->copyTeam;?></button>
|
||||
<div id='titlebar'>
|
||||
<div class='heading'>
|
||||
<span class='prefix'><?php echo html::icon($lang->icons['team']);?></span>
|
||||
<strong> <?php echo $lang->project->manageMembers;?></strong>
|
||||
<small class='text-muted'><i class='icon icon-cogs'></i></small>
|
||||
</div>
|
||||
<div class='actions'>
|
||||
<button class='btn' id='itBtn'><?php echo html::icon($lang->icons['copy']) . ' ' . $lang->project->copyTeam;?></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class='side'>
|
||||
<div class='side-body'>
|
||||
<div class='panel panel-sm'>
|
||||
<div class='panel-heading nobr'><?php echo html::icon($lang->icons['company']);?> <strong><?php echo $lang->dept->common;?></strong></div>
|
||||
<div class='panel-body'><?php echo $deptTree;?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='main'>
|
||||
<form class='form-condensed' method='post'>
|
||||
<table class='table table-form'>
|
||||
<thead>
|
||||
@@ -38,10 +46,10 @@
|
||||
</thead>
|
||||
<?php $i = 1; $memberCount = 0;?>
|
||||
<?php foreach($currentMembers as $member):?>
|
||||
<?php if(!isset($users[$member->account])) continue; $realname = substr($users[$member->account], 2);?>
|
||||
<?php if(!isset($allUsers[$member->account])) continue;?>
|
||||
<?php unset($users[$member->account]);?>
|
||||
<tr>
|
||||
<td><input type='text' name='realnames[]' id='account<?php echo $i;?>' value='<?php echo $realname;?>' readonly class='form-control' /></td>
|
||||
<td><input type='text' name='realnames[]' id='account<?php echo $i;?>' value='<?php echo $member->realname;?>' readonly class='form-control' /></td>
|
||||
<td><input type='text' name='roles[]' id='role<?php echo $i;?>' value='<?php echo $member->role;?>' class='form-control' /></td>
|
||||
<td><input type='text' name='days[] ' id='days<?php echo $i;?>' value='<?php echo $member->days;?>' class='form-control' /></td>
|
||||
<td>
|
||||
@@ -57,7 +65,7 @@
|
||||
|
||||
<?php foreach($members2Import as $member2Import):?>
|
||||
<tr class='addedItem'>
|
||||
<td><?php echo html::select("accounts[]", $users, $member2Import->account, "class='select-2 chosen' onchange='setRole(this.value, $i)'");?></td>
|
||||
<td><?php echo html::select("accounts[]", $allUsers, $member2Import->account, "class='select-2 chosen' onchange='setRole(this.value, $i)'");?></td>
|
||||
<td><input type='text' name='roles[]' id='role<?php echo $i;?>' class='form-control' value='<?php echo $member2Import->role;?>' /></td>
|
||||
<td><input type='text' name='days[]' id='days<?php echo $i;?>' class='form-control' value='<?php echo $project->days?>'/></td>
|
||||
<td>
|
||||
@@ -93,6 +101,8 @@
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<?php $i = '%i%';?>
|
||||
<table class='hidden'>
|
||||
<tr id='addItem' class='hidden'>
|
||||
|
||||
Reference in New Issue
Block a user