* @package report * @version $Id$ * @link http://www.zentao.net */ ?> app->getWebRoot() . 'fusioncharts/'; $swfFile = "fcf_$swf.swf"; return << EOT; } /** * Create the js code of chart. * * @param string $swf the swf type * @param string $dataURL the date url * @param int $width * @param int $height * @access public * @return string */ public function createJSChart($swf, $dataXML, $width = 'auto', $height = 500) { $jsRoot = $this->app->getWebRoot() . 'js/'; static $count = 0; $count ++; $chartRoot = $this->app->getWebRoot() . 'fusioncharts/'; $swfFile = "fcf_$swf.swf"; $divID = "chart{$count}div"; $chartID = "chart{$count}"; $js = ''; if($count == 1) $js = ""; return << EOT; } public function createJSChartFlot($projectName, $dataJSON, $count, $width = 'auto', $height = 500) { $this->app->loadLang('project'); $jsRoot = $this->app->getWebRoot() . 'js/'; $width = $width . 'px'; $height = $height . 'px'; return <<

$projectName {$this->lang->project->burn}

EOT; } /** * Create xml data of single charts. * * @param array $sets * @param array $chartOptions * @param array $colors * @access public * @return string the xml data. */ public function createSingleXML($sets, $chartOptions = array(), $colors = array()) { $data = pack("CCC", 0xef, 0xbb, 0xbf); // utf-8 bom. $data .=""; $data .= ' $value) $data .= " $key='$value'"; $data .= ">"; if(empty($colors)) $colors = $this->lang->report->colors; $colorCount = count($colors); $i = 0; foreach($sets as $set) { if($i == $colorCount) $i = 0; $color = $colors[$i]; $i ++; $data .= ""; } $data .= ""; return $data; } public function createSingleJSON($sets) { $data = '['; foreach($sets as $set) { $data .= " [$set->name, $set->value],"; } $data = rtrim($data, ','); $data .= ']'; return $data; } /** * Create the js code to render chart. * * @param int $chartCount * @access public * @return string */ public function renderJsCharts($chartCount) { $js = ''; return $js; } /** * Compute percent of every item. * * @param array $datas * @access public * @return array */ public function computePercent($datas) { $sum = 0; foreach($datas as $data) $sum += $data->value; foreach($datas as $data) $data->percent = round($data->value / $sum, 2); return $datas; } /** * Get projects. * * @access public * @return void */ public function getProjects() { $projects = $this->dao->select('id, name')->from(TABLE_PROJECT)->where('status')->eq('done')->fetchAll(); foreach($projects as $project) { $total = $this->dao->select('SUM(estimate) AS estimate, SUM(consumed) AS consumed') ->from(TABLE_TASK) ->where('project')->eq($project->id) ->andWhere('status')->ne('cancel') ->andWhere('deleted')->eq(0) ->fetch(); $stories = $this->dao->select("count(*) as count")->from(TABLE_PROJECTSTORY)->where('project')->eq($project->id)->fetch(); $bugs = $this->dao->select("count(*) as count")->from(TABLE_BUG)->where('project')->eq($project->id)->fetch(); $dev = $this->dao->select('SUM(consumed) as consumed') ->from(TABLE_TASK) ->where('project')->eq($project->id) ->andWhere('type')->eq('devel') ->andWhere('status')->ne('cancel') ->andWhere('deleted')->eq(0) ->fetch(); $test = $this->dao->select('SUM(consumed) as consumed') ->from(TABLE_TASK) ->where('project')->eq($project->id) ->andWhere('type')->eq('test') ->andWhere('status')->ne('cancel') ->andWhere('deleted')->eq(0) ->fetch(); $project->estimate = $total->estimate; $project->consumed = $total->consumed; $project->stories = $stories->count; $project->bugs = $bugs->count; $project->devConsumed = empty($dev->consumed) ? 0 : $dev->consumed; $project->testConsumed = empty($test->consumed) ? 0 : $dev->consumed; } return $projects; } public function getProducts() { $products = $this->dao->select('id, code, name, PO')->from(TABLE_PRODUCT)->where('deleted')->eq(0)->fetchAll('id'); $plans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->fetchAll('id'); $planStories = $this->dao->select('plan, id, status')->from(TABLE_STORY)->where('deleted')->eq(0)->andWhere('plan')->in(array_keys($plans))->fetchGroup('plan', 'id'); foreach($planStories as $planID => $stories) { foreach($stories as $story) $statusList[$story->status][] = $story; foreach(array_keys($statusList) as $status) $plans[$planID]->status[$status] = count($statusList[$status]); } foreach($plans as $plan) $products[$plan->product]->plans[] = $plan; return $products; } public function getBugs($begin, $end) { $bugGroups = $this->dao->select('id, resolution, openedBy')->from(TABLE_BUG) ->where('deleted')->eq(0) ->andWhere('openedDate')->gt($begin) ->andWhere('openedDate')->lt($end) ->fetchGroup('openedBy', 'id'); $bugSummary = array(); foreach($bugGroups as $user => $bugs) { foreach($bugs as $bug) { $bugSummary[$user][$bug->resolution] = empty($bugSummary[$user][$bug->resolution]) ? 1 : $bugSummary[$user][$bug->resolution] + 1; } $bugSummary[$user]['all'] = count($bugs); } return $bugSummary; } public function getWorkload() { $tasks = $this->dao->select('t1.*, t2.name as projectName') ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2') ->on('t1.project = t2.id') ->where('t1.deleted')->eq(0) ->andWhere('t1.status')->notin('cancel, closed') ->fetchGroup('assignedTo'); $bugs = $this->dao->select('t1.*, t2.name as productName') ->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product = t2.id') ->where('t1.deleted')->eq(0) ->andWhere('t1.status')->eq('active') ->fetchGroup('assignedTo'); $workload = array(); foreach($tasks as $user => $userTasks) { if($user) { foreach($userTasks as $task) { $workload[$user]['task'][$task->projectName]['count'] = isset($workload[$user]['task'][$task->projectName]['count']) ? $workload[$user]['task'][$task->projectName]['count'] + 1 : 1; $workload[$user]['task'][$task->projectName]['manhour'] = isset($workload[$user]['task'][$task->projectName]['manhour']) ? $workload[$user]['task'][$task->projectName]['manhour'] + $task->consumed : $task->consumed; } } } foreach($bugs as $user => $userBugs) { if($user) { foreach($userBugs as $bug) { $workload[$user]['bug'][$bug->productName]['count'] = isset($workload[$user]['bug'][$bug->productName]['count']) ? $workload[$user]['bug'][$bug->productName]['count'] + 1 : 1; } } } return $workload; } }