* fix bug for export with child.
This commit is contained in:
+16
-10
@@ -251,14 +251,29 @@ class project extends control
|
||||
|
||||
/* Get tasks and group them. */
|
||||
if(empty($groupBy))$groupBy = 'story';
|
||||
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $productID = 0, $status = 'all', $modules = 0, $groupBy);
|
||||
$sort = $this->loadModel('common')->appendOrder($groupBy);
|
||||
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $productID = 0, $status = 'all', $modules = 0, $sort);
|
||||
$groupBy = str_replace('`', '', $groupBy);
|
||||
$taskLang = $this->lang->task;
|
||||
$groupByList = array();
|
||||
$groupTasks = array();
|
||||
|
||||
$groupTasks = array();
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
$groupTasks[] = $task;
|
||||
if(isset($task->children))
|
||||
{
|
||||
foreach($task->children as $child) $groupTasks[] = $child;
|
||||
$task->children = true;
|
||||
unset($task->children);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get users. */
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
$tasks = $groupTasks;
|
||||
$groupTasks = array();
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($groupBy == 'story')
|
||||
@@ -290,14 +305,6 @@ class project extends control
|
||||
{
|
||||
$groupTasks[$task->$groupBy][] = $task;
|
||||
}
|
||||
if(isset($task->children))
|
||||
{
|
||||
foreach($task->children as $child)
|
||||
{
|
||||
$groupTasks[$child->assignedToRealName][] = $child;
|
||||
}
|
||||
$task->children = true;
|
||||
}
|
||||
}
|
||||
/* Process closed data when group by assignedTo. */
|
||||
if($groupBy == 'assignedTo' and isset($groupTasks['Closed']))
|
||||
@@ -307,7 +314,6 @@ class project extends control
|
||||
$groupTasks['closed'] = $closedTasks;
|
||||
}
|
||||
|
||||
|
||||
/* Assign. */
|
||||
$this->app->loadLang('tree');
|
||||
$this->view->members = $this->project->getTeamMembers($projectID);
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<ul class='dropdown-menu' id='exportActionMenu'>
|
||||
<?php
|
||||
$misc = common::hasPriv('task', 'export') ? "class='export iframe' data-width='700'" : "class=disabled";
|
||||
$link = common::hasPriv('task', 'export') ? $this->createLink('task', 'export', "project=$projectID&orderBy=$orderBy") : '#';
|
||||
$link = common::hasPriv('task', 'export') ? $this->createLink('task', 'export', "project=$projectID&orderBy=$orderBy&type=$browseType") : '#';
|
||||
echo "<li>" . html::a($link, $lang->task->export, '', $misc) . "</li>";
|
||||
?>
|
||||
</ul>
|
||||
|
||||
@@ -27,10 +27,10 @@ $config->task->editor->cancel = array('id' => 'comment', 'tools' => 'simpleToo
|
||||
$config->task->editor->pause = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
|
||||
$config->task->exportFields = '
|
||||
id, project, module, progress, story,
|
||||
id, project, module, story,
|
||||
name, desc,
|
||||
type, pri,estStarted, realStarted, deadline, status,estimate, consumed, left,
|
||||
mailto,
|
||||
mailto, progress,
|
||||
openedBy, openedDate, assignedTo, assignedDate,
|
||||
finishedBy, finishedDate, canceledBy, canceledDate,
|
||||
closedBy, closedDate, closedReason,
|
||||
|
||||
+40
-4
@@ -1179,7 +1179,7 @@ class task extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function export($projectID, $orderBy)
|
||||
public function export($projectID, $orderBy, $type)
|
||||
{
|
||||
$project = $this->project->getById($projectID);
|
||||
$allExportFields = $this->config->task->exportFields;
|
||||
@@ -1191,6 +1191,7 @@ class task extends control
|
||||
$taskLang = $this->lang->task;
|
||||
|
||||
/* Create field lists. */
|
||||
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
||||
$fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $allExportFields);
|
||||
foreach($fields as $key => $fieldName)
|
||||
{
|
||||
@@ -1205,7 +1206,7 @@ class task extends control
|
||||
{
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskQueryCondition)
|
||||
->beginIF($this->post->exportType == 'selected')->andWhere('t1.id')->in($this->cookie->checkedItem)->fi()
|
||||
->orderBy($orderBy)->fetchAll('id');
|
||||
->orderBy($sort)->fetchAll('id');
|
||||
|
||||
foreach($tasks as $key => $task)
|
||||
{
|
||||
@@ -1222,7 +1223,6 @@ class task extends control
|
||||
{
|
||||
$task->progress = round($task->consumed / ($task->consumed + $task->left), 2) * 100;
|
||||
}
|
||||
|
||||
$task->progress .= '%';
|
||||
}
|
||||
}
|
||||
@@ -1252,9 +1252,34 @@ class task extends control
|
||||
$relatedFiles = $this->dao->select('id, objectID, pathname, title')->from(TABLE_FILE)->where('objectType')->eq('task')->andWhere('objectID')->in(@array_keys($tasks))->andWhere('extra')->ne('editor')->fetchGroup('objectID');
|
||||
$relatedModules = $this->loadModel('tree')->getTaskOptionMenu($projectID);
|
||||
|
||||
$children = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)->andWhere('parent')->in(array_keys($tasks))->fetchGroup('parent', 'id');
|
||||
$children = $this->dao->select('*')->from(TABLE_TASK)->where('deleted')->eq(0)
|
||||
->andWhere('parent')->in(array_keys($tasks))
|
||||
->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi()
|
||||
->orderBy($sort)
|
||||
->fetchGroup('parent', 'id');
|
||||
if(!empty($children))
|
||||
{
|
||||
foreach($children as $parent => $childTasks)
|
||||
{
|
||||
foreach($childTasks as $task)
|
||||
{
|
||||
/* Compute task progress. */
|
||||
if($task->consumed == 0 and $task->left == 0)
|
||||
{
|
||||
$task->progress = 0;
|
||||
}
|
||||
elseif($task->consumed != 0 and $task->left == 0)
|
||||
{
|
||||
$task->progress = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
$task->progress = round($task->consumed / ($task->consumed + $task->left), 2) * 100;
|
||||
}
|
||||
$task->progress .= '%';
|
||||
}
|
||||
}
|
||||
|
||||
$position = 0;
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
@@ -1267,6 +1292,17 @@ class task extends control
|
||||
}
|
||||
}
|
||||
|
||||
if($type == 'group')
|
||||
{
|
||||
$groupTasks = array();
|
||||
foreach($tasks as $task) $groupTasks[$task->$orderBy][] = $task;
|
||||
$tasks = array();
|
||||
foreach($groupTasks as $groupTask)
|
||||
{
|
||||
foreach($groupTask as $task)$tasks[] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($this->post->fileType == 'csv')
|
||||
|
||||
Reference in New Issue
Block a user