* adjust productplan for branch.

This commit is contained in:
wangyidong
2015-10-30 16:05:19 +08:00
parent 785c21f04a
commit 7c7117d233
12 changed files with 114 additions and 67 deletions
+3
View File
@@ -23,3 +23,6 @@ CREATE TABLE `zt_storystage` (
`branch` mediumint unsigned NOT NULL,
`stage` varchar(50) COLLATE 'utf8_general_ci' NOT NULL
);
ALTER TABLE `zt_story` ADD INDEX `product` (`product`, `module`, `type`, `pri`), DROP INDEX `product`;
ALTER TABLE `zt_story` ADD `plan` text COLLATE 'utf8_general_ci' NOT NULL AFTER `module`;
UPDATE `zt_story` SET `plan`='' WHERE `plan`='0';
+1 -1
View File
@@ -107,7 +107,7 @@ class bug extends control
elseif($browseType == 'longlifebugs') $bugs = $this->bug->getByLonglifebugs($productID, $branch, $projects, $sort, $pager);
elseif($browseType == 'postponedbugs') $bugs = $this->bug->getByPostponedbugs($productID, $branch, $projects, $sort, $pager);
elseif($browseType == 'needconfirm') $bugs = $this->bug->getByNeedconfirm($productID, $branch, $projects, $sort, $pager);
elseif($browseType == 'bysearch') $bugs = $this->bug->getBySearch($productID, $queryID, $sort, $pager);
elseif($browseType == 'bysearch') $bugs = $this->bug->getBySearch($productID, $queryID, $sort, $pager, $branch);
/* Process the sql, get the conditon partion, save it to session. */
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', $browseType == 'needconfirm' ? false : true);
+10 -8
View File
@@ -305,13 +305,14 @@ class bugModel extends model
* @access public
* @return array
*/
public function getActiveBugs($products, $projectID, $pager = null)
public function getActiveBugs($products, $branch, $projectID, $pager = null)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('status')->eq('active')
->andWhere('toTask')->eq(0)
->andWhere('tostory')->eq(0)
->beginIF(!empty($products))->andWhere('product')->in($products)->fi()
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->beginIF(empty($products))->andWhere('project')->eq($projectID)->fi()
->andWhere('deleted')->eq(0)
->orderBy('id desc')
@@ -861,7 +862,7 @@ class bugModel extends model
* @access public
* @return array
*/
public function getProductLeftBugs($build, $productID)
public function getProductLeftBugs($build, $productID, $branch = 0)
{
$build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($build)->fetch();
if(empty($build->project)) return array();
@@ -883,6 +884,7 @@ class bugModel extends model
->andWhere('openedDate')->le($project->end)
->andWhere("(status = 'active' OR resolvedDate > {$project->end})")
->andWhere('openedBuild')->notin($beforeBuilds)
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->fetchAll();
return $bugs;
@@ -918,18 +920,17 @@ class bugModel extends model
* @access public
* @return object
*/
public function getReleaseBugs($buildID, $productID)
public function getReleaseBugs($buildID, $productID, $branch = 0)
{
$project = $this->dao->select('t1.id,t1.begin')
->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')
->on('t1.id = t2.project')
$project = $this->dao->select('t1.id,t1.begin')->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.id = t2.project')
->where('t2.id')->eq($buildID)
->fetch();
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('resolvedDate')->ge($project->begin)
->andWhere('resolution')->ne('postponed')
->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->andWhere("(project != '$project->id' OR (project = '$project->id' and openedDate < '$project->begin'))")
->andWhere('deleted')->eq(0)
->orderBy('openedDate ASC')
@@ -1573,7 +1574,7 @@ class bugModel extends model
* @access public
* @return array
*/
public function getBySearch($productID, $queryID, $orderBy, $pager = null)
public function getBySearch($productID, $queryID, $orderBy, $pager = null, $branch = 0)
{
if($queryID)
{
@@ -1607,6 +1608,7 @@ class bugModel extends model
$bugQuery = str_replace($allProduct, '1', $this->session->bugQuery);
$bugQuery = $bugQuery . ' AND `product`' . helper::dbIN($products);
}
if($branch) $bugQuery .= "AND `branch` in('0','$branch')";
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery)
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
+3 -1
View File
@@ -436,11 +436,13 @@ class build extends control
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($build->product);
$this->config->bug->search['params']['openedBuild']['values'] = $this->build->getProductBuildPairs($build->product);
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
unset($this->config->bug->search['fields']['branch']);
unset($this->config->bug->search['params']['branch']);
$this->loadModel('search')->setSearchParams($this->config->bug->search);
if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($build->product, $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($build->product, $queryID, 'id_desc', null, $build->branch);
}
else
{
+1 -1
View File
@@ -47,7 +47,7 @@ $config->product->search['params']['pri'] = array('operator' => '=',
$config->product->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->product->search['params']['branch'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->product->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => '');
$config->product->search['params']['plan'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->product->search['params']['plan'] = array('operator' => 'include', 'control' => 'select', 'values' => '');
$config->product->search['params']['estimate'] = array('operator' => '=', 'control' => 'input', 'values' => '');
$config->product->search['params']['source'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->story->sourceList);
+1 -1
View File
@@ -151,7 +151,7 @@ class product extends control
}
if($browseType == 'allstory') $stories = $this->story->getProductStories($productID, $branch, 0, 'all', $sort, $pager);
if($browseType == 'bymodule') $stories = $this->story->getProductStories($productID, $branch, $this->tree->getAllChildID($moduleID), 'all', $sort, $pager);
if($browseType == 'bysearch') $stories = $this->story->getBySearch($productID, $queryID, $sort, $pager);
if($browseType == 'bysearch') $stories = $this->story->getBySearch($productID, $queryID, $sort, $pager, '', $branch);
if($browseType == 'assignedtome')$stories = $this->story->getByAssignedTo($productID, $branch, $this->app->user->account, $sort, $pager);
if($browseType == 'openedbyme') $stories = $this->story->getByOpenedBy($productID, $branch, $this->app->user->account, $sort, $pager);
if($browseType == 'reviewedbyme')$stories = $this->story->getByReviewedBy($productID, $branch, $this->app->user->account, $sort, $pager);
+7 -7
View File
@@ -227,7 +227,7 @@ class productplan extends control
$this->view->plan = $plan;
$this->view->actions = $this->loadModel('action')->getList('productplan', $planID);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->plans = $this->productplan->getPairs($plan->product);
$this->view->plans = $this->productplan->getPairs($plan->product, $plan->branch);
$this->view->type = $type;
$this->view->orderBy = $orderBy;
$this->view->link = $link;
@@ -318,15 +318,15 @@ class productplan extends control
* @access public
* @return void
*/
public function unlinkStory($storyID, $confirm = 'no')
public function unlinkStory($storyID, $planID, $confirm = 'no')
{
if($confirm == 'no')
{
die(js::confirm($this->lang->productplan->confirmUnlinkStory, $this->createLink('productplan', 'unlinkstory', "storyID=$storyID&confirm=yes")));
die(js::confirm($this->lang->productplan->confirmUnlinkStory, $this->createLink('productplan', 'unlinkstory', "storyID=$storyID&planID=$planID&confirm=yes")));
}
else
{
$this->productplan->unlinkStory($storyID);
$this->productplan->unlinkStory($storyID, $planID);
/* if ajax request, send result. */
if($this->server->ajax)
@@ -356,7 +356,7 @@ class productplan extends control
*/
public function batchUnlinkStory($planID, $orderBy = 'id_desc')
{
foreach($this->post->storyIDList as $storyID) $this->productplan->unlinkStory($storyID);
foreach($this->post->storyIDList as $storyID) $this->productplan->unlinkStory($storyID, $planID);
die(js::locate($this->createLink('productplan', 'view', "planID=$planID&type=story&orderBy=$orderBy"), 'parent'));
}
@@ -401,7 +401,7 @@ class productplan extends control
if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($plan->product, $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($plan->product, $queryID, 'id_desc', null, $plan->branch);
foreach($allBugs as $key => $bug)
{
if($bug->status != 'active') unset($allBugs[$key]);
@@ -411,7 +411,7 @@ class productplan extends control
{
$projects = $this->loadModel('project')->getPairs();
$projects[0] = '';
$allBugs= $this->bug->getActiveBugs($this->view->product->id, $projects);
$allBugs= $this->bug->getActiveBugs($this->view->product->id, $plan->branch, $projects);
}
$this->view->allBugs = $allBugs;
+10 -9
View File
@@ -89,7 +89,7 @@ class productplanModel extends model
return array('' => '') + $this->dao->select('id,CONCAT(title, " [", begin, " ~ ", end, "]") as title')->from(TABLE_PRODUCTPLAN)
->where('product')->in($product)
->andWhere('deleted')->eq(0)
->beginIF($branch)->andWhere("branch")->eq($branch)->fi()
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
->beginIF($expired == 'unexpired')->andWhere('end')->gt($date)->fi()
->orderBy('begin desc')->fetchPairs();
}
@@ -204,7 +204,7 @@ class productplanModel extends model
$this->loadModel('action');
foreach($this->post->stories as $storyID)
{
$this->dao->update(TABLE_STORY)->set('plan')->eq((int)$planID)->where('id')->eq((int)$storyID)->exec();
$this->dao->update(TABLE_STORY)->set("plan=CONCAT(plan, ',', $planID)")->where('id')->eq((int)$storyID)->exec();
$this->action->create('story', $storyID, 'linked2plan', '', $planID);
$this->story->setStage($storyID);
}
@@ -217,10 +217,11 @@ class productplanModel extends model
* @access public
* @return void
*/
public function unlinkStory($storyID)
public function unlinkStory($storyID, $planID)
{
$planID = $this->dao->findByID($storyID)->from(TABLE_STORY)->fields('plan')->fetch('plan');
$this->dao->update(TABLE_STORY)->set('plan')->eq(0)->where('id')->eq((int)$storyID)->exec();
$story = $this->dao->findByID($storyID)->from(TABLE_STORY)->fetch();
$plans = array_unique(explode(',', trim(str_replace(",$planID,", ',', ',' . trim($story->plan) . ','). ',')));
$this->dao->update(TABLE_STORY)->set('plan')->eq(join(',', $plans))->where('id')->eq((int)$storyID)->exec();
$this->loadModel('story')->setStage($storyID);
$this->loadModel('action')->create('story', $storyID, 'unlinkedfromplan', '', $planID);
}
@@ -238,7 +239,7 @@ class productplanModel extends model
$this->loadModel('action');
foreach($this->post->bugs as $bugID)
{
$this->dao->update(TABLE_BUG)->set('plan')->eq((int)$planID)->where('id')->eq((int)$bugID)->exec();
$this->dao->update(TABLE_BUG)->set('plan')->eq($planID)->where('id')->eq((int)$bugID)->exec();
$this->action->create('bug', $bugID, 'linked2plan', '', $planID);
}
}
@@ -250,10 +251,10 @@ class productplanModel extends model
* @access public
* @return void
*/
public function unlinkBug($bugID)
public function unlinkBug($bugID, $planID)
{
$planID = $this->dao->findByID($bugID)->from(TABLE_BUG)->fields('plan')->fetch('plan');
$this->dao->update(TABLE_BUG)->set('plan')->eq(0)->where('id')->eq((int)$bugID)->exec();
$planID = $this->dao->findByID($bugID)->from(TABLE_BUG)->fetch('plan');
$this->dao->update(TABLE_STORY)->set('plan')->eq(0)->where('id')->eq((int)$bugID)->exec();
$this->loadModel('action')->create('bug', $bugID, 'unlinkedfromplan', '', $planID);
}
}
+2 -2
View File
@@ -102,7 +102,7 @@
<?php
if(common::hasPriv('productplan', 'unlinkStory'))
{
$unlinkURL = $this->createLink('productplan', 'unlinkStory', "story=$story->id&confirm=yes");
$unlinkURL = $this->createLink('productplan', 'unlinkStory', "story=$story->id&plan=$plan->id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"storyList\",confirmUnlinkStory)", '<i class="icon-unlink"></i>', '', "class='btn-icon' title='{$lang->productplan->unlinkStory}'");
}
?>
@@ -134,7 +134,7 @@
$withSearch = count($plans) > 10;
foreach($plans as $planID => $planName)
{
$actionLink = $this->createLink('story', 'batchChangePlan', "planID=$planID");
$actionLink = $this->createLink('story', 'batchChangePlan', "planID=$planID&oldPlanID=$plan->id");
echo "<li class='option' data-key='$planID'>" . html::a('#', $planName, '', "onclick=\"setFormAction('$actionLink', 'hiddenwin')\"") . "</li>";
}
if($withSearch) echo "<li class='menu-search'><div class='input-group input-group-sm'><input type='text' class='form-control' placeholder=''><span class='input-group-addon'><i class='icon-search'></i></span></div></li>";
+5 -3
View File
@@ -446,22 +446,24 @@ class release extends control
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($release->product);
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($release->product);
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
unset($this->config->bug->search['fields']['branch']);
unset($this->config->bug->search['params']['branch']);
$this->loadModel('search')->setSearchParams($this->config->bug->search);
$allBugs = array();
if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($release->product, $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($release->product, $queryID, 'id_desc', null, $release->branch);
}
elseif($build->project)
{
if($type == 'bug')
{
$allBugs = $this->bug->getReleaseBugs($build->id, $release->product);
$allBugs = $this->bug->getReleaseBugs($build->id, $release->product, $release->branch);
}
elseif($type == 'leftBug')
{
$allBugs = $this->bug->getProductLeftBugs($build->id, $release->product);
$allBugs = $this->bug->getProductLeftBugs($build->id, $release->product, $release->branch);
}
}
+2 -2
View File
@@ -780,10 +780,10 @@ class story extends control
* @access public
* @return void
*/
public function batchChangePlan($planID)
public function batchChangePlan($planID, $oldPlanID = 0)
{
$storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
$allChanges = $this->story->batchChangePlan($storyIDList, $planID);
$allChanges = $this->story->batchChangePlan($storyIDList, $planID, $oldPlanID);
if(dao::isError()) die(js::error(dao::getError()));
foreach($allChanges as $storyID => $changes)
{
+69 -32
View File
@@ -46,7 +46,7 @@ class storyModel extends model
//$story->bugCount = $this->dao->select('COUNT(*)')->alias('count')->from(TABLE_BUG)->where('story')->eq($storyID)->fetch('count');
//$story->caseCount = $this->dao->select('COUNT(*)')->alias('count')->from(TABLE_CASE)->where('story')->eq($storyID)->fetch('count');
if($story->toBug) $story->toBugTitle = $this->dao->findById($story->toBug)->from(TABLE_BUG)->fetch('title');
if($story->plan) $story->planTitle = $this->dao->findById($story->plan)->from(TABLE_PRODUCTPLAN)->fetch('title');
if($story->plan) $story->planTitle = join(' ', $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('id')->in($story->plan)->fetchPairs('id', 'title'));
$extraStories = array();
if($story->duplicateStory) $extraStories = array($story->duplicateStory);
if($story->linkStories) $extraStories = explode(',', $story->linkStories);
@@ -721,11 +721,12 @@ class storyModel extends model
* @access public
* @return array
*/
public function batchChangePlan($storyIDList, $planID)
public function batchChangePlan($storyIDList, $planID, $oldPlanID = 0)
{
$now = helper::now();
$allChanges = array();
$oldStories = $this->getByList($storyIDList);
$plan = $this->loadModel('productplan')->getById($planID);
foreach($storyIDList as $storyID)
{
$oldStory = $oldStories[$storyID];
@@ -733,7 +734,16 @@ class storyModel extends model
$story = new stdclass();
$story->lastEditedBy = $this->app->user->account;
$story->lastEditedDate = $now;
$story->plan = $planID;
if(strpos(",{$oldStory->plan},", ",$planID,") !== false) continue;
if($this->session->currentProductType == 'normal' or empty($oldPlanID))
{
$story->plan = $planID;
}
elseif($oldPlanID)
{
$story->plan = trim(str_replace(",$oldPlanID,", ',', ",$oldStory->plan,"), ',');
if(empty($story->branch) or empty($plan->branch) or ($plan->branch == $oldStory->branch)) $story->plan .= ",$planID";
}
if($planID) $story->stage = 'planned';
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
@@ -859,8 +869,8 @@ class storyModel extends model
/* If no projects, in plan, stage is planned. No plan, wait. */
if(!$projects)
{
$this->dao->update(TABLE_STORY)->set('stage')->eq('wait')->where('id')->eq($storyID)->andWhere('plan')->eq(0)->exec();
$this->dao->update(TABLE_STORY)->set('stage')->eq('planned')->where('id')->eq($storyID)->andWhere('plan')->gt(0)->exec();
$this->dao->update(TABLE_STORY)->set('stage')->eq('wait')->where('id')->eq($storyID)->andWhere('plan')->eq('')->exec();
$this->dao->update(TABLE_STORY)->set('stage')->eq('planned')->where('id')->eq($storyID)->andWhere('plan')->ne('')->exec();
return true;
}
@@ -976,15 +986,14 @@ class storyModel extends model
unset($branch[0]);
$branch = join(',', $branch);
}
return $this->dao->select('t1.*, t2.title as planTitle')
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
->beginIF($branch)->andWhere("t1.branch")->in("0,$branch")->fi()
->beginIF(!empty($moduleIds))->andWhere('t1.module')->in($moduleIds)->fi()
->beginIF($status and $status != 'all')->andWhere('t1.status')->in($status)->fi()
->andWhere('t1.deleted')->eq(0)
$stories = $this->dao->select('*')->from(TABLE_STORY)
->where('product')->in($productID)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
->beginIF(!empty($moduleIds))->andWhere('module')->in($moduleIds)->fi()
->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
return $this->mergePlanTitle($productID, $stories, $branch);
}
/**
@@ -1102,17 +1111,16 @@ class storyModel extends model
*/
public function getByField($productID, $branch, $fieldName, $fieldValue, $orderBy, $pager, $operator = 'equal')
{
return $this->dao->select('t1.*, t2.title as planTitle')
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
->andWhere('t1.deleted')->eq(0)
->beginIF(!empty($branch))->andWhere("CONCAT(',', t1.branch, ',')")->like("%,$branch,%")->fi()
$stories = $this->dao->select('*')->from(TABLE_STORY)
->where('product')->in($productID)
->andWhere('deleted')->eq(0)
->beginIF($branch)->andWhere("branch")->eq($branch)->fi()
->beginIF($operator == 'equal')->andWhere($fieldName)->eq($fieldValue)->fi()
->beginIF($operator == 'include')->andWhere($fieldName)->like("%$fieldValue%")->fi()
->orderBy($orderBy)
->page($pager)
->fetchAll();
return $this->mergePlanTitle($productID, $stories, $branch);
}
/**
@@ -1126,10 +1134,9 @@ class storyModel extends model
*/
public function getWillClose($productID, $branch, $orderBy, $pager)
{
$stories = $this->dao->select('t1.*, t2.title as planTitle')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
->andWhere('t1.deleted')->eq(0)
$stories = $this->dao->select('*')->from(TABLE_STORY)
->where('product')->in($productID)
->andWhere('deleted')->eq(0)
->andWhere('stage')->in('developed,released')
->andWhere('status')->ne('closed')
->orderBy($orderBy)
@@ -1137,7 +1144,7 @@ class storyModel extends model
->fetchAll('id');
$stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in(array_keys($stories))->andWhere('stage')->notIN('released')->fetchPairs('story', 'story');
foreach($stages as $storyID) unset($stories[$storyID]);
return $stories;
return $this->mergePlanTitle($productID, $stories, $branch);
}
/**
@@ -1183,15 +1190,17 @@ class storyModel extends model
$storyQuery = $storyQuery . ' AND `product`' . helper::dbIN(array_keys($products));
if($projectID != '')
{
$branches = array(0 => 0);
foreach($products as $product) $branches[$product->branch] = $product->branch;
$storyQuery .= " AND `branch`" . helper::dbIN($branches);
unset($branches[0]);
$branches = join(',', $branches);
if($branches) $storyQuery .= " AND `branch`" . helper::dbIN("0,$branches");
$storyQuery .= " AND `status` != 'draft'";
}
elseif($branch)
{
$storyQuery .= " AND `branch`" . helper::dbIN("0,$branch");
}
$storyQuery = preg_replace("/`plan` +LIKE +'%([0-9]+)%'/i", "CONCAT(',', `plan`, ',') LIKE '%,$1,%'", $storyQuery);
return $this->getBySQL($queryProductID, $storyQuery, $orderBy, $pager);
}
@@ -1230,7 +1239,9 @@ class storyModel extends model
$stories = array();
foreach($tmpStories as $story)
{
$story->planTitle = isset($plans[$story->plan]) ? $plans[$story->plan] : '';
$story->planTitle = '';
$storyPlans = explode(',', trim($story->plan, ','));
foreach($storyPairs as $planID) $story->planTitle .= zget($plans, $planID) . ' ';
$stories[] = $story;
}
return $stories;
@@ -1311,7 +1322,7 @@ class storyModel extends model
public function getPlanStories($planID, $status = 'all', $orderBy = 'id_desc', $pager = null)
{
$stories = $this->dao->select('*')->from(TABLE_STORY)
->where('plan')->eq((int)$planID)
->where("CONCAT(',', plan, ',')")->like("%,$planID,%")
->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll('id');
@@ -1352,10 +1363,9 @@ class storyModel extends model
*/
public function getUserStories($account, $type = 'assignedTo', $orderBy = 'id_desc', $pager = null)
{
$stories = $this->dao->select('t1.*, t2.title as planTitle, t3.name as productTitle')
$stories = $this->dao->select('t1.*, t2.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')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->where('t1.deleted')->eq(0)
->beginIF($type != 'all')
->beginIF($type == 'assignedTo')->andWhere('assignedTo')->eq($account)->fi()
@@ -1368,8 +1378,10 @@ class storyModel extends model
->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
$productIdList = array();
foreach($stories as $story) $productIdList[$story->product] = $story->product;
return $stories;
return $this->mergePlanTitle($productIdList, $stories);
}
/**
@@ -1791,4 +1803,29 @@ class storyModel extends model
return true;
}
/**
* Merge plan title.
*
* @param int|array $productID
* @param array $stories
* @access public
* @return array
*/
public function mergePlanTitle($productID, $stories, $branch = 0)
{
$plans = $this->dao->select('id,title')->from(TABLE_PRODUCTPLAN)
->where('product')->in($productID)
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->andWhere('deleted')->eq(0)
->fetchPairs('id', 'title');
foreach($stories as $story)
{
$story->planTitle = '';
$storyPlans = explode(',', trim($story->plan, ','));
foreach($storyPlans as $planID) $story->planTitle .= zget($plans, $planID) . ' ';
}
return $stories;
}
}