* finish task #49091.
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Get the project or execution in which the user participates..
|
||||
*
|
||||
* @param string $account
|
||||
* @param string $type project|execution
|
||||
* @param string $status
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getObjects($account, $type = 'execution', $status = 'all', $orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
$objectType = $type == 'execution' ? 'sprint,stage,kanban' : $type;
|
||||
$myObjectsList = $this->dao->select('t1.*,t2.*')->from(TABLE_TEAM)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.root = t2.id')
|
||||
->where('t1.type')->eq($type)
|
||||
->andWhere('t2.type')->in($objectType)
|
||||
->beginIF(strpos('doing|wait|suspended|closed', $status) !== false)->andWhere('status')->eq($status)->fi()
|
||||
->beginIF($status == 'done')->andWhere('status')->in('done,closed')->fi()
|
||||
->beginIF($status == 'undone')->andWhere('status')->notin('done,closed')->fi()
|
||||
->beginIF($status == 'openedbyme')->andWhere('openedBy')->eq($account)->fi()
|
||||
->beginIF($type == 'execution' and !$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($type == 'project' and !$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->projects)->fi()
|
||||
->andWhere('t1.account')->eq($account)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t2.vision')->eq($this->config->vision)
|
||||
->orderBy("t2.$orderBy")
|
||||
->page($pager)
|
||||
->fetchAll('root');
|
||||
|
||||
$objectIdList = array();
|
||||
$projectIdList = array();
|
||||
foreach($myObjectsList as $object)
|
||||
{
|
||||
$objectIdList[] = $object->id;
|
||||
$projectIdList[] = $object->project;
|
||||
}
|
||||
|
||||
/* Get all tasks and compute totalConsumed, totalLeft, totalWait, progress according to them. */
|
||||
$hours = array();
|
||||
$emptyHour = array('totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0, 'waitTasks' => 0, 'assignedToMeTasks' => 0, 'doneTasks' => 0, 'taskTotal' => 0);
|
||||
$searchField = $type == 'project' ? 'project' : 'execution';
|
||||
$tasks = $this->dao->select('id, project, execution, consumed, `left`, status, assignedTo,finishedBy')
|
||||
->from(TABLE_TASK)
|
||||
->where('parent')->lt(1)
|
||||
->andWhere($searchField)->in($objectIdList)->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchGroup($searchField, 'id');
|
||||
|
||||
/* Compute totalEstimate, totalConsumed, totalLeft. */
|
||||
foreach($tasks as $objectID => $objectTasks)
|
||||
{
|
||||
$hour = (object)$emptyHour;
|
||||
$hour->taskTotal = count($objectTasks);
|
||||
foreach($objectTasks as $task)
|
||||
{
|
||||
if($task->status == 'wait') $hour->waitTasks += 1;
|
||||
if($task->finishedBy != '') $hour->doneTasks += 1;
|
||||
if($task->status != 'cancel') $hour->totalConsumed += $task->consumed;
|
||||
if($task->status != 'cancel' and $task->status != 'closed') $hour->totalLeft += $task->left;
|
||||
if($task->assignedTo == $account) $hour->assignedToMeTasks += 1;
|
||||
}
|
||||
$hours[$objectID] = $hour;
|
||||
}
|
||||
|
||||
/* Compute totalReal and progress. */
|
||||
foreach($hours as $hour)
|
||||
{
|
||||
$hour->totalConsumed = round($hour->totalConsumed, 1);
|
||||
$hour->totalLeft = round($hour->totalLeft, 1);
|
||||
$hour->totalReal = $hour->totalConsumed + $hour->totalLeft;
|
||||
$hour->progress = $hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0;
|
||||
}
|
||||
|
||||
$myObjects = array();
|
||||
$projectList = $this->loadModel('project')->getByIdList($projectIdList);
|
||||
foreach($myObjectsList as $object)
|
||||
{
|
||||
/* Judge whether the project or execution is delayed. */
|
||||
if($object->status != 'done' and $object->status != 'closed' and $object->status != 'suspended')
|
||||
{
|
||||
$delay = helper::diffDate(helper::today(), $object->end);
|
||||
if($delay > 0) $object->delay = $delay;
|
||||
}
|
||||
|
||||
/* Process the hours. */
|
||||
$object->progress = isset($hours[$object->id]) ? $hours[$object->id]->progress : 0;
|
||||
$object->waitTasks = isset($hours[$object->id]) ? $hours[$object->id]->waitTasks : 0;
|
||||
$object->doneTasks = isset($hours[$object->id]) ? $hours[$object->id]->doneTasks : 0;
|
||||
$object->taskTotal = isset($hours[$object->id]) ? $hours[$object->id]->taskTotal : 0;
|
||||
$object->totalConsumed = isset($hours[$object->id]) ? $hours[$object->id]->totalConsumed : 0;
|
||||
$object->assignedToMeTasks = isset($hours[$object->id]) ? $hours[$object->id]->assignedToMeTasks : 0;
|
||||
|
||||
if($object->project)
|
||||
{
|
||||
$parentProject = zget($projectList, $object->project, '');
|
||||
$object->projectName = $parentProject ? $parentProject->name : '';
|
||||
}
|
||||
$myObjects[$object->id] = $object;
|
||||
}
|
||||
|
||||
return $myObjects;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* The project view file of dashboard module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package dashboard
|
||||
* @version $Id: project.html.php 4129 2013-01-18 01:58:14Z wwccss $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include $this->app->getModuleRoot() . 'common/view/header.html.php';?>
|
||||
<?php include $this->app->getModuleRoot() . 'common/view/tablesorter.html.php';?>
|
||||
<?php include $this->app->getModuleRoot() . 'user/view/featurebar.html.php';?>
|
||||
<div id='mainContent'>
|
||||
<div class='main-table'>
|
||||
<table class='table has-sort-head table-fixed'>
|
||||
<?php $vars = "userID={$user->id}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"; ?>
|
||||
<thead>
|
||||
<tr class='colhead'>
|
||||
<th class='c-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
|
||||
<th class="text-left"><?php common::printOrderLink('name', $orderBy, $vars, $lang->user->name);?></th>
|
||||
<th class='c-status'> <?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
|
||||
<th class='c-user'> <?php echo $lang->team->role;?></th>
|
||||
<th class='c-date'> <?php common::printOrderLink('begin', $orderBy, $vars, $lang->execution->begin);?></th>
|
||||
<th class='c-date'> <?php common::printOrderLink('end', $orderBy, $vars, $lang->execution->end);?></th>
|
||||
<th class='c-date'> <?php echo $lang->team->join;?></th>
|
||||
<th class='c-hours'> <?php echo $lang->team->hours;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($executions as $execution):?>
|
||||
<?php $executionLink = $this->createLink('execution', 'view', "executionID=$execution->id");?>
|
||||
<?php if($this->config->vision == 'lite') $executionLink = $this->createLink('execution', 'kanban', "kanbanID=$execution->id");?>
|
||||
<tr>
|
||||
<td><?php echo html::a($executionLink, $execution->id);?></td>
|
||||
<td>
|
||||
<?php if(isset($config->maxVersion)):?>
|
||||
<span class='project-type-label label label-info label-outline'><?php echo zget($lang->user->executionTypeList, $execution->type);?></span>
|
||||
<?php endif;?>
|
||||
<?php echo html::a($executionLink, $execution->name);?>
|
||||
</td>
|
||||
<?php if(isset($execution->delay)):?>
|
||||
<td class='project-delay'><?php echo $lang->execution->delayed;?></td>
|
||||
<?php else:?>
|
||||
<td class='project-<?php echo $execution->status?>'><?php echo $this->processStatus('execution', $execution);?></td>
|
||||
<?php endif;?>
|
||||
<td><?php echo $execution->role;?></td>
|
||||
<td><?php echo $execution->begin;?></td>
|
||||
<td><?php echo $execution->end;?></td>
|
||||
<td><?php echo $execution->join;?></td>
|
||||
<td><?php echo $execution->hours;?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($executions):?>
|
||||
<div class="table-footer"><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include $this->app->getModuleRoot() . 'common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user