* refactor task method for project module.
This commit is contained in:
@@ -160,65 +160,12 @@ class project extends control
|
||||
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$tasks = array();
|
||||
if($status == 'byProduct')
|
||||
{
|
||||
$modules = $this->tree->getProjectModule($projectID, $productID);
|
||||
$tasks = $this->task->getTasksByModule($projectID, $modules, $sort, $pager);
|
||||
}
|
||||
elseif($status == 'byModule')
|
||||
{
|
||||
$tasks = $this->task->getTasksByModule($projectID, $this->tree->getAllChildID($moduleID), $sort, $pager);
|
||||
}
|
||||
elseif($browseType != "bysearch")
|
||||
{
|
||||
$qureyStatus = $status == 'byProject' ? 'all' : $status;
|
||||
if($qureyStatus == 'unclosed')
|
||||
{
|
||||
$qureyStatus = $this->lang->task->statusList;
|
||||
unset($qureyStatus['closed']);
|
||||
$qureyStatus = array_keys($qureyStatus);
|
||||
}
|
||||
$tasks = $this->task->getProjectTasks($projectID, $qureyStatus, $sort, $pager);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->search->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('taskQuery', $query->sql);
|
||||
$this->session->set('taskForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('taskQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->taskQuery == false) $this->session->set('taskQuery', ' 1 = 1');
|
||||
}
|
||||
|
||||
/* Limit current project when no project. */
|
||||
if(strpos($this->session->taskQuery, "`project` =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND `project` = $projectID");
|
||||
if(strpos($this->session->taskQuery, "deleted =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND deleted = '0'");
|
||||
|
||||
$projectQuery = "`project`" . helper::dbIN(array_keys($this->projects));
|
||||
$taskQuery = str_replace("`project` = 'all'", $projectQuery, $this->session->taskQuery); // Search all project.
|
||||
$this->session->set('taskQueryCondition', $taskQuery);
|
||||
$this->session->set('taskOnlyCondition', true);
|
||||
$this->session->set('taskOrderBy', $sort);
|
||||
|
||||
$tasks = $this->project->getSearchTasks($taskQuery, $pager, $sort);
|
||||
}
|
||||
/* Get tasks. */
|
||||
$tasks = $this->project->getTasks($productID, $projectID, $this->projects, $status, $browseType, $queryID, $moduleID, $sort, $pager);
|
||||
|
||||
/* Build the search form. */
|
||||
$this->config->project->search['actionURL'] = $this->createLink('project', 'task', "projectID=$projectID&status=bySearch¶m=myQueryID");
|
||||
$this->config->project->search['queryID'] = $queryID;
|
||||
$this->config->project->search['params']['project']['values'] = array(''=>'', $projectID => $this->projects[$projectID], 'all' => $this->lang->project->allProject);
|
||||
$this->config->project->search['params']['module']['values'] = $this->tree->getTaskOptionMenu($projectID, $startModuleID = 0);
|
||||
$actionURL = $this->createLink('project', 'task', "projectID=$projectID&status=bySearch¶m=myQueryID");
|
||||
$this->project->buildSearchForm($projectID, $this->projects, $queryID, $actionURL);
|
||||
$this->search->setSearchParams($this->config->project->search);
|
||||
|
||||
/* team member pairs. */
|
||||
|
||||
@@ -726,6 +726,84 @@ class projectModel extends model
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tasks.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $projectID
|
||||
* @param array $projects
|
||||
* @param string $status
|
||||
* @param string $browseType
|
||||
* @param int $queryID
|
||||
* @param int $moduleID
|
||||
* @param string $sort
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTasks($productID, $projectID, $projects, $status, $browseType, $queryID, $moduleID, $sort, $pager)
|
||||
{
|
||||
$this->loadModel('task');
|
||||
|
||||
/* Get tasks. */
|
||||
if($status == 'byProduct')
|
||||
{
|
||||
$modules = $this->loadModel('tree')->getProjectModule($projectID, $productID);
|
||||
$tasks = $this->task->getTasksByModule($projectID, $modules, $sort, $pager);
|
||||
}
|
||||
elseif($status == 'byModule')
|
||||
{
|
||||
$tasks = $this->task->getTasksByModule($projectID, $this->loadModel('tree')->getAllChildID($moduleID), $sort, $pager);
|
||||
}
|
||||
elseif($browseType != "bysearch")
|
||||
{
|
||||
$qureyStatus = $status == 'byProject' ? 'all' : $status;
|
||||
if($qureyStatus == 'unclosed')
|
||||
{
|
||||
$qureyStatus = $this->lang->task->statusList;
|
||||
unset($qureyStatus['closed']);
|
||||
$qureyStatus = array_keys($qureyStatus);
|
||||
}
|
||||
$tasks = $this->task->getProjectTasks($projectID, $qureyStatus, $sort, $pager);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('taskQuery', $query->sql);
|
||||
$this->session->set('taskForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('taskQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->taskQuery == false) $this->session->set('taskQuery', ' 1 = 1');
|
||||
}
|
||||
|
||||
/* Limit current project when no project. */
|
||||
if(strpos($this->session->taskQuery, "`project` =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND `project` = $projectID");
|
||||
if(strpos($this->session->taskQuery, "deleted =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND deleted = '0'");
|
||||
|
||||
$projectQuery = "`project`" . helper::dbIN(array_keys($projects));
|
||||
$taskQuery = str_replace("`project` = 'all'", $projectQuery, $this->session->taskQuery); // Search all project.
|
||||
$this->session->set('taskQueryCondition', $taskQuery);
|
||||
$this->session->set('taskOnlyCondition', true);
|
||||
$this->session->set('taskOrderBy', $sort);
|
||||
|
||||
$tasks = $this->getSearchTasks($taskQuery, $pager, $sort);
|
||||
}
|
||||
|
||||
if($tasks) return $tasks;
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project by id.
|
||||
*
|
||||
@@ -1679,4 +1757,22 @@ class projectModel extends model
|
||||
->where('project')->eq($projectID)
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build search form.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param array $projects
|
||||
* @param int $queryID
|
||||
* @param string $actionURL
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildSearchForm($projectID, $projects, $queryID, $actionURL)
|
||||
{
|
||||
$this->config->project->search['actionURL'] = $actionURL;
|
||||
$this->config->project->search['queryID'] = $queryID;
|
||||
$this->config->project->search['params']['project']['values'] = array(''=>'', $projectID => $projects[$projectID], 'all' => $this->lang->project->allProject);
|
||||
$this->config->project->search['params']['module']['values'] = $this->loadModel('tree')->getTaskOptionMenu($projectID, $startModuleID = 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ class testcaseModel extends model
|
||||
* @param int $queryID
|
||||
* @param int $moduleID
|
||||
* @param int $sort
|
||||
* @param int $pager
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user