* Fix code style.

This commit is contained in:
Yagami
2020-08-21 16:59:10 +08:00
parent ab623ffab6
commit 87f36b0c39
5 changed files with 97 additions and 109 deletions
+1 -9
View File
@@ -1468,15 +1468,7 @@ class block extends control
*/
public function printRecentprogramBlock()
{
$programs = $this->block->getRecentProject();
$this->loadModel('project');
foreach($programs as $programID => $program)
{
$program->teamCount = count($this->project->getTeamMembers($program->id));
}
$this->view->programs = $programs;
$this->view->programs = $this->block->getRecentPrograms();
}
public function printProgramteamBlock()
-21
View File
@@ -26,24 +26,3 @@ body {padding-bottom: 20px;}
#dashboard .block-sm .hide-in-sm {display: none;}
#dashboard .block-dynamic .panel-body{overflow-x:hidden;}
.modal-body{padding: 10px 20px 20px 20px;}
#cards {margin: 0 10px;}
#cards > .col {width: 33.33%;}
#cards .panel {margin: 10px 0; border: 1px solid #DCDCDC; border-radius: 2px; box-shadow: none; height: 146px; cursor: pointer;}
#cards .panel:hover {border-color: #006AF1; box-shadow: 0 0 10px 0 rgba(0,0,100,.25);}
#cards .panel-heading {padding: 12px 24px 10px 16px;}
#cards .panel-body {padding: 0 16px 16px;}
#cards .panel-actions {padding: 7px 0;}
#cards .panel-actions .dropdown-menu > li > a {padding-left: 5px; text-align: left;}
#cards .panel-actions .dropdown-menu > li > a > i {opacity: .5; display: inline-block; margin-right: 4px; width: 18px; text-align: center;}
#cards .panel-actions .dropdown-menu > li > a:hover > i {opacity: 1;}
#cards .project-type-label {padding: 1px 2px;}
#cards .project-name {font-size: 16px; font-weight: normal; display: inline-block; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;}
#cards .project-infos {font-size: 12px;}
#cards .project-infos > span {display: inline-block; line-height: 12px;}
#cards .project-infos > span > .icon {font-size: 12px; display: inline-block; position: relative; top: -1px}
#cards .project-infos > span + span {margin-left: 15px;}
#cards .project-detail {position: absolute; bottom: 16px; left: 16px; right: 16px; font-size: 12px;}
#cards .project-detail > p {margin-bottom: 8px;}
#cards .project-detail .progress {height: 4px;}
#cards .project-detail .progress-text-left .progress-text {width: 50px; left: -50px;}
+47 -52
View File
@@ -660,73 +660,68 @@ class blockModel extends model
return $data;
}
public function getRecentProject()
public function getRecentPrograms()
{
$projects = $this->loadModel('program')->getUserPrograms('all', 'id_desc', 3);
if(empty($projects)) return array();
$this->loadModel('project');
foreach($projects as $projectID => $project)
{
$project->teamCount = count($this->project->getTeamMembers($project->id));
}
$programs = $this->loadModel('program')->getUserPrograms('all', 'id_desc', 3);
if(empty($programs)) return array();
$projectKeys = array_keys($projects);
$hours = array();
$emptyHour = array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0);
$programIdList = array_keys($programs);
$projects = $this->dao->select('*')->from(TABLE_PROJECT)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('template')->eq('')
->orderBy('id_asc')
->fetchAll('program');
$projectIdList = array();
foreach($projects as $project) $projectIdList[] = $project->id;
$teams = $this->dao->select('root, count(*) as count')->from(TABLE_TEAM)
->where('root')->in($programIdList)
->groupBy('root')
->fetchAll('root');
$consumes = $this->dao->select('program, sum(consumed) as consumed')->from(TABLE_TASK)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->groupBy('program')
->fetchAll('program');
/* Get all tasks and compute totalEstimate, totalConsumed, totalLeft, progress according to them. */
$tasks = $this->dao->select('id, project, estimate, consumed, `left`, status, closedReason')
->from(TABLE_TASK)
->where('project')->in($projectKeys)
->where('project')->in($projectIdList)
->andWhere('parent')->lt(1)
->andWhere('deleted')->eq(0)
->fetchGroup('project', 'id');
/* Compute totalEstimate, totalConsumed, totalLeft. */
foreach($tasks as $projectID => $projectTasks)
->fetchAll('id');
foreach($programs as $programID => $program)
{
$hour = (object)$emptyHour;
foreach($projectTasks as $task)
$program->teamCount = isset($teams[$programID]) ? $teams[$programID]->count : 0;
$program->consumed = isset($consumes[$programID]) ? $consumes[$programID]->consumed : 0;
$program->project = isset($projects[$programID]) ? $projects[$programID] : new stdclass();
if(!empty($program->project))
{
if($task->status != 'cancel')
$totalEstimate = $totalConsumed = $totalLeft = 0;
foreach($tasks as $id => $task)
{
$hour->totalEstimate += $task->estimate;
$hour->totalConsumed += $task->consumed;
if($task->project != $program->project->id) continue;
if($task->status != 'cancel')
{
$totalEstimate += $task->estimate;
$totalConsumed += $task->consumed;
}
if($task->status != 'cancel' and $task->status != 'closed') $totalLeft += $task->left;
}
if($task->status != 'cancel' and $task->status != 'closed') $hour->totalLeft += $task->left;
$program->project->progress = ($totalLeft + $totalConsumed) == 0 ? 0 : round($totalConsumed / ($totalLeft + $totalConsumed), 3) * 100;
}
$hours[$projectID] = $hour;
}
/* Compute totalReal and progress. */
foreach($hours as $hour)
{
$hour->totalEstimate = round($hour->totalEstimate, 1) ;
$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, 3) * 100 : 0;
}
/* Process projects. */
foreach($projects as $key => $project)
{
// Process the end time.
$project->end = date(DT_DATE1, strtotime($project->end));
/* Judge whether the project is delayed. */
if($project->status != 'done' and $project->status != 'closed' and $project->status != 'suspended')
{
$delay = helper::diffDate(helper::today(), $project->end);
if($delay > 0) $project->delay = $delay;
}
/* Process the hours. */
$project->hours = isset($hours[$project->id]) ? $hours[$project->id] : (object)$emptyHour;
}
return $projects;
return $programs;
}
/**
@@ -135,9 +135,9 @@ $(function()
<div class="program-info">
<div class='title'><?php echo $lang->program->allInput;?></div>
<div class='info'>
<span><i class='icon icon-group'></i><?php echo $program->countMembers;?></span>
<span><i class='icon icon-clock'></i><?php echo $program->consumed;?></span>
<span><i class='icon icon-yen'></i><?php echo $program->budget;?></span>
<span><i class='icon icon-group'></i> <?php echo $program->countMembers;?></span>
<span><i class='icon icon-clock'></i> <?php echo $program->consumed;?></span>
<span><i class='icon icon-cost'></i> <?php echo $program->budget;?></span>
</div>
</div>
<div class="project-info">
+46 -24
View File
@@ -1,50 +1,72 @@
<style>
#cards {margin: 0 10px;}
#cards > .col {width: 33.33%;}
#cards .panel {margin: 10px 0; border: 1px solid #DCDCDC; border-radius: 2px; box-shadow: none; height: 146px; cursor: pointer;}
#cards .panel:hover {border-color: #006AF1; box-shadow: 0 0 10px 0 rgba(0,0,100,.25);}
#cards .panel-heading {padding: 12px 24px 10px 16px;}
#cards .panel-body {padding: 0 16px 16px;}
#cards .panel-actions {padding: 7px 0;}
#cards .panel-actions .dropdown-menu > li > a {padding-left: 5px; text-align: left;}
#cards .panel-actions .dropdown-menu > li > a > i {opacity: .5; display: inline-block; margin-right: 4px; width: 18px; text-align: center;}
#cards .panel-actions .dropdown-menu > li > a:hover > i {opacity: 1;}
#cards .program-type-label {padding: 1px 2px;}
#cards .program-name {font-size: 16px; font-weight: normal; display: inline-block; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;}
#cards .program-infos {font-size: 12px;}
#cards .program-infos > span {display: inline-block; line-height: 12px;}
#cards .program-infos > span > .icon {font-size: 12px; display: inline-block; position: relative; top: -1px}
#cards .program-infos > span + span {margin-left: 15px;}
#cards .program-detail {position: absolute; bottom: 16px; left: 16px; right: 16px; font-size: 12px;}
#cards .program-detail > p {margin-bottom: 8px;}
#cards .program-detail .progress {height: 4px;}
#cards .program-detail .progress-text-left .progress-text {width: 50px; left: -50px;}
</style>
<div class='row cell' id='cards'>
<?php foreach ($programs as $projectID => $project):?>
<?php foreach ($programs as $programID => $program):?>
<div class='col'>
<div class='panel'>
<div class='panel-heading'>
<?php if($project->template === 'cmmi'): ?>
<span class='project-type-label label label-warning label-outline'><?php echo $lang->block->cmmi; ?></span>
<?php if($program->template === 'cmmi'): ?>
<span class='program-type-label label label-warning label-outline'><?php echo $lang->block->cmmi; ?></span>
<?php else: ?>
<span class='project-type-label label label-info label-outline'><?php echo $lang->block->scrum; ?></span>
<span class='program-type-label label label-info label-outline'><?php echo $lang->block->scrum; ?></span>
<?php endif; ?>
<strong class='project-name' title='<?php echo $project->name;?>'><?php echo $project->name;?></strong>
<strong class='program-name' title='<?php echo $program->name;?>'><?php echo $program->name;?></strong>
<nav class='panel-actions nav nav-default'>
<li class='dropdown'>
<a href='javascript:;' data-toggle='dropdown' class='panel-action'><i class='icon icon-ellipsis-v'></i></a>
<ul class='dropdown-menu pull-right'>
<li><?php common::printIcon('program', 'group', "projectID=$project->id", $project, 'button', 'group');?></li>
<li><?php common::printIcon('program', 'manageMembers', "projectID=$project->id", $project, 'button', 'persons');?></li>
<li><?php common::printicon('program', 'activate', "projectid=$project->id", $project, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "projectID=$project->id"), "<i class='icon-edit'></i> " . $lang->edit, '', "");?></li>
<li><?php common::printIcon('program', 'start', "projectID=$project->id", $project, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'suspend', "projectID=$project->id", $project, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'close', "projectID=$project->id", $project, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("project", "delete", "projectID=$project->id"), "<i class='icon-trash'></i> " . $lang->delete, 'hiddenwin', "");?></li>
<li><?php common::printIcon('program', 'group', "programID=$program->id", $program, 'button', 'group');?></li>
<li><?php common::printIcon('program', 'manageMembers', "programID=$program->id", $program, 'button', 'persons');?></li>
<li><?php common::printicon('program', 'activate', "programid=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "programID=$program->id"), "<i class='icon-edit'></i> " . $lang->edit, '', "");?></li>
<li><?php common::printIcon('program', 'start', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'suspend', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'close', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("program", "delete", "programID=$program->id"), "<i class='icon-trash'></i> " . $lang->delete, 'hiddenwin', "");?></li>
</ul>
</li>
</nav>
</div>
<div class='panel-body'>
<div class='project-infos'>
<span><i class='icon icon-group'></i> <?php printf($lang->program->membersUnit, $project->teamCount); ?></span>
<span><i class='icon icon-clock'></i> <?php printf($lang->program->hoursUnit, $project->hours->totalEstimate); ?></span>
<span><i class='icon icon-cost'></i> <?php echo $project->budget . '' . zget($lang->program->unitList, $project->budgetUnit);?></span>
<div class='program-infos'>
<span><i class='icon icon-group'></i> <?php printf($lang->program->membersUnit, $program->teamCount); ?></span>
<span><i class='icon icon-clock'></i> <?php printf($lang->program->hoursUnit, $program->consumed); ?></span>
<span><i class='icon icon-cost'></i> <?php echo $program->budget . '' . zget($lang->program->unitList, $program->budgetUnit);?></span>
</div>
<?php if($project->template === 'cmmi'): ?>
<div class='project-detail project-stages'>
<?php if($program->template === 'cmmi'): ?>
<div class='program-detail program-stages'>
<p class='text-muted'><?php echo $lang->program->ongoingStage; ?></p>
<div class='label label-outline'><?php echo zget($lang->project->statusList, $project->status);?></div>
<div class='label label-outline'><?php echo zget($lang->project->statusList, $program->status);?></div>
</div>
<?php else: ?>
<div class='project-detail project-iteration'>
<div class='program-detail program-iteration'>
<p class='text-muted'><?php echo $lang->program->lastIteration; ?></p>
<div class='row'>
<div class='col-xs-5'><?php echo $project->name; ?></div>
<div class='col-xs-5'><?php echo $program->project->name; ?></div>
<div class='col-xs-7'>
<div class="progress progress-text-left">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $project->hours->progress;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $project->hours->progress;?>%">
<span class="progress-text"><?php echo $project->hours->progress;?>%</span>
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $program->project->progress;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $program->project->progress;?>%">
<span class="progress-text"><?php echo $program->project->progress;?>%</span>
</div>
</div>
</div>