* finish task #2344.

This commit is contained in:
wangyidong
2015-10-26 13:12:00 +08:00
parent 621684debf
commit 5029ba6b23
9 changed files with 38 additions and 37 deletions

View File

@@ -129,14 +129,13 @@ class build extends control
$this->view->title = "BUILD #$build->id $build->name - " . $projects[$build->project];
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $projects[$build->project]);
$this->view->position[] = $this->lang->build->view;
$this->view->products = $this->project->getProducts($build->project);
$this->view->generatedBugs = $this->bug->getProjectBugs($build->project, 'status_desc,id_desc', null, $build->id);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->build = $build;
$this->view->stories = $stories;
$this->view->bugs = $bugs;
$this->view->actions = $this->loadModel('action')->getList('build', $buildID);
$this->view->type = $type;
$this->view->type = $type;
$this->view->link = $link;
$this->view->param = $param;
$this->display();

View File

@@ -316,7 +316,7 @@ class doc extends control
$this->view->moduleID = $moduleID;
$this->view->productID = $productID;
$this->view->projectID = $projectID;
$this->view->products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID);
$this->view->products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID, false);
$this->view->projects = $this->loadModel('project')->getPairs('all');
$this->display();
@@ -370,7 +370,7 @@ class doc extends control
$this->view->libID = $libID;
$this->view->libs = $this->libs;
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->products = $doc->project == 0 ? $this->product->getPairs() : $this->project->getProducts($doc->project);
$this->view->products = $doc->project == 0 ? $this->product->getPairs() : $this->project->getProducts($doc->project, false);
$this->view->projects = $this->loadModel('project')->getPairs('all');
$this->display();
}

View File

@@ -295,6 +295,10 @@ class mail extends control
$log = '';
foreach($queueList as $queue)
{
$mailStatus = $this->dao->select('*')->from(TABLE_MAILQUEUE)->where('id')->eq($queue->id)->fetch('status');
if($mailStatus != 'wait') break;
$this->dao->update(TABLE_MAILQUEUE)->set('status')->eq('sending')->where('id')->eq($queue->id)->exec();
$this->mail->send($queue->toList, $queue->subject, $queue->body, $queue->ccList);
$data = new stdclass();

View File

@@ -904,7 +904,6 @@ class project extends control
$whitelist = '';
$acl = 'open';
$productIDList = array();
if($copyProjectID)
{
$copyProject = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProjectID)->fetch();
@@ -914,7 +913,6 @@ class project extends control
$acl = $copyProject->acl;
$whitelist = $copyProject->whitelist;
$products = $this->project->getProducts($copyProjectID);
foreach($products as $product) $productIDList[$product->id] = $product->id;
}
if(!empty($_POST))
@@ -941,7 +939,7 @@ class project extends control
$this->view->whitelist = $whitelist;
$this->view->acl = $acl ;
$this->view->copyProjectID = $copyProjectID;
$this->view->branchGroups = $this->loadModel('branch')->getByProducts($productIDList);
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products));
$this->display();
}
@@ -991,11 +989,9 @@ class project extends control
$allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode');
$linkedProducts = $this->project->getProducts($project->id);
$productIDList = array();
foreach($linkedProducts as $product)
{
if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name;
$productIDList[$product->id] = $product->id;
}
$this->view->title = $title;
@@ -1009,7 +1005,7 @@ class project extends control
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->allProducts = $allProducts;
$this->view->linkedProducts = $linkedProducts;
$this->view->branchGroups = $this->loadModel('branch')->getByProducts($productIDList);
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts));
$this->display();
}
@@ -1351,14 +1347,10 @@ class project extends control
$allProducts = $this->product->getPairs('noclosed|nocode');
$linkedProducts = $this->project->getProducts($project->id);
// Merge allProducts and linkedProducts for closed product.
$products = array();
foreach($linkedProducts as $product)
{
if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name;
if(!isset($products[$product->id])) $products[$product->id] = $product;
$products[$product->id]->branches[$product->branch] = $product->branch;
}
$linkedProducts = $products;
/* Assign. */
$this->view->title = $title;
@@ -1556,7 +1548,9 @@ class project extends control
}
else
{
$allStories = $this->story->getProductStories(array_keys($products), 0, $moduleID = '0', $status = 'active');
$branches = array(0 => 0);
foreach($products as $product) $branches += $product->branches;
$allStories = $this->story->getProductStories(array_keys($products), $branches, $moduleID = '0', $status = 'active');
}
$prjStories = $this->story->getProjectStoryPairs($projectID);
@@ -1709,7 +1703,7 @@ class project extends control
*/
public function ajaxGetProducts($projectID)
{
$products = $this->project->getProducts($projectID);
$products = $this->project->getProducts($projectID, false);
die(html::select('product', $products, '', 'class="form-control"'));
}

View File

@@ -631,7 +631,7 @@ class projectModel extends model
* @access public
* @return void
*/
public function getProjectStats($status = 'undone', $productID = 0, $branch, $itemCounts = 30, $orderBy = 'order_desc', $pager = null)
public function getProjectStats($status = 'undone', $productID = 0, $itemCounts = 30, $orderBy = 'order_desc', $pager = null)
{
/* Init vars. */
$projects = $this->getList($status, 0, $productID, $branch);
@@ -788,13 +788,23 @@ class projectModel extends model
* @access public
* @return array
*/
public function getProducts($projectID)
public function getProducts($projectID, $withBranch = true)
{
return $this->dao->select('t2.id, t2.name, t2.type, t1.branch')->from(TABLE_PROJECTPRODUCT)->alias('t1')
$query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')
->on('t1.product = t2.id')
->where('t1.project')->eq((int)$projectID)
->fetchAll();
->where('t1.project')->eq((int)$projectID);
if(!$withBranch) return $query->fetchPairs('id', 'name');
$products = $query->fetchAll();
$productGroups = array();
foreach($products as $product)
{
if(!isset($productGroups[$product->id])) $productGroups[$product->id] = $product;
$productGroups[$product->id]->branches[$product->branch] = $product->branch;
unset($productGroups[$product->id]->branch);
}
return $productGroups;
}
/**

View File

@@ -45,7 +45,7 @@
<?php echo html::a($storyLink, sprintf('%03d', $story->id));?>
</td>
<td><span class='<?php echo 'pri' . zget($lang->story->priList, $story->pri, $story->pri)?>'><?php echo zget($lang->story->priList, $story->pri, $story->pri);?></span></td>
<td><?php echo html::a($this->createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product], '_blank');?></td>
<td><?php echo html::a($this->createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product]->name, '_blank');?></td>
<td class='text-left nobr' title="<?php echo $story->title?>"><?php echo html::a($storyLink, $story->title);?></td>
<td><?php echo $story->planTitle;?></td>
<td><?php echo $users[$story->openedBy];?></td>

View File

@@ -1,12 +0,0 @@
<?php
$products = join(', ', $products);
printf($lang->project->oneLineStats,
$project->name,
$project->code,
$products,
$project->begin,
$project->end,
$project->totalEstimate,
$project->totalConsumed,
$project->totalLeft);
?>

View File

@@ -110,7 +110,7 @@
<tr>
<th><?php echo $lang->project->products;?></th>
<td>
<?php foreach($products as $productID => $productName) echo html::a($this->createLink('product', 'browse', "productID=$productID"), $productName) . '<br />';?>
<?php foreach($products as $productID => $product) echo html::a($this->createLink('product', 'browse', "productID=$productID"), $product->name) . '<br />';?>
</td>
</tr>
<tr>

View File

@@ -937,7 +937,7 @@ class storyModel extends model
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
->beginIF(!empty($branch))->andWhere("t1.branch")->eq($branch)->fi()
->beginIF(!empty($branch))->andWhere("t1.branch")->in($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)
@@ -1136,7 +1136,13 @@ class storyModel extends model
$queryProductID = 'all';
}
$storyQuery = $storyQuery . ' AND `product`' . helper::dbIN(array_keys($products));
if($projectID != '') $storyQuery .= " AND `status` != 'draft'";
if($projectID != '')
{
$branches = array(0 => 0);
foreach($products as $product) $branches += $product->branches;
$storyQuery .= " AND `branch`" . helper::dbIN($branches);
$storyQuery .= " AND `status` != 'draft'";
}
return $this->getBySQL($queryProductID, $storyQuery, $orderBy, $pager);
}