diff --git a/module/report/model.php b/module/report/model.php index 8b01517ab1..b2952578a1 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -287,37 +287,43 @@ class reportModel extends model if($assign == 'noassign') { - $members = $this->dao->select('t1.account,t2.name,t1.root')->from(TABLE_TEAM)->alias('t1') + $members = $this->dao->select('t1.account,t2.name,t1.root,t3.id as project,t3.name as projectname')->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t2.id = t1.root') + ->leftJoin(TABLE_PROJECT)->alias('t3')->on('t3.id = t2.project') ->where('t2.status')->notin('cancel, closed, done, suspended') ->beginIF($dept)->andWhere('t1.account')->in(array_keys($deptUsers))->fi() ->andWhere('t1.type')->eq('execution') ->andWhere("t1.account NOT IN(SELECT `assignedTo` FROM " . TABLE_TASK . " WHERE `execution` = t1.`root` AND `status` NOT IN('cancel, closed, done, pause') AND assignedTo != '' GROUP BY assignedTo)") ->fetchGroup('account', 'name'); - $workload = array(); + $workload = array(); if(!empty($members)) { foreach($members as $member => $executions) { + $project = array(); if(!empty($executions)) { foreach($executions as $name => $execution) { - $workload[$member]['task'][$name]['count'] = 0; - $workload[$member]['task'][$name]['manhour'] = 0; - $workload[$member]['task'][$name]['executionID'] = $execution->root; - $workload[$member]['total']['count'] = 0; - $workload[$member]['total']['manhour'] = 0; + $project[$execution->projectname]['projectID'] = $execution->project; + $project[$execution->projectname]['execution'][$name]['executionID'] = $execution->root; + $project[$execution->projectname]['execution'][$name]['count'] = 0; + $project[$execution->projectname]['execution'][$name]['manhour'] = 0; + + $workload[$member]['total']['count'] = 0; + $workload[$member]['total']['manhour'] = 0; } } + $workload[$member]['task']['project'] = $project; } } return $workload; } - $stmt = $this->dao->select('t1.*, t2.name as executionName')->from(TABLE_TASK)->alias('t1') + $stmt = $this->dao->select('t1.*, t2.name as executionName,t3.name as projectname')->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution = t2.id') + ->leftJoin(TABLE_PROJECT)->alias('t3')->on('t3.id = t2.project') ->where('t1.deleted')->eq(0) ->andWhere('t1.status')->in('wait,pause,doing') ->andWhere('t2.deleted')->eq(0) @@ -371,17 +377,22 @@ class reportModel extends model { if($user) { + $project = array(); foreach($userTasks as $task) { if(isset($parents[$task->id])) continue; - $workload[$user]['task'][$task->executionName]['count'] = isset($workload[$user]['task'][$task->executionName]['count']) ? $workload[$user]['task'][$task->executionName]['count'] + 1 : 1; - $workload[$user]['task'][$task->executionName]['manhour'] = isset($workload[$user]['task'][$task->executionName]['manhour']) ? $workload[$user]['task'][$task->executionName]['manhour'] + $task->left : $task->left; - $workload[$user]['task'][$task->executionName]['executionID'] = $task->execution; - $workload[$user]['total']['count'] = isset($workload[$user]['total']['count']) ? $workload[$user]['total']['count'] + 1 : 1; + + $project[$task->projectname]['projectID'] = isset($project[$task->projectname]['projectID']) ? $project[$task->projectname]['projectID'] : $task->project; + $project[$task->projectname]['execution'][$task->executionName]['executionID'] = isset($project[$task->projectname]['execution'][$task->executionName]['executionID']) ? $project[$task->projectname]['execution'][$task->executionName]['executionID'] : $task->execution; + $project[$task->projectname]['execution'][$task->executionName]['count'] = isset($project[$task->projectname]['execution'][$task->executionName]['count']) ? $project[$task->projectname]['execution'][$task->executionName]['count'] + 1 : 1; + $project[$task->projectname]['execution'][$task->executionName]['manhour'] = isset($project[$task->projectname]['execution'][$task->executionName]['manhour']) ? $project[$task->projectname]['execution'][$task->executionName]['manhour'] + $task->left : $task->left; + + $workload[$user]['total']['count'] = isset($workload[$user]['total']['count']) ? $workload[$user]['total']['count'] + 1 : 1; $workload[$user]['total']['manhour'] = isset($workload[$user]['total']['manhour']) ? $workload[$user]['total']['manhour'] + $task->left : $task->left; } + $workload[$user]['task']['project'] = $project; } - } + } unset($workload['closed']); return $workload; } diff --git a/module/report/view/workload.html.php b/module/report/view/workload.html.php index df2cffe6ce..2d01a8c7f6 100644 --- a/module/report/view/workload.html.php +++ b/module/report/view/workload.html.php @@ -70,6 +70,7 @@ report->user;?> + report->project ;?> report->execution;?> report->task;?> report->remain;?> @@ -83,24 +84,31 @@ $load):?> - - - $info):?> - - ';?> - createLink('execution', 'view', "executionID={$info['executionID']}"), $execution);?> - - - - - - + + $info) foreach($info['execution'] as $exec => $execinfo) $countusername ++;?> + + $info):?> + + + $execinfo):?> + ";?> + + createLink('project', 'view', "projectID={$info['projectID']}"), $project);?> - '; $id ++;?> + createLink('execution', 'view', "executionID={$execinfo['executionID']}"), $exec);?> + + + + + + + + "; $idprojectname ++; $idusername ++;?> + - +