diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 33f768c..34b008b 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -84,53 +84,66 @@ class IDF_Views_Issue public $summary_precond = array('IDF_Precondition::accessIssues'); public function summary($request, $match) { + $tagStatistics = array(); + $ownerStatistics = array(); + $status = array(); + $isTrackerEmpty = false; + $prj = $request->project; $opened = $prj->getIssueCountByStatus('open'); $closed = $prj->getIssueCountByStatus('closed'); - $otags = implode(',', $prj->getTagIdsByStatus('open')); - // Issue status statistics - $status = array(); - $status['Open'] = array($opened, (int)(100 * $opened / ($opened + $closed))); - $status['Closed'] = array($closed, (int)(100 * $closed / ($opened + $closed))); - - // Issue owner statistics - $sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable(); - $sqlUsersTable = Pluf::factory('Pluf_User')->getSqlTable(); - $query = <<<"QUERY" + // Check if the tracker is empty + if ($opened === 0 && $closed === 0) { + $isTrackerEmpty = true; + } else { + if ($opened > 0 || $closed > 0) { + // Issue status statistics + $status['Open'] = array($opened, (int)(100 * $opened / ($opened + $closed))); + $status['Closed'] = array($closed, (int)(100 * $closed / ($opened + $closed))); + } + + if ($opened > 0) { + // Issue owner statistics + $sqlIssueTable = Pluf::factory('IDF_Issue')->getSqlTable(); + $sqlUsersTable = Pluf::factory('Pluf_User')->getSqlTable(); + $otags = implode(',', $prj->getTagIdsByStatus('open')); + $query = <<<"QUERY" SELECT CONCAT(first_name, " ", last_name) as name, nb FROM (SELECT uid as id,count(uid) as nb FROM (SELECT ifnull(owner, -1) as uid FROM $sqlIssueTable WHERE status IN ($otags)) as ff group by uid) AS ff LEFT JOIN $sqlUsersTable using(id) QUERY; - $db = Pluf::db(); - $dbData = $db->select($query); - $ownerStatistics = array(); - foreach ($dbData as $k => $v) { - $key = ($v['name'] === null) ? __('Not assigned') : $v['name']; - $ownerStatistics[$key] = array($v['nb'], (int)(100 * $v['nb'] / $opened)); - } + $db = Pluf::db(); + $dbData = $db->select($query); + foreach ($dbData as $k => $v) { + $key = ($v['name'] === null) ? __('Not assigned') : $v['name']; + $ownerStatistics[$key] = array($v['nb'], (int)(100 * $v['nb'] / $opened)); + } - // Issue class tag statistics - $tags = $prj->getTagCloud(); - $tagStatistics = array(); - foreach ($tags as $t) { - $tagStatistics[$t->class][$t->name] = array($t->nb_use, $t->id); - } - foreach($tagStatistics as $k => $v) { - $nbIssueInClass = 0; - foreach ($v as $val) { - $nbIssueInClass += $val[0]; - } - foreach ($v as $kk => $vv) { - $tagStatistics[$k][$kk] = array($vv[0], (int)(100 * $vv[0] / $nbIssueInClass), $vv[1]); + // Issue class tag statistics + $tags = $prj->getTagCloud(); + foreach ($tags as $t) { + $tagStatistics[$t->class][$t->name] = array($t->nb_use, $t->id); + } + foreach($tagStatistics as $k => $v) { + $nbIssueInClass = 0; + foreach ($v as $val) { + $nbIssueInClass += $val[0]; + } + foreach ($v as $kk => $vv) { + $tagStatistics[$k][$kk] = array($vv[0], (int)(100 * $vv[0] / $nbIssueInClass), $vv[1]); + } + } + + // Sort + krsort($tagStatistics); + arsort($ownerStatistics); } } - // Sort - krsort($tagStatistics); - arsort($ownerStatistics); - $title = sprintf(__('Summary of tracked issues in %s.'), (string) $prj); + return Pluf_Shortcuts_RenderToResponse('idf/issues/summary.html', array('page_title' => $title, + 'trackerEmpty' => $isTrackerEmpty, 'project' => $prj, 'tagStatistics' => $tagStatistics, 'ownerStatistics' => $ownerStatistics, diff --git a/src/IDF/templates/idf/issues/summary.html b/src/IDF/templates/idf/issues/summary.html index 14765e5..578a77d 100644 --- a/src/IDF/templates/idf/issues/summary.html +++ b/src/IDF/templates/idf/issues/summary.html @@ -3,87 +3,93 @@ {block docclass}yui-t2{assign $inSummaryIssues=true}{/block} {block body} +{if $trackerEmpty} + {aurl 'create_url', 'IDF_Views_Issue::create', array($project.shortname)} +

{blocktrans}The issue tracker is empty
You can create your first issue here.{/blocktrans}

+{else}
{foreach $tagStatistics as $key => $class} -
-

Unresolved: By {$key}

- - -{foreach $class as $key => $value} - - - - - -{/foreach} - -
{$key}{$value[0]} - - - - - +
+

Unresolved: By {$key}

+
-
-
   {$value[1]}%
+ + {foreach $class as $key => $value} + + + + + + {/foreach}
{$key}{$value[0]} + + + + + + +
+
+
   {$value[1]}%
+
-
-
+
{/foreach}
- -
-

Status Summary

- - -{foreach $status as $key => $value} - - - - - -{/foreach} - -
{$key}{$value[0]} - - - - - +{if $status} +
+

Status Summary

+
-
-
   {$value[1]}%
+ + {foreach $status as $key => $value} + + + + + + {/foreach}
{$key}{$value[0]} + + + + + + +
+
+
   {$value[1]}%
+
-
-
+
+{/if} -
-

Unresolved: By Assignee

- - -{foreach $ownerStatistics as $key => $value} - - - - - -{/foreach} - -
{$key}{$value[0]} - - - - - +{if $ownerStatistics} +
+

Unresolved: By Assignee

+
-
-
   {$value[1]}%
+ + {foreach $ownerStatistics as $key => $value} + + + + + + {/foreach}
{$key}{$value[0]} + + + + + + +
+
+
   {$value[1]}%
+
-
+
+{/if} - - - +{/if} {/block} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index be16143..2adbc8e 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -1128,7 +1128,7 @@ table.issue-summary { table.issue-summary tr td { border: 0; - padding: .1em; + padding: .1em .005em; } table.issue-summary td.graph {