* Adjustment Code.
This commit is contained in:
+11
-11
@@ -40,17 +40,7 @@ class personnelModel extends model
|
||||
|
||||
/* Determine who can be accessed based on access control. */
|
||||
$program = $this->loadModel('program')->getPGMByID($programID);
|
||||
if($program->acl == 'private')
|
||||
{
|
||||
$personnelList = $this->dao->select('t2.id,t2.dept,t2.account,t2.role,t2.realname,t2.gender')->from(TABLE_USERVIEW)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.account=t2.account')
|
||||
->where("CONCAT(',', t1.programs, ',')")->like("%,$programID,%")
|
||||
->beginIF($deptID > 0)->andWhere('t2.dept')->eq($deptID)->fi()
|
||||
->beginIF($browseType == 'bysearch')->andWhere($accessibleQuery)->fi()
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
else
|
||||
if($program->acl == 'open')
|
||||
{
|
||||
/* The program is public, and users are judged to be accessible by permission groups. */
|
||||
$accessibleGroupID = $this->loadModel('group')->getAccessProgramGroup();
|
||||
@@ -65,6 +55,16 @@ class personnelModel extends model
|
||||
->page($pager)
|
||||
->fetchAll('account');
|
||||
}
|
||||
else
|
||||
{
|
||||
$personnelList = $this->dao->select('t2.id,t2.dept,t2.account,t2.role,t2.realname,t2.gender')->from(TABLE_USERVIEW)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.account=t2.account')
|
||||
->where("CONCAT(',', t1.programs, ',')")->like("%,$programID,%")
|
||||
->beginIF($deptID > 0)->andWhere('t2.dept')->eq($deptID)->fi()
|
||||
->beginIF($browseType == 'bysearch')->andWhere($accessibleQuery)->fi()
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
return $personnelList;
|
||||
}
|
||||
|
||||
@@ -28,66 +28,64 @@ class programplan extends control
|
||||
/**
|
||||
* Common action.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $productID
|
||||
* @param string $extra
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function commonAction($programID, $productID = 0, $extra = '')
|
||||
public function commonAction($projectID, $productID = 0, $extra = '')
|
||||
{
|
||||
$products = $this->loadModel('product')->getPairs('', $programID);
|
||||
$products = $this->loadModel('product')->getProductsByProject('', $projectID);
|
||||
$productID = $this->product->saveState($productID, $products);
|
||||
$this->product->setMenu($products, $productID, 0, 0, '', $extra);
|
||||
$this->productID = $productID;
|
||||
$this->programplan->setMenu($programID, $productID);
|
||||
$this->product->setMenu($products, $productID, 0, 0, '', $extra);
|
||||
$this->programplan->setMenu($projectID, $productID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse programplans.
|
||||
* Browse program plans.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $productID
|
||||
* @param string $type
|
||||
* @param string $orderBy
|
||||
* @param int $baselineID
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param string $type
|
||||
* @param string $orderBy
|
||||
* @param int $baselineID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browse($programID = 0, $productID = 0, $type = 'gantt', $orderBy = 'id_asc', $baselineID = 0)
|
||||
public function browse($projectID = 0, $productID = 0, $type = 'gantt', $orderBy = 'id_asc', $baselineID = 0)
|
||||
{
|
||||
$this->app->loadLang('stage');
|
||||
$this->commonAction($programID, $productID, $type);
|
||||
$this->commonAction($projectID, $productID, $type);
|
||||
$this->session->set('programPlanList', $this->app->getURI(true));
|
||||
|
||||
if(common::hasPriv('programplan', 'create')) $this->lang->TRActions = html::a($this->createLink('programplan', 'create', "programID=$programID"), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->programplan->create, '', "class='btn btn-primary'");
|
||||
if(common::hasPriv('programplan', 'create')) $this->lang->TRActions = html::a($this->createLink('programplan', 'create', "projectID=$projectID"), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->programplan->create, '', "class='btn btn-primary'");
|
||||
|
||||
$selectCustom = 0;
|
||||
$dateDetails = 1;
|
||||
$selectCustom = 0; // Display date and task settings.
|
||||
$dateDetails = 1; // Gantt chart detail date display.
|
||||
if($type == 'gantt')
|
||||
{
|
||||
$owner = $this->app->user->account;
|
||||
$module = 'programplan';
|
||||
$section = 'browse';
|
||||
$object = 'stageCustom';
|
||||
$setting = $this->loadModel('setting');
|
||||
$selectCustom = $setting->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
|
||||
$selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
if(strpos($selectCustom, 'date') !== false) $dateDetails = 0;
|
||||
|
||||
$plans = $this->programplan->getDataForGantt($programID, $this->productID, $baselineID);
|
||||
$plans = $this->programplan->getDataForGantt($projectID, $this->productID, $baselineID);
|
||||
}
|
||||
|
||||
if($type == 'lists')
|
||||
{
|
||||
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
||||
$this->loadModel('datatable');
|
||||
$plans = $this->programplan->getPlans($programID, $this->productID, $sort);
|
||||
$plans = $this->programplan->getPlans($projectID, $this->productID, $sort);
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->programplan->browse;
|
||||
$this->view->position[] = $this->lang->programplan->browse;
|
||||
$this->view->programID = $programID;
|
||||
$this->view->programID = $projectID;
|
||||
$this->view->productID = $this->productID;
|
||||
$this->view->type = $type;
|
||||
$this->view->plans = $plans;
|
||||
|
||||
@@ -16,12 +16,12 @@ class programplanModel extends model
|
||||
/**
|
||||
* Set menu.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $productID
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function setMenu($programID, $productID)
|
||||
public function setMenu($projectID, $productID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -49,30 +49,28 @@ class programplanModel extends model
|
||||
*/
|
||||
public function getProjectsByProduct($productID)
|
||||
{
|
||||
$projects = $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->fetchPairs();
|
||||
|
||||
return $projects;
|
||||
return $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plans list.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $productID
|
||||
* @param int $planID
|
||||
* @param string $browseType
|
||||
* @param string $orderBy
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param int $planID
|
||||
* @param string $browseType
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($programID = 0, $productID = 0, $planID = 0, $browseType = 'all', $orderBy = 'id_asc')
|
||||
public function getStage($projectID = 0, $productID = 0, $planID = 0, $browseType = 'all', $orderBy = 'id_asc')
|
||||
{
|
||||
$projects = $this->getProjectsByProduct($productID);
|
||||
|
||||
$plans = $this->dao->select('*')->from(TABLE_PROJECT)
|
||||
->where('type')->eq('stage')
|
||||
->beginIF($browseType == 'all')->andWhere('project')->eq($programID)->fi()
|
||||
->beginIF($browseType == 'parent')->andWhere('parent')->eq($programID)->fi()
|
||||
->beginIF($browseType == 'all')->andWhere('project')->eq($projectID)->fi()
|
||||
->beginIF($browseType == 'parent')->andWhere('parent')->eq($projectID)->fi()
|
||||
->beginIF($browseType == 'children')->andWhere('parent')->eq($planID)->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($productID)->andWhere('id')->in($projects)->fi()
|
||||
@@ -139,7 +137,7 @@ class programplanModel extends model
|
||||
*/
|
||||
public function getPlans($programID = 0, $productID = 0, $orderBy = 'id_asc')
|
||||
{
|
||||
$plans = $this->getList($programID, $productID, 0, 'all', $orderBy);
|
||||
$plans = $this->getStage($programID, $productID, 0, 'all', $orderBy);
|
||||
|
||||
$parents = array();
|
||||
$children = array();
|
||||
@@ -182,19 +180,19 @@ class programplanModel extends model
|
||||
/**
|
||||
* Get gantt data.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $productID
|
||||
* @param int $baselineID
|
||||
* @param string $selectCustom
|
||||
* @param bool $returnJson
|
||||
* @param int $projectID
|
||||
* @param int $productID
|
||||
* @param int $baselineID
|
||||
* @param string $selectCustom
|
||||
* @param bool $returnJson
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDataForGantt($programID, $productID, $baselineID = 0, $selectCustom = '', $returnJson = true)
|
||||
public function getDataForGantt($projectID, $productID, $baselineID = 0, $selectCustom = '', $returnJson = true)
|
||||
{
|
||||
$this->loadModel('stage');
|
||||
|
||||
$plans = $this->getList($programID, $productID, 0, 'all');
|
||||
$plans = $this->getStage($projectID, $productID, 0, 'all');
|
||||
if($baselineID)
|
||||
{
|
||||
$baseline = $this->loadModel('cm')->getByID($baselineID);
|
||||
@@ -251,9 +249,8 @@ class programplanModel extends model
|
||||
$module = 'programplan';
|
||||
$section = 'browse';
|
||||
$object = 'stageCustom';
|
||||
$setting = $this->loadModel('setting');
|
||||
|
||||
if(empty($selectCustom)) $selectCustom = $setting->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
if(empty($selectCustom)) $selectCustom = $this->loadModel('setting')->getItem("owner={$owner}&module={$module}§ion={$section}&key={$object}");
|
||||
|
||||
$tasks = array();
|
||||
if(strpos($selectCustom, 'task') !== false)
|
||||
@@ -333,7 +330,7 @@ class programplanModel extends model
|
||||
*/
|
||||
public function getTotalPercent($plan)
|
||||
{
|
||||
$plans = $this->getList($plan->project, $plan->product, $plan->parent, 'parent');
|
||||
$plans = $this->getStage($plan->project, $plan->product, $plan->parent, 'parent');
|
||||
|
||||
$totalPercent = 0;
|
||||
foreach($plans as $id => $stage)
|
||||
@@ -354,11 +351,7 @@ class programplanModel extends model
|
||||
*/
|
||||
public function processPlans($plans)
|
||||
{
|
||||
foreach($plans as $planID => $plan)
|
||||
{
|
||||
$plans[$planID] = $this->processPlan($plan);
|
||||
}
|
||||
|
||||
foreach($plans as $planID => $plan) $plans[$planID] = $this->processPlan($plan);
|
||||
return $plans;
|
||||
}
|
||||
|
||||
@@ -392,8 +385,8 @@ class programplanModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$plan->begin = $plan->begin == '0000-00-00' ? '' : $plan->begin;
|
||||
$plan->end = $plan->end == '0000-00-00' ? '' : $plan->end;
|
||||
$plan->begin = $plan->begin == '0000-00-00' ? '' : $plan->begin;
|
||||
$plan->end = $plan->end == '0000-00-00' ? '' : $plan->end;
|
||||
$plan->realBegan = $plan->realBegan == '0000-00-00' ? '' : $plan->realBegan;
|
||||
$plan->realEnd = $plan->realEnd == '0000-00-00' ? '' : $plan->realEnd;
|
||||
|
||||
|
||||
+27
-13
@@ -362,7 +362,7 @@ class projectModel extends model
|
||||
$member->root = $projectID;
|
||||
$member->join = $today;
|
||||
$member->days = $sprint->days;
|
||||
$member->type = 'project';
|
||||
$member->type = $sprintType;
|
||||
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
|
||||
if($member->account == $this->app->user->account) $creatorExists = true;
|
||||
}
|
||||
@@ -377,10 +377,12 @@ class projectModel extends model
|
||||
$member->account = $this->app->user->account;
|
||||
$member->role = $this->lang->user->roleList[$this->app->user->role];
|
||||
$member->join = $today;
|
||||
$member->type = 'project';
|
||||
$member->type = $sprintType;
|
||||
$member->days = $sprint->days;
|
||||
$member->hours = $this->config->project->defaultWorkhours;
|
||||
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
|
||||
|
||||
$this->addProjectMembers($this->session->PRJ, array($member));
|
||||
}
|
||||
|
||||
/* Create doc lib. */
|
||||
@@ -1985,7 +1987,7 @@ class projectModel extends model
|
||||
}
|
||||
|
||||
/* Add iteration or phase team members to the project team. */
|
||||
if($projectType == 'stage' || $projectType == 'sprint') $this->addProjectMembers($project->parent, $projectMember);
|
||||
if($projectType == 'stage' || $projectType == 'sprint') $this->addProjectMembers($project->project, $projectMember);
|
||||
|
||||
/* Only changed account update userview. */
|
||||
$oldAccounts = array_keys($oldJoin);
|
||||
@@ -2007,18 +2009,18 @@ class projectModel extends model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function addProjectMembers($projectID, $members = array())
|
||||
public function addProjectMembers($projectID = 0, $members = array())
|
||||
{
|
||||
$project = $this->getByID($projectID);
|
||||
$projectType = $project->type;
|
||||
$oldJoin = $this->dao->select('`account`, `join`')->from(TABLE_TEAM)->where('root')->eq((int)$projectID)->andWhere('type')->eq($projectType)->fetchPairs();
|
||||
$oldJoin = $this->dao->select('`account`, `join`')->from(TABLE_TEAM)->where('root')->eq($projectID)->andWhere('type')->eq($projectType)->fetchPairs();
|
||||
|
||||
$accounts = array();
|
||||
foreach($members as $account => $member)
|
||||
{
|
||||
if(isset($oldJoin[$account])) continue;
|
||||
if(isset($oldJoin[$member->account])) continue;
|
||||
|
||||
$accounts[] = $account;
|
||||
$accounts[] = $member->account;
|
||||
$member->root = $projectID;
|
||||
$member->type = $projectType;
|
||||
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
|
||||
@@ -2039,18 +2041,30 @@ class projectModel extends model
|
||||
/**
|
||||
* Unlink a member.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $sprintID
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function unlinkMember($projectID, $account)
|
||||
public function unlinkMember($sprintID, $account)
|
||||
{
|
||||
$project = $this->getByID($projectID);
|
||||
$this->dao->delete()->from(TABLE_TEAM)->where('root')->eq((int)$projectID)->andWhere('type')->eq($project->type)->andWhere('account')->eq($account)->exec();
|
||||
$sprint = $this->getByID($sprintID);
|
||||
$this->dao->delete()->from(TABLE_TEAM)->where('root')->eq((int)$sprintID)->andWhere('type')->eq($sprint->type)->andWhere('account')->eq($account)->exec();
|
||||
|
||||
$this->loadModel('user')->updateUserView($projectID, $project->type, array($account));
|
||||
$products = $this->getProducts($projectID, false);
|
||||
/* Remove team members from the sprint or stage, and determine whether to remove team members from the project. */
|
||||
if($sprint->type == 'sprint' || $sprint->type == 'stage')
|
||||
{
|
||||
$teamMember = $this->dao->select('t1.id, t2.account')->from(TABLE_PROJECT)->alias('t1')
|
||||
->leftJoin(TABLE_TEAM)->alias('t2')->on('t1.id = t2.root')
|
||||
->where('t1.project')->eq($sprint->project)
|
||||
->andWhere('t1.type')->eq($sprint->type)
|
||||
->andWhere('t2.account')->eq($account)
|
||||
->fetch();
|
||||
if(empty($teamMember)) $this->dao->delete()->from(TABLE_TEAM)->where('root')->eq($sprint->project)->andWhere('type')->eq('project')->andWhere('account')->eq($account)->exec();
|
||||
}
|
||||
|
||||
$this->loadModel('user')->updateUserView($sprintID, $sprint->type, array($account));
|
||||
$products = $this->getProducts($sprintID, false);
|
||||
if($products) $this->user->updateUserView(array_keys($products), 'product', array($account));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user