diff --git a/api/v1/entries/my.php b/api/v1/entries/my.php
index 5b53396883..a07722c884 100644
--- a/api/v1/entries/my.php
+++ b/api/v1/entries/my.php
@@ -10,12 +10,9 @@ class myEntry extends entry
{
public function get()
{
- $myModel = $this->loadModel('my');
+ $info = $this->loadModel('my')->getInfo();
- $data = $myModel->myInfo();
-
- if(!$data) return $this->sendError(400, $data->message);
- $this->send(200, $data);
+ if(!$info) return $this->sendError(400, $info->message);
+ $this->send(200, $info);
}
-
}
diff --git a/config/routes.php b/config/routes.php
index 985f82dc15..a18c4c579f 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -33,7 +33,7 @@ $routes['/tasks/:id/finish'] = 'taskFinish';
$routes['/users'] = 'users';
$routes['/users/:id'] = 'user';
-$routes['/user'] = 'user';
+$routes['/my'] = 'my';
$routes['/programs'] = 'programs';
$routes['/programs/:id'] = 'program';
@@ -41,6 +41,4 @@ $routes['/programs/:id'] = 'program';
$routes['/issues/:issueID'] = 'productIssue';
$routes['/products/:productID/issues'] = 'productIssues';
-$routes['/my'] = 'my';
-
$config->routes = $routes;
diff --git a/module/action/model.php b/module/action/model.php
index bc601a6d23..0738ab9bbf 100755
--- a/module/action/model.php
+++ b/module/action/model.php
@@ -965,7 +965,7 @@ class actionModel extends model
$objectName = array();
$objectProject = array();
- if(strpos($this->config->action->needGetProjectType, $objectType) !== false)
+ if(strpos(",{$this->config->action->needGetProjectType},", ",{$objectType},") !== false)
{
$objectInfo = $this->dao->select("id, project, $field AS name")->from($table)->where('id')->in($objectIds)->fetchAll();
foreach($objectInfo as $object)
diff --git a/module/execution/control.php b/module/execution/control.php
index 0d0cb3c83d..c4707e1337 100644
--- a/module/execution/control.php
+++ b/module/execution/control.php
@@ -1340,6 +1340,7 @@ class execution extends control
$this->view->name = $name;
$this->view->code = $code;
$this->view->team = $team;
+ $this->view->teams = array(0 => '') + $this->execution->getTeamPairsByProject((int)$projectID);
$this->view->allProjects = array(0 => '') + $this->project->getPairsByModel();
$this->view->executionID = $executionID;
$this->view->productID = $productID;
@@ -2269,7 +2270,7 @@ class execution extends control
$currentMembers = $this->execution->getTeamMembers($executionID);
$members2Import = $this->execution->getMembers2Import($team2Import, array_keys($currentMembers));
- $teams2Import = $this->execution->getTeams2Import($this->app->user->account, $executionID);
+ $teams2Import = $this->loadModel('personnel')->getCopyObjects($executionID, 'sprint');
$teams2Import = array('' => '') + $teams2Import;
/* Append users for get users. */
@@ -2635,6 +2636,28 @@ class execution extends control
}
}
+ /**
+ * AJAX: get team members by projectID/executionID.
+ *
+ * @param int $objectID
+ * @access public
+ * @return string
+ */
+ public function ajaxGetTeamMembers($objectID)
+ {
+ $type = 'execution';
+ if($this->config->systemMode == 'new')
+ {
+ $type = $this->dao->findById($objectID)->from(TABLE_PROJECT)->fetch('type');
+ $type = $type == 'project' ? $type : 'execution';
+ }
+
+ $users = $this->loadModel('user')->getPairs('nodeleted|noclosed');
+ $members = $this->user->getTeamMemberPairs($objectID, $type);
+
+ die(html::select('teamMembers[]', $users, array_keys($members), "class='form-control chosen' multiple"));
+ }
+
/**
* When create a execution, help the user.
*
@@ -2904,10 +2927,11 @@ class execution extends control
*
* @param int $executionID
* @param int $deptID
+ * @param int $copyID
* @access public
* @return void
*/
- public function addWhitelist($executionID = 0, $deptID = 0)
+ public function addWhitelist($executionID = 0, $deptID = 0, $copyID = 0)
{
/* use first execution if executionID does not exist. */
if(!isset($this->executions[$executionID])) $executionID = key($this->executions);
@@ -2915,7 +2939,7 @@ class execution extends control
/* Set the menu. If the executionID = 0, use the indexMenu instead. */
$this->execution->setMenu($executionID);
- echo $this->fetch('personnel', 'addWhitelist', "objectID=$executionID&dept=$deptID&objectType=sprint&module=execution");
+ echo $this->fetch('personnel', 'addWhitelist', "objectID=$executionID&dept=$deptID©ID=$copyID&objectType=sprint&module=execution");
}
/*
diff --git a/module/execution/js/create.js b/module/execution/js/create.js
index e3290b67ff..1f703868a5 100644
--- a/module/execution/js/create.js
+++ b/module/execution/js/create.js
@@ -42,6 +42,18 @@ $(function()
};
adjustMainCol();
$(window).on('resize', adjustMainCol);
+
+ $('#teams').change(function()
+ {
+ var objectID = $(this).val();
+ $.get(createLink('execution', 'ajaxGetTeamMembers', 'objectID=' + objectID), function(data)
+ {
+ $('#teamMembers').parent().html(data);
+ $('#teamMembers').chosen();
+ });
+ })
+
+ $('#teams').change();
});
function showLifeTimeTips()
diff --git a/module/execution/lang/de.php b/module/execution/lang/de.php
index a5e1c34fdd..f342ab966f 100644
--- a/module/execution/lang/de.php
+++ b/module/execution/lang/de.php
@@ -98,6 +98,10 @@ $lang->execution->noLinkProduct = "Stage not linked {$lang->productCommon}";
$lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
+$lang->execution->or = ' or ';
+
+if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
+if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Start';
$lang->execution->activate = 'Aktivieren';
diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php
index 20ec31ed80..10fa7d2b20 100644
--- a/module/execution/lang/en.php
+++ b/module/execution/lang/en.php
@@ -99,6 +99,10 @@ $lang->execution->noLinkProduct = "Stage not linked {$lang->productCommon}";
$lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
+$lang->execution->or = ' or ';
+
+if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
+if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Start';
$lang->execution->activate = 'Activate';
@@ -293,7 +297,7 @@ $lang->execution->copyTeam = 'Copy Team';
$lang->execution->copyFromTeam = "Copy from {$lang->executionCommon} Team: %s";
$lang->execution->noMatched = "No $lang->executionCommon including '%s'can be found.";
$lang->execution->copyTitle = "Choose a {$lang->executionCommon} to copy.";
-$lang->execution->copyTeamTitle = "Choose a {$lang->executionCommon} Team to copy.";
+$lang->execution->copyTeamTitle = "Choose a {$lang->projectCommon} or {$lang->executionCommon} Team to copy.";
$lang->execution->copyNoExecution = "No {$lang->executionCommon} can be copied.";
$lang->execution->copyFromExecution = "Copy from {$lang->executionCommon} %s";
$lang->execution->cancelCopy = 'Cancel Copy';
diff --git a/module/execution/lang/fr.php b/module/execution/lang/fr.php
index 53f323b89c..9049dc47a2 100644
--- a/module/execution/lang/fr.php
+++ b/module/execution/lang/fr.php
@@ -98,6 +98,10 @@ $lang->execution->noLinkProduct = "Stage not linked {$lang->productCommon}";
$lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
+$lang->execution->or = ' or ';
+
+if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
+if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Démarrer';
$lang->execution->activate = 'Activer';
diff --git a/module/execution/lang/vi.php b/module/execution/lang/vi.php
index 2a3e9ba2d5..e3f827c4e9 100644
--- a/module/execution/lang/vi.php
+++ b/module/execution/lang/vi.php
@@ -99,6 +99,10 @@ $lang->execution->noLinkProduct = "Stage not linked {$lang->productCommon}";
$lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
+$lang->execution->or = ' or ';
+
+if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
+if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Bắt đầu';
$lang->execution->activate = 'Kích hoạt';
diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php
index fe2371889f..497fa6179d 100644
--- a/module/execution/lang/zh-cn.php
+++ b/module/execution/lang/zh-cn.php
@@ -99,6 +99,10 @@ $lang->execution->noLinkProduct = "阶段没有关联{$lang->productCommon}";
$lang->execution->recent = '近期访问:';
$lang->execution->copyNoExecution = '没有可用的' . $lang->executionCommon . '来复制';
$lang->execution->noTeam = '暂时没有团队成员';
+$lang->execution->or = '或';
+
+if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "可以选择复制项目或{$lang->execution->common}团队的成员";
+if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "可以选择复制{$lang->executionCommon}团队的成员";
$lang->execution->start = "开始";
$lang->execution->activate = "激活";
@@ -293,7 +297,7 @@ $lang->execution->copyTeam = '复制团队';
$lang->execution->copyFromTeam = "复制自{$lang->executionCommon}团队: %s";
$lang->execution->noMatched = "找不到包含'%s'的$lang->executionCommon";
$lang->execution->copyTitle = "请选择一个{$lang->executionCommon}来复制";
-$lang->execution->copyTeamTitle = "选择一个{$lang->executionCommon}团队来复制";
+$lang->execution->copyTeamTitle = "选择一个{$lang->projectCommon}或{$lang->executionCommon}团队来复制";
$lang->execution->copyNoExecution = "没有可用的{$lang->executionCommon}来复制";
$lang->execution->copyFromExecution = "复制自{$lang->executionCommon} %s";
$lang->execution->cancelCopy = '取消复制';
diff --git a/module/execution/model.php b/module/execution/model.php
index 0e416d6bb5..f9b99a6b6c 100644
--- a/module/execution/model.php
+++ b/module/execution/model.php
@@ -325,7 +325,7 @@ class executionModel extends model
->join('whitelist', ',')
->add('type', $type)
->stripTags($this->config->execution->editor->create['id'], $this->config->allowedTags)
- ->remove('products, workDays, delta, branch, uid, plans')
+ ->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers')
->get();
/* Check the workload format and total. */
@@ -368,6 +368,7 @@ class executionModel extends model
$executionID = $this->dao->lastInsertId();
$today = helper::today();
$creatorExists = false;
+ $teamMembers = array();
/* Save order. */
$this->dao->update(TABLE_EXECUTION)->set('`order`')->eq($executionID * 5)->where('id')->eq($executionID)->exec();
@@ -376,39 +377,42 @@ class executionModel extends model
/* Update the path. */
if($this->config->systemMode == 'new') $this->setTreePath($executionID);
- /* Copy team of execution. */
- if($copyExecutionID != '')
+ /* Set team of execution. */
+ $members = isset($_POST['teamMembers']) ? $_POST['teamMembers'] : array();
+ $roles = $this->loadModel('user')->getUserRoles(array_keys($members));
+ foreach($members as $account)
{
- $members = $this->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($copyExecutionID)->andWhere('type')->eq('execution')->fetchAll();
- foreach($members as $member)
- {
- unset($member->id);
- $member->root = $executionID;
- $member->join = $today;
- $member->days = $sprint->days;
- $member->type = 'execution';
- $this->dao->insert(TABLE_TEAM)->data($member)->exec();
- if($member->account == $this->app->user->account) $creatorExists = true;
- }
- }
+ if(empty($account)) continue;
- /* Add the creator to team. */
- if($copyExecutionID == '' or !$creatorExists)
- {
- $this->app->loadLang('user');
- $member = new stdclass();
+ $member = new stdClass();
$member->root = $executionID;
- $member->account = $this->app->user->account;
- $member->role = zget($this->lang->user->roleList, $this->app->user->role, '');
- $member->join = $today;
$member->type = 'execution';
+ $member->account = $account;
+ $member->role = zget($roles, $account, '');
+ $member->join = $today;
$member->days = $sprint->days;
$member->hours = $this->config->execution->defaultWorkhours;
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
-
- if($this->config->systemMode == 'new') $this->addProjectMembers($sprint->project, array($member));
+ if($member->account == $this->app->user->account) $creatorExists = true;
+ $teamMembers[$account] = $member;
}
+ if(!$creatorExists)
+ {
+ $member = new stdClass();
+ $member->root = $executionID;
+ $member->type = 'execution';
+ $member->account = $this->app->user->account;
+ $member->role = zget($this->lang->user->roleList, $this->app->user->role, '');
+ $member->join = $today;
+ $member->days = $sprint->days;
+ $member->hours = $this->config->execution->defaultWorkhours;
+ $this->dao->insert(TABLE_TEAM)->data($member)->exec();
+ $teamMembers[$member->account] = $member;
+ }
+
+ if($this->config->systemMode == 'new') $this->addProjectMembers($sprint->project, $teamMembers);
+
/* Create doc lib. */
$this->app->loadLang('doc');
$lib = new stdclass();
@@ -2434,11 +2438,40 @@ class executionModel extends model
return $this->dao->select('account, role, hours')
->from(TABLE_TEAM)
->where('root')->eq($execution)
- ->andWhere('type')->eq('execution')
+ ->andWhere('type')->in('project,execution')
->andWhere('account')->notIN($currentMembers)
->fetchAll('account');
}
+ /**
+ * Get the project and execution the team through the projectID.
+ *
+ * @param int $projectID
+ * @access public
+ * @return array
+ */
+ public function getTeamPairsByProject($projectID = 0)
+ {
+ $teams = $this->dao->select('id,team,type')->from(TABLE_PROJECT)
+ ->where('deleted')->eq(0)
+ ->andWhere('project')->eq($projectID)
+ ->orWhere('id')->eq($projectID)
+ ->fetchAll('id');
+
+ if(empty($teams)) return array();
+
+ $teamPairs = array();
+ foreach($teams as $id => $team)
+ {
+ if(empty($team->team)) continue;
+
+ $object = $team->type == 'project' ? $this->lang->project->common . '-' : $this->lang->execution->common . '-';
+ $teamPairs[$id] = $object . $team->team;
+ }
+
+ return $teamPairs;
+ }
+
/**
* Manage team members.
*
diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php
index 707b4290f0..df69b0c8b1 100644
--- a/module/execution/view/create.html.php
+++ b/module/execution/view/create.html.php
@@ -50,13 +50,13 @@
| systemMode == 'new')) ? $lang->execution->execDesc : $lang->execution->desc;?> |
diff --git a/module/index/js/index.js b/module/index/js/index.js
index 68d7a52f2e..edad5856cc 100644
--- a/module/index/js/index.js
+++ b/module/index/js/index.js
@@ -463,7 +463,7 @@
{
var $item = $(this);
var isDivider = $item.hasClass('divider');
- var height = isDivider ? 17 : 40;
+ var height = isDivider ? 17 : $item.outerHeight();
currentHeight += height;
if(currentHeight > maxHeight)
{
diff --git a/module/my/model.php b/module/my/model.php
index c491dfc7f4..52124c0429 100644
--- a/module/my/model.php
+++ b/module/my/model.php
@@ -57,16 +57,155 @@ class myModel extends model
}
}
- public function myInfo()
+ /**
+ * Get my info.
+ *
+ * @access public
+ * @return object
+ */
+ public function getInfo()
{
- $data = array();
+ $info = new stdclass();
+ $info->profile = $this->loadModel('user')->getById($this->app->user->account);
- /* My count. */
- $data['tasks'] = (int) $this->dao->select('count(*) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
- $data['stories'] = (int) $this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
- $data['bugs'] = (int) $this->dao->select('count(*) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
+ /* My tasks. */
+ $info->task = new stdclass();
+ $info->task->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->task->dynamic = array();
- /* Charge products. */
+ if(common::hasPriv('task', 'view'))
+ {
+ $tasks = $this->dao->select('*')->from(TABLE_TASK)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('deleted')->eq('0')
+ ->andWhere('status')->ne('closed')
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->task->dynamic = $tasks;
+ }
+
+ /* My stories. */
+ $info->story = new stdclass();
+ $info->story->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
+ $info->story->dynamic = array();
+ if(common::hasPriv('story', 'view'))
+ {
+ $stories = $this->dao->select('*')->from(TABLE_STORY)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('deleted')->eq('0')
+ ->andWhere('status')->ne('closed')
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->story->dynamic = $stories;
+ }
+
+ /* My bugs. */
+ $info->bug = new stdclass();
+ $info->bug->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->bug->dynamic = array();
+ if(common::hasPriv('bug', 'view'))
+ {
+ $this->app->loadLang('bug');
+ $bugs = $this->dao->select('*')->from(TABLE_BUG)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('deleted')->eq('0')
+ ->andWhere('status')->ne('closed')
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->bug->dynamic = $bugs;
+ }
+
+ /* My todos. */
+ $info->todo = new stdclass();
+ $info->todo->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_TODO)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->todo->dynamic = new stdclass();
+ if(common::hasPriv('todo', 'view'))
+ {
+ $todos = $this->dao->select('*')->from(TABLE_TODO)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('cycle')->eq(0)
+ ->andWhere('deleted')->eq(0)
+ ->andWhere('status')->eq('wait')
+ ->orderBy('`date` desc')
+ ->limit(3)
+ ->fetchAll();
+ foreach($todos as $key => $todo)
+ {
+ if($todo->status == 'done' and $todo->finishedBy == $this->app->user->account)
+ {
+ unset($todos[$key]);
+ continue;
+ }
+
+ $todo->begin = date::formatTime($todo->begin);
+ $todo->end = date::formatTime($todo->end);
+ }
+ $info->todo->dynamic = $todos;
+ }
+
+ /* My risks. */
+ $info->risk = new stdclass();
+ $info->risk->total = 0;
+ $info->risk->dynamic = new stdclass();
+ if(common::hasPriv('risk', 'view') and isset($this->config->maxVersion))
+ {
+ $risks = $this->dao->select('*')->from(TABLE_RISK)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('deleted')->eq('0')
+ ->andWhere('status')->ne('closed')
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->risk->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_RISK)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->risk->dynamic = $risks;
+ }
+
+ /* My meetings. */
+ $info->meeting = new stdclass();
+ $info->meeting->total = 0;
+ $info->meeting->dynamic = new stdclass();
+ if(common::hasPriv('meeting', 'view') and isset($this->config->maxVersion))
+ {
+ $today = helper::today();
+ $now = date('H:i:s', strtotime(helper::now()));
+
+ $meetings = $this->dao->select('*')->from(TABLE_MEETING)
+ ->Where('deleted')->eq('0')
+ ->andWhere('(date')->gt($today)
+ ->orWhere('(begin')->gt($now)
+ ->andWhere('date')->eq($today)
+ ->markRight(2)
+ ->andwhere('(host')->eq($this->app->user->account)
+ ->orWhere('participant')->in($this->app->user->account)
+ ->markRight(1)
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->meeting->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_MEETING)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->meeting->dynamic = $meetings;
+ }
+
+ /* My issues. */
+ $info->issue = new stdclass();
+ $info->issue->total = 0;
+ $info->issue->dynamic = new stdclass();
+ if(common::hasPriv('issue', 'view') and isset($this->config->maxVersion))
+ {
+ $issues = $this->dao->select('*')->from(TABLE_ISSUE)
+ ->where('assignedTo')->eq($this->app->user->account)
+ ->andWhere('deleted')->eq('0')
+ ->andWhere('status')->ne('closed')
+ ->orderBy('id_desc')
+ ->limit(3)
+ ->fetchAll();
+ $info->issue->total = (int) $this->dao->select('count(*) AS count')->from(TABLE_ISSUE)->where('assignedTo')->eq($this->app->user->account)->andWhere('status')->ne('closed')->andWhere('deleted')->eq(0)->fetch('count');
+ $info->issue->dynamic = $issues;
+ }
+
+ /* My charged products. */
$products = $this->dao->select('t1.id as id,t1.*')->from(TABLE_PRODUCT)->alias('t1')
->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id')
->where('t1.deleted')->eq(0)
@@ -76,6 +215,7 @@ class myModel extends model
->orderBy('t1.order_asc')
->fetchAll('id');
$productKeys = array_keys($products);
+
$stories = $this->dao->select('product, status, count(status) AS count')
->from(TABLE_STORY)
->where('deleted')->eq(0)
@@ -107,6 +247,7 @@ class myModel extends model
$execution = $this->loadModel('execution')->getById($execuData->id);
$executions[$key]->progress = ($execution->totalConsumed + $execution->totalLeft) ? floor($execution->totalConsumed / ($execution->totalConsumed + $execution->totalLeft) * 1000) / 1000 * 100 : 0;
}
+
foreach($products as $key => $product)
{
$product->plans = isset($plans[$product->id]) ? $plans[$product->id] : 0;
@@ -114,7 +255,7 @@ class myModel extends model
if(isset($stories[$product->id])) $product->stories = $stories[$product->id];
if(isset($executions[$product->id])) $product->executions = $executions[$product->id];
}
- $data['chargeProducts'] = array_values($products);
+ $info->products = array_values($products);
/* All projects. */
$projects = $this->loadModel('project')->getOverviewList('byStatus', 'all', 'order_asc');
@@ -126,119 +267,7 @@ class myModel extends model
$projects[$key]->progress = ($workhour->totalConsumed + $workhour->totalLeft) ? floor($workhour->totalConsumed / ($workhour->totalConsumed + $workhour->totalLeft) * 1000) / 1000 * 100 : 0;
}
}
- $data['projects'] = array_values($projects);
-
- /* Todo list. */
- if(common::hasPriv('todo', 'view')) $hasViewPriv['todo'] = true;
- if(common::hasPriv('task', 'view')) $hasViewPriv['task'] = true;
- if(common::hasPriv('bug', 'view')) $hasViewPriv['bug'] = true;
- if(common::hasPriv('risk', 'view') and isset($this->config->maxVersion)) $hasViewPriv['risk'] = true;
- if(common::hasPriv('issue', 'view') and isset($this->config->maxVersion)) $hasViewPriv['issue'] = true;
- if(common::hasPriv('meeting', 'view') and isset($this->config->maxVersion)) $hasViewPriv['meeting'] = true;
- if(common::hasPriv('story', 'view')) $hasViewPriv['story'] = true;
- if(isset($hasViewPriv['todo']))
- {
- $this->app->loadClass('date');
- $this->app->loadLang('todo');
- $stmt = $this->dao->select('*')->from(TABLE_TODO)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('cycle')->eq(0)
- ->andWhere('deleted')->eq(0)
- ->andWhere('status')->eq('wait')
- ->orderBy('`date` desc')
- ->limit(3);
- $todos = $stmt->fetchAll();
- foreach($todos as $key => $todo)
- {
- if($todo->status == 'done' and $todo->finishedBy == $this->app->user->account)
- {
- unset($todos[$key]);
- continue;
- }
-
- $todo->begin = date::formatTime($todo->begin);
- $todo->end = date::formatTime($todo->end);
- }
- $data['todos'] = $todos;
- }
- if(isset($hasViewPriv['task']))
- {
- $this->app->loadLang('task');
- $this->app->loadLang('execution');
- $stmt = $this->dao->select('*')->from(TABLE_TASK)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('deleted')->eq('0')
- ->andWhere('status')->ne('closed')
- ->orderBy('id_desc')
- ->limit(3);
- $data['toTasks'] = $stmt->fetchAll();
- }
- if(isset($hasViewPriv['bug']))
- {
- $this->app->loadLang('bug');
- $stmt = $this->dao->select('*')->from(TABLE_BUG)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('deleted')->eq('0')
- ->andWhere('status')->ne('closed')
- ->orderBy('id_desc')
- ->limit(3);
- $data['toBugs'] = $stmt->fetchAll();
- }
- if(isset($hasViewPriv['risk']))
- {
- $this->app->loadLang('risk');
- $stmt = $this->dao->select('*')->from(TABLE_RISK)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('deleted')->eq('0')
- ->andWhere('status')->ne('closed')
- ->orderBy('id_desc')
- ->limit(3);
- $data['toRisks'] = $stmt->fetchAll();
- }
- if(isset($hasViewPriv['meeting']))
- {
- $this->app->loadLang('meeting');
- $today = helper::today();
- $now = date('H:i:s', strtotime(helper::now()));
-
- $meetings = $this->dao->select('*')->from(TABLE_MEETING)
- ->Where('deleted')->eq('0')
- ->andWhere('(date')->gt($today)
- ->orWhere('(begin')->gt($now)
- ->andWhere('date')->eq($today)
- ->markRight(2)
- ->andwhere('(host')->eq($this->app->user->account)
- ->orWhere('participant')->in($this->app->user->account)
- ->markRight(1)
- ->orderBy('id_desc')
- ->limit(3)
- ->fetchAll();
-
- $data['toMeetings'] = $meetings;
- }
- if(isset($hasViewPriv['issue']))
- {
- $this->app->loadLang('issue');
- $stmt = $this->dao->select('*')->from(TABLE_ISSUE)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('deleted')->eq('0')
- ->andWhere('status')->ne('closed')
- ->orderBy('id_desc')
- ->limit(3);
-
- $data['toIssues'] = $stmt->fetchAll();
- }
- if(isset($hasViewPriv['story']))
- {
- $this->app->loadLang('story');
- $stmt = $this->dao->select('*')->from(TABLE_STORY)
- ->where('assignedTo')->eq($this->app->user->account)
- ->andWhere('deleted')->eq('0')
- ->andWhere('status')->ne('closed')
- ->orderBy('id_desc')
- ->limit(3);
- $data['toStories'] = $stmt->fetchAll();
- }
+ $info->projects = array_values($projects);
/* Dynamic. */
$actions = $this->loadModel('action')->getDynamic('all', 'today', 'date_desc');
@@ -247,19 +276,13 @@ class myModel extends model
{
$actions[$key]->actor = $users[$action->actor];
}
- $data['dynamic'] = $actions;
+ $info->dynamic = $actions;
/* User info. */
- global $lang, $app;
- $data['user'] = new stdclass();
- $data['user']->score = $app->user->score;
- $data['user']->avatar = !empty($app->user->avatar) ? $app->user->avatar : strtoupper($app->user->account[0]);
- $data['user']->role = isset($lang->user->roleList[$app->user->role]) ? $lang->user->roleList[$app->user->role] : $app->user->role;
- $data['user']->email = $app->user->email;
- $data['participateProjectCount'] = count($data['projects']);
- $data['createdDocs'] = $this->dao->select('count(*) AS count')->from(TABLE_DOC)->where('addedBy')->eq($this->app->user->account)->andWhere('deleted')->eq('0')->fetch('count');
+ $info->participateProjectCount = count($info->projects);
+ $info->createdDocs = $this->dao->select('count(*) AS count')->from(TABLE_DOC)->where('addedBy')->eq($this->app->user->account)->andWhere('deleted')->eq('0')->fetch('count');
- return $data;
+ return $info;
}
}
diff --git a/module/personnel/control.php b/module/personnel/control.php
index 43835db04c..fc3b80d5fa 100644
--- a/module/personnel/control.php
+++ b/module/personnel/control.php
@@ -145,6 +145,7 @@ class personnel extends control
*
* @param int $objectID
* @param int $deptID
+ * @param int $copyID
* @param string $objectType program|project|product|sprint
* @param string $module
* @param int $programID
@@ -152,7 +153,7 @@ class personnel extends control
* @access public
* @return void
*/
- public function addWhitelist($objectID = 0, $deptID = 0, $objectType = 'program', $module = 'personnel', $programID = 0, $from = '')
+ public function addWhitelist($objectID = 0, $deptID = 0, $copyID = 0, $objectType = 'program', $module = 'personnel', $programID = 0, $from = '')
{
if($this->app->openApp == 'program')
{
@@ -180,20 +181,38 @@ class personnel extends control
$this->loadModel('dept');
$deptUsers = empty($deptID) ? array() : $this->dept->getDeptUserPairs($deptID);
+ $copyObjectType = $objectType;
+ if($copyObjectType == 'sprint')
+ {
+ $object = $this->loadModel('project')->getByID($copyID);
+ if(!empty($object)) $copyObjectType = 'project';
+ }
+ $copyUsers = empty($copyID) ? array() : $this->personnel->getWhitelistAccount($copyID, $copyObjectType);
+ $appendUsers = array_unique($deptUsers + $copyUsers);
+
+ $objectName = $this->lang->projectCommon . $this->lang->execution->or . $this->lang->execution->common;
+ if($objectType == 'program') $objectName = $this->lang->program->common;
+ if($objectType == 'product') $objectName = $this->lang->productCommon;
+ if($objectType == 'project') $objectName = $this->lang->projectCommon;
+ $this->lang->personnel->selectObjectTips = sprintf($this->lang->personnel->selectObjectTips, $objectName);
+
$this->view->title = $this->lang->personnel->addWhitelist;
$this->view->position[] = $this->lang->personnel->addWhitelist;
- $this->view->objectID = $objectID;
- $this->view->objectType = $objectType;
- $this->view->module = $module;
- $this->view->deptID = $deptID;
- $this->view->deptUsers = $deptUsers;
- $this->view->whitelist = $this->personnel->getWhitelist($objectID, $objectType);
- $this->view->depts = $this->dept->getOptionMenu();
- $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted');
- $this->view->dept = $this->dept->getByID($deptID);
- $this->view->programID = $programID;
- $this->view->from = $from;
+ $this->view->objectID = $objectID;
+ $this->view->objectType = $objectType;
+ $this->view->objectName = $objectName;
+ $this->view->objects = array('' => '') + $this->personnel->getCopyObjects($objectID, $objectType);
+ $this->view->module = $module;
+ $this->view->deptID = $deptID;
+ $this->view->appendUsers = $appendUsers;
+ $this->view->whitelist = $this->personnel->getWhitelist($objectID, $objectType);
+ $this->view->depts = $this->dept->getOptionMenu();
+ $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted');
+ $this->view->dept = $this->dept->getByID($deptID);
+ $this->view->programID = $programID;
+ $this->view->from = $from;
+ $this->view->copyID = $copyID;
$this->display();
}
diff --git a/module/personnel/js/addwhitelist.js b/module/personnel/js/addwhitelist.js
index eb81369c64..083645bb30 100644
--- a/module/personnel/js/addwhitelist.js
+++ b/module/personnel/js/addwhitelist.js
@@ -1,15 +1,16 @@
/**
- * Users by department.
+ * Users by dept,execution,project,product or program.
*
- * @param object dept
+ * @param object $object
+ * @access public
* @return void
*/
-function setDeptUsers(dept)
+function setObjectUsers()
{
- var deptID = $(dept).val();
- var link = createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '&objectType=' + objectType + '&module=' + module);
-
- if(module == 'program') link = createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '&programID=' + programID + '&from=' + from);
+ var copyID = $('#object').val();
+ var deptID = $('#dept').val();
+ var link = createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '©ID=' + copyID + '&objectType=' + objectType + '&module=' + module);
+ if(module == 'program') link = createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '©ID=' + copyID + '&programID=' + programID + '&from=' + from);
location.href = link;
}
diff --git a/module/personnel/lang/de.php b/module/personnel/lang/de.php
index 3390cdb972..fab6b23d11 100644
--- a/module/personnel/lang/de.php
+++ b/module/personnel/lang/de.php
@@ -30,9 +30,11 @@ $lang->personnel->resolved = 'Resolved';
$lang->personnel->UR = $lang->URCommon;
$lang->personnel->SR = $lang->SRCommon;
-$lang->personnel->whitelist = 'Whitelist';
-$lang->personnel->addWhitelist = 'Add Whitelist';
+$lang->personnel->whitelist = 'Whitelist';
+$lang->personnel->addWhitelist = 'Add Whitelist';
$lang->personnel->unbindWhitelist = 'Remove Whitelist';
-$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->copy = 'Copy Whitelist';
-$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->selectObjectTips = 'Select %s to copy its whitelist';
diff --git a/module/personnel/lang/en.php b/module/personnel/lang/en.php
index ea35916e8b..3f78c567f9 100644
--- a/module/personnel/lang/en.php
+++ b/module/personnel/lang/en.php
@@ -30,9 +30,11 @@ $lang->personnel->resolved = 'Resolved';
$lang->personnel->UR = $lang->URCommon;
$lang->personnel->SR = $lang->SRCommon;
-$lang->personnel->whitelist = 'Whitelist';
-$lang->personnel->addWhitelist = 'Add Whitelist';
+$lang->personnel->whitelist = 'Whitelist';
+$lang->personnel->addWhitelist = 'Add Whitelist';
$lang->personnel->unbindWhitelist = 'Remove Whitelist';
-$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->copy = 'Copy Whitelist';
-$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->selectObjectTips = 'Select %s to copy its whitelist';
diff --git a/module/personnel/lang/fr.php b/module/personnel/lang/fr.php
index 3390cdb972..fab6b23d11 100644
--- a/module/personnel/lang/fr.php
+++ b/module/personnel/lang/fr.php
@@ -30,9 +30,11 @@ $lang->personnel->resolved = 'Resolved';
$lang->personnel->UR = $lang->URCommon;
$lang->personnel->SR = $lang->SRCommon;
-$lang->personnel->whitelist = 'Whitelist';
-$lang->personnel->addWhitelist = 'Add Whitelist';
+$lang->personnel->whitelist = 'Whitelist';
+$lang->personnel->addWhitelist = 'Add Whitelist';
$lang->personnel->unbindWhitelist = 'Remove Whitelist';
-$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->copy = 'Copy Whitelist';
-$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->selectObjectTips = 'Select %s to copy its whitelist';
diff --git a/module/personnel/lang/vi.php b/module/personnel/lang/vi.php
index 3390cdb972..fab6b23d11 100644
--- a/module/personnel/lang/vi.php
+++ b/module/personnel/lang/vi.php
@@ -30,9 +30,11 @@ $lang->personnel->resolved = 'Resolved';
$lang->personnel->UR = $lang->URCommon;
$lang->personnel->SR = $lang->SRCommon;
-$lang->personnel->whitelist = 'Whitelist';
-$lang->personnel->addWhitelist = 'Add Whitelist';
+$lang->personnel->whitelist = 'Whitelist';
+$lang->personnel->addWhitelist = 'Add Whitelist';
$lang->personnel->unbindWhitelist = 'Remove Whitelist';
-$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->confirmDelete = 'Confirm removal of the user from the whitelist?';
+$lang->personnel->copy = 'Copy Whitelist';
-$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.';
+$lang->personnel->selectObjectTips = 'Select %s to copy its whitelist';
diff --git a/module/personnel/lang/zh-cn.php b/module/personnel/lang/zh-cn.php
index a262e8fb5d..d5b345f623 100644
--- a/module/personnel/lang/zh-cn.php
+++ b/module/personnel/lang/zh-cn.php
@@ -30,9 +30,11 @@ $lang->personnel->resolved = '解决';
$lang->personnel->UR = $lang->URCommon;
$lang->personnel->SR = $lang->SRCommon;
-$lang->personnel->whitelist = '白名单列表';
-$lang->personnel->addWhitelist = '添加白名单';
+$lang->personnel->whitelist = '白名单列表';
+$lang->personnel->addWhitelist = '添加白名单';
$lang->personnel->unbindWhitelist = '删除白名单';
-$lang->personnel->confirmDelete = '确认将该用户移除白名单?';
+$lang->personnel->confirmDelete = '确认将该用户移除白名单?';
+$lang->personnel->copy = '复制白名单';
-$lang->personnel->openedPGMTip = '该项目集是公开状态,有项目集视图权限的人员即可访问。';
+$lang->personnel->openedPGMTip = '该项目集是公开状态,有项目集视图权限的人员即可访问。';
+$lang->personnel->selectObjectTips = '请选择一个%s白名单来复制';
diff --git a/module/personnel/model.php b/module/personnel/model.php
index d6cd126d74..35008cf8ec 100644
--- a/module/personnel/model.php
+++ b/module/personnel/model.php
@@ -456,6 +456,58 @@ class personnelModel extends model
->fetchGroup('root', 'id');
}
+ /**
+ * Get objects to copy whitelist.
+ *
+ * @param int $objectID
+ * @param int $objectType
+ * @access public
+ * @return array
+ */
+ public function getCopyObjects($objectID, $objectType)
+ {
+ $objects = array();
+
+ if($objectType == 'sprint')
+ {
+ $parentID = 0;
+ if($this->config->systemMode == 'new') $parentID = $this->dao->select('project')->from(TABLE_EXECUTION)->where('id')->eq($objectID)->fetch('project');
+
+ $objects = $this->dao->select('id,name')->from(TABLE_EXECUTION)
+ ->where('(project')->eq($parentID)
+ ->orWhere('id')->eq($parentID)
+ ->markRight(1)
+ ->andWhere('(id')->in($this->app->user->view->projects)
+ ->orWhere('id')->in($this->app->user->view->sprints)
+ ->markRight(1)
+ ->andWhere('deleted')->eq(0)
+ ->orderBy('type')
+ ->fetchPairs();
+ foreach($objects as $id => &$object)
+ {
+ if($id == $parentID) $object = $this->lang->projectCommon . '-' . $object;
+ if($id != $parentID) $object = $this->lang->execution->common . '-' . $object;
+ }
+ }
+ elseif($objectType == 'project')
+ {
+ $parentID = $this->dao->select('parent')->from(TABLE_PROJECT)->where('id')->eq($objectID)->fetch('parent');
+ $objects = $this->loadModel('project')->getPairsByProgram($parentID);
+ }
+ elseif($objectType == 'product')
+ {
+ $parentID = $this->dao->select('program')->from(TABLE_PRODUCT)->where('id')->eq($objectID)->fetch('program');
+ $objects = $this->loadModel('product')->getPairs('', $parentID);
+ }
+ elseif($objectType == 'program')
+ {
+ $objects = $this->loadModel('program')->getPairs();
+ }
+
+ unset($objects[$objectID]);
+ return $objects;
+ }
+
/**
* Access to program set invest staff.
*
diff --git a/module/personnel/view/addwhitelist.html.php b/module/personnel/view/addwhitelist.html.php
index ffc351f2cb..d9d07bdfc6 100644
--- a/module/personnel/view/addwhitelist.html.php
+++ b/module/personnel/view/addwhitelist.html.php
@@ -13,18 +13,23 @@
+
-
- personnel->addWhitelist;?>
-
|