diff --git a/module/bug/control.php b/module/bug/control.php
index 3b46381c51..c103fdc20e 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -349,7 +349,7 @@ class bug extends control
$productName = $this->products[$productID];
/* Get the previous and next bug. */
- $tmpBugIDs = $this->dao->select('id')->from(TABLE_BUG)->where($this->session->storyReport)->fetchPairs('id');
+ $tmpBugIDs = $this->dao->select('id')->from(TABLE_BUG)->where($this->session->bugReport)->fetchPairs('id');
$bugIDs = ',' . implode(',', $tmpBugIDs) . ',';
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugIDs, $bugID);
diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php
index eeff8135e6..5998f553d2 100644
--- a/module/bug/view/view.html.php
+++ b/module/bug/view/view.html.php
@@ -43,11 +43,11 @@
echo html::a($browseLink, $lang->goback);
if($preAndNext->pre)
{
- echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}"), '<') . " ";
+ echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}"), '<') . " ";
}
if($preAndNext->next)
{
- echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}"), '>') . "";
+ echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}"), '>') . "";
}
?>
diff --git a/module/release/control.php b/module/release/control.php
index 95e3dc4145..c42d7c9b85 100644
--- a/module/release/control.php
+++ b/module/release/control.php
@@ -131,6 +131,7 @@ class release extends control
$release = $this->release->getById((int)$releaseID, true);
if(!$release) die(js::error($this->lang->notFound) . js::locate('back'));
$stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($release->stories)->fetchAll();
+ $this->story->saveQueryCondition($this->dao->get());
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->bugs)->fetchAll();
$this->commonAction($release->product);
diff --git a/module/story/control.php b/module/story/control.php
index 1681b7eafa..20e7bd7358 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -368,7 +368,12 @@ class story extends control
$this->product->setMenu($this->product->getPairs(), $product->id);
/* Get the previous and next story. */
- $tmpStoryIDs = $this->dao->select('id')->from(TABLE_STORY)->where($this->session->storyReport)->fetchPairs('id');
+ $stories = $this->dao->select('*')->from(TABLE_STORY)
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
+ ->beginIF($this->session->storyOrderBy != false)->orderBy($this->session->storyOrderBy)->fi()
+ ->fetchAll();
+ $tmpStoryIDs = array();
+ foreach($stories as $tmpStory) $tmpStoryIDs[$tmpStory->id] = $tmpStory->id;
$storyIDs = ',' . implode(',', $tmpStoryIDs) . ',';
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('story', $storyIDs, $storyID);
@@ -534,7 +539,7 @@ class story extends control
{
/* Set menu. */
$this->product->setMenu($this->product->getPairs('nodeleted'), $productID);
- $allStories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyReport)->orderBy($orderBy)->fetchAll('id');
+ $allStories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->orderBy($orderBy)->fetchAll('id');
}
else
{
@@ -775,7 +780,7 @@ class story extends control
}
/* Get stories. */
- $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyReport)->orderBy($orderBy)->fetchAll('id');
+ $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->orderBy($orderBy)->fetchAll('id', false);
/* Get users, products and projects. */
$users = $this->loadModel('user')->getPairs('noletter');
diff --git a/module/story/model.php b/module/story/model.php
index f5787d5ec2..9fe8927f0e 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -635,7 +635,7 @@ class storyModel extends model
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
- $this->saveReportQuery($this->dao->get());
+ $this->saveQueryCondition($this->dao->get());
return $stories;
}
@@ -763,7 +763,7 @@ class storyModel extends model
->orderBy($orderBy)
->page($pager)
->fetchAll();
- $this->saveReportQuery($this->dao->get());
+ $this->saveQueryCondition($this->dao->get());
return $stories;
}
@@ -830,7 +830,7 @@ class storyModel extends model
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
- $this->saveReportQuery($this->dao->get());
+ $this->saveQueryCondition($this->dao->get());
if(!$tmpStories) return array();
@@ -850,18 +850,32 @@ class storyModel extends model
}
/**
- * Save one executed query as report query, thus when create report chart to make use the condition is the same.
+ * Save one executed query.
*
* @param string $sql
* @access public
* @return void
*/
- public function saveReportQuery($sql)
+ public function saveQueryCondition($sql)
{
- $sql = explode('WHERE', $sql);
- $sql = explode('ORDER', $sql[1]);
- $sql = str_replace('t1.', '', $sql[0]);
- $this->session->set('storyReport', $sql);
+ /* Set the query condition session. */
+ $queryCondition = explode('WHERE', $sql);
+ $queryCondition = explode('ORDER', $queryCondition[1]);
+ $queryCondition = str_replace('t1.', '', $queryCondition[0]);
+ $this->session->set('storyQueryCondition', $queryCondition);
+
+ /* Set the query condition session. */
+ $orderBy = explode('ORDER BY', $sql);
+ if(isset($orderBy[1]))
+ {
+ $orderBy = explode('limit', $orderBy[1]);
+ $orderBy = str_replace('t1.', '', $orderBy[0]);
+ $this->session->set('storyOrderBy', $orderBy);
+ }
+ else
+ {
+ $this->session->set('storyOrderBy', '');
+ }
}
/**
@@ -874,12 +888,13 @@ class storyModel extends model
*/
public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc')
{
- return $this->dao->select('t1.*, t2.*')->from(TABLE_PROJECTSTORY)->alias('t1')
+ $stories = $this->dao->select('t1.*, t2.*')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->where('t1.project')->eq((int)$projectID)
->andWhere('t2.deleted')->eq(0)
->orderBy($orderBy)
->fetchAll('id');
+ return $stories;
}
/**
@@ -918,11 +933,15 @@ class storyModel extends model
*/
public function getPlanStories($planID, $status = 'all', $orderBy = 'id_desc', $pager = null)
{
- return $this->dao->select('*')->from(TABLE_STORY)
+ $stories = $this->dao->select('*')->from(TABLE_STORY)
->where('plan')->eq((int)$planID)
->beginIF($status != 'all')->andWhere('status')->in($status)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll('id');
+
+ $this->saveQueryCondition($this->dao->get());
+
+ return $stories;
}
/**
@@ -957,7 +976,7 @@ class storyModel extends model
public function getUserStories($account, $type = 'assignedto', $orderBy = 'id_desc', $pager = null)
{
$type = strtolower($type);
- return $this->dao->select('t1.*, t2.title as planTitle, t3.name as productTitle')
+ $stories = $this->dao->select('t1.*, t2.title as planTitle, t3.name as productTitle')
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id')
@@ -967,6 +986,10 @@ class storyModel extends model
->beginIF($type == 'reviewedby')->andWhere('reviewedby')->like('%' . $this->app->user->account . '%')->fi()
->beginIF($type == 'closedby')->andWhere('closedby')->eq($this->app->user->account)->fi()
->orderBy($orderBy)->page($pager)->fetchAll();
+
+ $this->saveQueryCondition($this->dao->get());
+
+ return $stories;
}
/**
@@ -1097,7 +1120,7 @@ class storyModel extends model
public function getDataOfStorysPerProduct()
{
$datas = $this->dao->select('product as name, count(product) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('product')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$products = $this->loadModel('product')->getPairs();
@@ -1114,7 +1137,7 @@ class storyModel extends model
public function getDataOfStorysPerModule()
{
$datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('module')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$modules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(array_keys($datas))->fetchPairs();
@@ -1131,7 +1154,7 @@ class storyModel extends model
public function getDataOfStorysPerSource()
{
$datas = $this->dao->select('source as name, count(source) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('source')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$this->lang->story->sourceList[''] = $this->lang->report->undefined;
@@ -1148,7 +1171,7 @@ class storyModel extends model
public function getDataOfStorysPerPlan()
{
$datas = $this->dao->select('plan as name, count(plan) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('plan')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$plans = $this->dao->select('id, title')->from(TABLE_PRODUCTPLAN)->where('id')->in(array_keys($datas))->fetchPairs();
@@ -1165,7 +1188,7 @@ class storyModel extends model
public function getDataOfStorysPerStatus()
{
$datas = $this->dao->select('status as name, count(status) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('status')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $status => $data) if(isset($this->lang->story->statusList[$status])) $data->name = $this->lang->story->statusList[$status];
@@ -1181,7 +1204,7 @@ class storyModel extends model
public function getDataOfStorysPerStage()
{
$datas = $this->dao->select('stage as name, count(stage) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('stage')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $stage => $data) $data->name = $this->lang->story->stageList[$stage] != '' ? $this->lang->story->stageList[$stage] : $this->lang->report->undefined;
@@ -1197,7 +1220,7 @@ class storyModel extends model
public function getDataOfStorysPerPri()
{
$datas = $this->dao->select('pri as name, count(pri) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('pri')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $pri => $data) $data->name = $this->lang->story->priList[$pri] != '' ? $this->lang->story->priList[$pri] : $this->lang->report->undefined;
@@ -1213,7 +1236,7 @@ class storyModel extends model
public function getDataOfStorysPerEstimate()
{
return $this->dao->select('estimate as name, count(estimate) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('estimate')->orderBy('value')->fetchAll();
}
@@ -1226,7 +1249,7 @@ class storyModel extends model
public function getDataOfStorysPerOpenedBy()
{
$datas = $this->dao->select('openedBy as name, count(openedBy) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('openedBy')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
if(!isset($this->users)) $this->users = $this->loadModel('user')->getPairs('noletter');
@@ -1243,7 +1266,7 @@ class storyModel extends model
public function getDataOfStorysPerAssignedTo()
{
$datas = $this->dao->select('assignedTo as name, count(assignedTo) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('assignedTo')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
if(!isset($this->users)) $this->users = $this->loadModel('user')->getPairs('noletter');
@@ -1260,7 +1283,7 @@ class storyModel extends model
public function getDataOfStorysPerClosedReason()
{
$datas = $this->dao->select('closedReason as name, count(closedReason) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('closedReason')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $reason => $data) $data->name = $this->lang->story->reasonList[$reason] != '' ? $this->lang->story->reasonList[$reason] : $this->lang->report->undefined;
@@ -1276,7 +1299,7 @@ class storyModel extends model
public function getDataOfStorysPerChange()
{
return $this->dao->select('(version-1) as name, count(*) as value')->from(TABLE_STORY)
- ->beginIF($this->session->storyReport != false)->where($this->session->storyReport)->fi()
+ ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi()
->groupBy('version')->orderBy('value')->fetchAll();
}
}
diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php
index 26c1cdfb2e..f5e3638884 100644
--- a/module/story/view/view.html.php
+++ b/module/story/view/view.html.php
@@ -31,11 +31,11 @@
echo html::a($browseLink, $lang->goback);
if($preAndNext->pre)
{
- echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . " ";
+ echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . " ";
}
if($preAndNext->next)
{
- echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . "";
+ echo "next->id}{$lang->colon}{$preAndNext->next->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . "";
}
?>
diff --git a/module/task/control.php b/module/task/control.php
index 75bd03488b..5216949d49 100644
--- a/module/task/control.php
+++ b/module/task/control.php
@@ -344,9 +344,19 @@ class task extends control
$this->project->setMenu($this->project->getPairs(), $project->id);
/* Get the previous and next task. */
- $tmpTaskIDs = $this->dao->select('id')->from(TABLE_TASK)->alias('t1')->where($this->session->taskReportCondition)->fetchPairs('id');
- $taskIDs = ',' . implode(',', $tmpTaskIDs) . ',';
- $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('task', $taskIDs, $taskID);
+ if($this->session->taskReportCondition)
+ {
+ $tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskReportCondition)->orderBy($this->session->taskOrderBy)->fetchAll();
+ $tmpTaskIDs = array();
+ foreach($tasks as $tmpTask) $tmpTaskIDs[$tmpTask->id] = $tmpTask->id;
+ $taskIDs = ',' . implode(',', $tmpTaskIDs) . ',';
+ $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('task', $taskIDs, $taskID);
+ }
+ else
+ {
+ $this->view->preAndNext->pre = '';
+ $this->view->preAndNext->next = '';
+ }
$header['title'] = $project->name . $this->lang->colon . $this->lang->task->view;
$position[] = html::a($this->createLink('project', 'browse', "projectID=$task->project"), $project->name);
diff --git a/module/task/model.php b/module/task/model.php
index 235f5c5948..41b32372d8 100644
--- a/module/task/model.php
+++ b/module/task/model.php
@@ -537,6 +537,8 @@ class taskModel extends model
*/
public function getProjectTasks($projectID, $type = 'all', $orderBy = 'status_asc, id_desc', $pager = null)
{
+ $this->session->set('taskOrderBy', $orderBy);
+
$orderBy = str_replace('status', 'statusCustom', $orderBy);
$type = strtolower($type);
$tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')
diff --git a/module/task/view/view.html.php b/module/task/view/view.html.php
index 3a4cbbc391..bd435d581e 100644
--- a/module/task/view/view.html.php
+++ b/module/task/view/view.html.php
@@ -36,11 +36,11 @@
echo html::a($browseLink, $lang->goback);
if($preAndNext->pre)
{
- echo "" . html::a($this->inLink('view', "taskID={$preAndNext->pre->id}"), '<') . " ";
+ echo "" . html::a($this->inLink('view', "taskID={$preAndNext->pre->id}"), '<') . " ";
}
if($preAndNext->next)
{
- echo "next->id}{$lang->colon}{$preAndNext->pre->name}>" . html::a($this->inLink('view', "taskID={$preAndNext->next->id}"), '>') . "";
+ echo "next->id}{$lang->colon}{$preAndNext->pre->name}>" . html::a($this->inLink('view', "taskID={$preAndNext->next->id}"), '>') . "";
}
?>
diff --git a/module/testcase/control.php b/module/testcase/control.php
index f18a6df7a2..cd6191edd9 100644
--- a/module/testcase/control.php
+++ b/module/testcase/control.php
@@ -321,9 +321,19 @@ class testcase extends control
$this->testcase->setMenu($this->products, $productID);
/* Get the previous and next testcase. */
- $tmpCaseIDs = $this->dao->select('id')->from(TABLE_CASE)->where($this->session->testcaseReport)->fetchPairs('id');
- $caseIDs = ',' . implode(',', $tmpCaseIDs) . ',';
- $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('case', $caseIDs, $caseID);
+ if($this->session->testcaseReport)
+ {
+ $cases = $this->dao->select('id')->from(TABLE_CASE)->where($this->session->testcaseReport)->fetchAll();
+ $tmpCaseIDs = array();
+ foreach($cases as $tmpCase) $tmpCaseIDs[$tmpCase->id] = $tmpCase->id;
+ $caseIDs = ',' . implode(',', $tmpCaseIDs) . ',';
+ $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('case', $caseIDs, $caseID);
+ }
+ else
+ {
+ $this->view->preAndNext->pre = '';
+ $this->view->preAndNext->next = '';
+ }
$this->view->header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->view;
$this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]);
diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php
index df45ed4d1b..039bdda6b5 100644
--- a/module/testcase/view/view.html.php
+++ b/module/testcase/view/view.html.php
@@ -30,11 +30,11 @@
echo html::a($browseLink, $lang->goback);
if($preAndNext->pre)
{
- echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . " ";
+ echo "" . html::a($this->inLink('view', "storyID={$preAndNext->pre->id}&version={$preAndNext->pre->version}"), '<') . " ";
}
if($preAndNext->next)
{
- echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . "";
+ echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . "";
}
?>