* Divide program/project/execution.
This commit is contained in:
+44
-44
@@ -57,7 +57,7 @@ class program extends control
|
||||
}
|
||||
else
|
||||
{
|
||||
$programs = $this->program->getPGMList($status, $orderBy, null, true);
|
||||
$programs = $this->program->getList($status, $orderBy, null, true);
|
||||
}
|
||||
|
||||
/* Get PM id list. */
|
||||
@@ -95,15 +95,15 @@ class program extends control
|
||||
*/
|
||||
public function product($programID = 0, $browseType = 'noclosed', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$programID = $this->program->savePGMState($programID, $this->program->getPGMPairs());
|
||||
setCookie("lastPGM", $programID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
|
||||
$programID = $this->program->saveState($programID, $this->program->getPairs());
|
||||
setCookie("lastProgram", $programID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
|
||||
|
||||
$program = $this->program->getPGMByID($programID);
|
||||
$program = $this->program->getByID($programID);
|
||||
if(empty($program) || $program->type != 'program') die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
|
||||
$this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getPGMMainAction();
|
||||
$this->program->setPGMViewMenu($programID);
|
||||
$this->lang->program->switcherMenu = $this->program->getSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getMainAction();
|
||||
$this->program->setViewMenu($programID);
|
||||
|
||||
/* Load pager and get tasks. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -138,7 +138,7 @@ class program extends control
|
||||
*/
|
||||
public function create($parentProgramID = 0)
|
||||
{
|
||||
$parentProgram = $this->program->getPGMByID($parentProgramID);
|
||||
$parentProgram = $this->program->getByID($parentProgramID);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ class program extends control
|
||||
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
|
||||
$this->view->parentProgram = $parentProgram;
|
||||
$this->view->parents = $this->program->getParentPairs();
|
||||
$this->view->programList = $this->program->getPGMList();
|
||||
$this->view->programList = $this->program->getList();
|
||||
$this->view->budgetUnitList = $this->project->getBudgetUnitList();
|
||||
$this->view->availableBudget = $this->program->getAvailableBudget($parentProgram);
|
||||
|
||||
@@ -186,8 +186,8 @@ class program extends control
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browse')));
|
||||
}
|
||||
|
||||
$program = $this->program->getPGMByID($programID);
|
||||
$parentProgram = $program->parent ? $this->program->getPGMByID($program->parent) : '';
|
||||
$program = $this->program->getByID($programID);
|
||||
$parentProgram = $program->parent ? $this->program->getByID($program->parent) : '';
|
||||
$parents = $this->program->getParentPairs();
|
||||
unset($parents[$programID]);
|
||||
|
||||
@@ -199,7 +199,7 @@ class program extends control
|
||||
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
|
||||
$this->view->program = $program;
|
||||
$this->view->parents = $parents;
|
||||
$this->view->programList = $this->program->getPGMList();
|
||||
$this->view->programList = $this->program->getList();
|
||||
$this->view->budgetUnitList = $this->program->getBudgetUnitList();
|
||||
$this->view->parentProgram = $parentProgram;
|
||||
$this->view->availableBudget = $this->program->getAvailableBudget($parentProgram) + (float)$program->budget;
|
||||
@@ -217,13 +217,13 @@ class program extends control
|
||||
public function close($programID)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$program = $this->program->getPGMByID($programID);
|
||||
$program = $this->program->getByID($programID);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
/* Only when all subprograms and subprojects are closed can the program be closed. */
|
||||
$hasUnfinished = $this->program->hasUnfinished($program);
|
||||
if($hasUnfinished) die(js::error($this->lang->program->PGMCloseErrorMessage));
|
||||
if($hasUnfinished) die(js::error($this->lang->program->closeErrorMessage));
|
||||
|
||||
$changes = $this->project->close($programID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
@@ -238,8 +238,8 @@ class program extends control
|
||||
die(js::reload('parent.parent'));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->program->PGMClose;
|
||||
$this->view->position[] = $this->lang->program->PGMClose;
|
||||
$this->view->title = $this->lang->program->close;
|
||||
$this->view->position[] = $this->lang->program->close;
|
||||
$this->view->project = $program;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->action->getList('program', $programID);
|
||||
@@ -274,7 +274,7 @@ class program extends control
|
||||
|
||||
$this->view->title = $this->lang->project->start;
|
||||
$this->view->position[] = $this->lang->project->start;
|
||||
$this->view->program = $this->program->getPGMByID($programID);
|
||||
$this->view->program = $this->program->getByID($programID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->action->getList('program', $programID);
|
||||
$this->display();
|
||||
@@ -290,7 +290,7 @@ class program extends control
|
||||
public function activate($programID = 0)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$program = $this->program->getPGMByID($programID);
|
||||
$program = $this->program->getByID($programID);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
@@ -309,8 +309,8 @@ class program extends control
|
||||
$dateDiff = helper::diffDate($newBegin, $program->begin);
|
||||
$newEnd = date('Y-m-d', strtotime($program->end) + $dateDiff * 24 * 3600);
|
||||
|
||||
$this->view->title = $this->lang->program->PGMActivate;
|
||||
$this->view->position[] = $this->lang->program->PGMActivate;
|
||||
$this->view->title = $this->lang->program->activate;
|
||||
$this->view->position[] = $this->lang->program->activate;
|
||||
$this->view->program = $program;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->action->getList('program', $programID);
|
||||
@@ -348,7 +348,7 @@ class program extends control
|
||||
$this->view->position[] = $this->lang->project->suspend;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->action->getList('program', $programID);
|
||||
$this->view->project = $this->program->getPGMByID($programID);
|
||||
$this->view->project = $this->program->getByID($programID);
|
||||
|
||||
$this->display('project', 'suspend');
|
||||
}
|
||||
@@ -367,7 +367,7 @@ class program extends control
|
||||
if($childrenCount) die(js::alert($this->lang->program->hasChildren));
|
||||
|
||||
$program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch();
|
||||
if($confirm == 'no') die(js::confirm($this->lang->program->confirmDelete, $this->createLink('program', 'PGMDelete', "programID=$programID&confirm=yes")));
|
||||
if($confirm == 'no') die(js::confirm($this->lang->program->confirmDelete, $this->createLink('program', 'delete', "programID=$programID&confirm=yes")));
|
||||
|
||||
$this->dao->update(TABLE_PROGRAM)->set('deleted')->eq(1)->where('id')->eq($programID)->exec();
|
||||
$this->loadModel('action')->create('program', $programID, 'deleted', '', $extra = ACTIONMODEL::CAN_UNDELETED);
|
||||
@@ -389,16 +389,16 @@ class program extends control
|
||||
*/
|
||||
public function project($programID = 0, $browseType = 'doing', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$programID = $this->program->savePGMState($programID, $this->program->getPGMPairs());
|
||||
$programID = $this->program->saveState($programID, $this->program->getPairs());
|
||||
if(!$programID) $this->locate($this->createLink('program', 'browse'));
|
||||
setCookie("lastPGM", $programID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
|
||||
setCookie("lastProgram", $programID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
|
||||
|
||||
$this->app->session->set('PGMProject', $this->app->getURI(true));
|
||||
$this->app->session->set('programProject', $this->app->getURI(true));
|
||||
$this->app->session->set('projectList', $this->app->getURI(true));
|
||||
|
||||
$this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getPGMMainAction();
|
||||
$this->program->setPGMViewMenu($programID);
|
||||
$this->lang->program->switcherMenu = $this->program->getSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getMainAction();
|
||||
$this->program->setViewMenu($programID);
|
||||
|
||||
$this->loadModel('datatable');
|
||||
|
||||
@@ -406,10 +406,10 @@ class program extends control
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$programTitle = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=program&key=PRJProgramTitle');
|
||||
$programTitle = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=program&key=programTitle');
|
||||
$order = explode('_', $orderBy);
|
||||
$sortField = zget($this->config->program->sortFields, $order[0], 'id') . '_' . $order[1];
|
||||
$projectStats = $this->program->getPRJStats($programID, $browseType, 0, $sortField, $pager, $programTitle);
|
||||
$projectStats = $this->program->getProjectStats($programID, $browseType, 0, $sortField, $pager, $programTitle);
|
||||
|
||||
$this->view->title = $this->lang->program->project;
|
||||
$this->view->position[] = $this->lang->program->project;
|
||||
@@ -417,7 +417,7 @@ class program extends control
|
||||
$this->view->projectStats = $projectStats;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->programID = $programID;
|
||||
$this->view->program = $this->program->getPRJByID($programID);
|
||||
$this->view->program = $this->program->getByID($programID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|pofirst|nodeleted');
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->orderBy = $orderBy;
|
||||
@@ -438,9 +438,9 @@ class program extends control
|
||||
*/
|
||||
public function stakeholder($programID = 0, $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getPGMMainAction();
|
||||
$this->program->setPGMViewMenu($programID);
|
||||
$this->lang->program->switcherMenu = $this->program->getSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getMainAction();
|
||||
$this->program->setViewMenu($programID);
|
||||
|
||||
/* Load pager and get tasks. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -452,7 +452,7 @@ class program extends control
|
||||
$this->view->stakeholders = $this->program->getStakeholders($programID, $orderBy, $pager);
|
||||
$this->view->pager = $pager;
|
||||
$this->view->programID = $programID;
|
||||
$this->view->program = $this->program->getPRJByID($programID);
|
||||
$this->view->program = $this->program->getByID($programID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|pofirst|nodeleted');
|
||||
$this->view->orderBy = $orderBy;
|
||||
|
||||
@@ -475,9 +475,9 @@ class program extends control
|
||||
}
|
||||
|
||||
$this->loadModel('user');
|
||||
$this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getPGMMainAction();
|
||||
$this->program->setPGMViewMenu($programID);
|
||||
$this->lang->program->switcherMenu = $this->program->getSwitcher($programID, true);
|
||||
$this->lang->program->mainMenuAction = $this->program->getMainAction();
|
||||
$this->program->setViewMenu($programID);
|
||||
|
||||
$this->loadModel('dept');
|
||||
$deptUsers = $dept === '' ? array() : $this->dept->getDeptUserPairs($dept);
|
||||
@@ -486,13 +486,13 @@ class program extends control
|
||||
$this->view->position[] = $this->lang->program->createStakeholder;
|
||||
|
||||
$this->view->programID = $programID;
|
||||
$this->view->program = $this->program->getPGMByID($programID);
|
||||
$this->view->program = $this->program->getByID($programID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed');
|
||||
$this->view->deptUsers = $deptUsers;
|
||||
$this->view->dept = $dept;
|
||||
$this->view->depts = array('' => '') + $this->dept->getOptionMenu();
|
||||
$this->view->stakeholders = $this->program->getStakeholders($programID, 't1.id_desc');
|
||||
$this->view->parentStakeholders = $this->program->getStakeholdersByPGMList($parentIdList);
|
||||
$this->view->parentStakeholders = $this->program->getStakeholdersByList($parentIdList);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -638,7 +638,7 @@ class program extends control
|
||||
$this->view->programID = $programID;
|
||||
$this->view->module = $module;
|
||||
$this->view->method = $method;
|
||||
$this->view->programs = $this->program->getPGMList('all');
|
||||
$this->view->programs = $this->program->getList('all');
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ class program extends control
|
||||
*/
|
||||
public function ajaxGetAvailableBudget($parentProgramID)
|
||||
{
|
||||
$parentProgram = $this->program->getPGMByID($parentProgramID);
|
||||
$parentProgram = $this->program->getByID($parentProgramID);
|
||||
$availableBudget = $this->program->getAvailableBudget($parentProgram);
|
||||
echo number_format($availableBudget, 2);
|
||||
}
|
||||
@@ -723,9 +723,9 @@ class program extends control
|
||||
*/
|
||||
public function view($programID)
|
||||
{
|
||||
$program = $this->program->getPGMByID($programID);
|
||||
$program = $this->program->getByID($programID);
|
||||
if(!$program) die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
|
||||
echo $this->fetch('program', 'PGMProduct', "programID=$programID");
|
||||
echo $this->fetch('program', 'product', "programID=$programID");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,106 @@ class programModel extends model
|
||||
->andWhere('deleted')->eq(0)
|
||||
->beginIF(!$this->app->user->admin)
|
||||
->andWhere('id')->in($this->app->user->view->programs)
|
||||
->orWhere('id')->in($this->app->user->view->projects)
|
||||
->fi()
|
||||
->beginIF($status != 'all')->andWhere('status')->eq($status)->fi()
|
||||
->beginIF(!$this->cookie->showClosed)->andWhere('status')->ne('closed')->fi()
|
||||
->orWhere('id')->in($this->app->user->view->projects)
|
||||
->fi()
|
||||
->beginIF($status != 'all')->andWhere('status')->eq($status)->fi()
|
||||
->beginIF(!$this->cookie->showClosed)->andWhere('status')->ne('closed')->fi()
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project list data.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $browseType
|
||||
* @param string $queryID
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @param int $programTitle
|
||||
* @param int $PRJMine
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getProjectList($programID = 0, $browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $PRJMine = 0)
|
||||
{
|
||||
$path = '';
|
||||
if($programID)
|
||||
{
|
||||
$program = $this->getByID($programID);
|
||||
$path = $program->path;
|
||||
}
|
||||
|
||||
$projectList = $this->dao->select('*')->from(TABLE_PROJECT)
|
||||
->where('deleted')->eq('0')
|
||||
->beginIF($this->config->systemMode == 'new')->andWhere('type')->eq('project')->fi()
|
||||
->beginIF($browseType != 'all')->andWhere('status')->eq($browseType)->fi()
|
||||
->beginIF($path)->andWhere('path')->like($path . '%')->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->systemMode == 'new')->andWhere('id')->in($this->app->user->view->projects)->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->systemMode == 'classic')->andWhere('id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($this->cookie->PRJMine or $PRJMine)
|
||||
->andWhere('openedBy', true)->eq($this->app->user->account)
|
||||
->orWhere('PM')->eq($this->app->user->account)
|
||||
->markRight(1)
|
||||
->fi()
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
|
||||
/* Determine how to display the name of the program. */
|
||||
if($programTitle and $this->config->systemMode == 'new')
|
||||
{
|
||||
$programList = $this->getPairs();
|
||||
foreach($projectList as $id => $project)
|
||||
{
|
||||
$path = explode(',', $project->path);
|
||||
$path = array_filter($path);
|
||||
array_pop($path);
|
||||
$programID = $programTitle == 'base' ? current($path) : end($path);
|
||||
if(empty($path) || $programID == $id) continue;
|
||||
|
||||
$programName = isset($programList[$programID]) ? $programList[$programID] : '';
|
||||
|
||||
$projectList[$id]->name = $programName . '/' . $projectList[$id]->name;
|
||||
}
|
||||
}
|
||||
return $projectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stakeholders by program id.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $orderBy
|
||||
* @param object $paper
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getStakeholders($programID = 0, $orderBy, $pager = null)
|
||||
{
|
||||
return $this->dao->select('t2.account,t2.realname,t2.role,t2.qq,t2.mobile,t2.phone,t2.weixin,t2.email,t1.id,t1.type,t1.key')->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.user=t2.account')
|
||||
->where('t1.objectID')->eq($programID)
|
||||
->andWhere('t1.objectType')->eq('program')
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stakeholders by program id list.
|
||||
*
|
||||
* @param string $programIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getStakeholdersByPrograms($programIdList = 0)
|
||||
{
|
||||
return $this->dao->select('distinct user as account')->from(TABLE_STAKEHOLDER)
|
||||
->where('objectID')->in($programIdList)
|
||||
->andWhere('objectType')->eq('program')
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,7 +806,7 @@ class programModel extends model
|
||||
public function getProjectStats($programID = 0, $browseType = 'undone', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $PRJMine = 0)
|
||||
{
|
||||
/* Init vars. */
|
||||
$projects = $this->getPRJList($programID, $browseType, $queryID, $orderBy, $pager, $programTitle, $PRJMine);
|
||||
$projects = $this->getProjectList($programID, $browseType, $queryID, $orderBy, $pager, $programTitle, $PRJMine);
|
||||
if(empty($projects)) return array();
|
||||
|
||||
$projectKeys = array_keys($projects);
|
||||
|
||||
Reference in New Issue
Block a user