function per_project_xls() { $this->load->model('modules'); $this->modules->analyze_clock_entries_per_project_report(); excel_create($this->data['results'], 'filename'); //if you want to write it to disk and/or send it as an attachment }
public function per_task_xls() { $this->load->model('modules'); $this->modules->analyze_clock_entries_per_task_report(); $results = $this->data['results']; $totals = []; $old_tid = 0; $i = 0; $data = []; foreach ($results as $tid => $tasks) { if (!isset($totals[$tid])) { $totals[$tid] = 0; } if ($old_tid != $tid) { $task_info = $this->modules->get_task($tid, true); $task_name = $task_info['name']; if ($old_tid > 0) { $data[$i][] = 'Task Total'; $data[$i][] = ''; $data[$i][] = $this->modules->format_seconds($totals[$old_tid]); unset($totals[$old_tid]); $i++; } $old_tid = $tid; } $old_uid = 0; foreach ($tasks as $uid => $times) { $user_name = ""; if ($old_uid != $uid) { $user_info = $this->modules->get_user($uid, true); $user_name = $user_info['upro_first_name'] . ' ' . $user_info['upro_last_name']; $old_uid = $uid; } $total_time = 0; foreach ($times as $time) { $total_time += $time; } $totals[$tid] += $total_time; $data[$i][] = $task_name; $data[$i][] = $user_name; $data[$i][] = $this->modules->format_seconds($total_time); $i++; } } foreach ($totals as $tid => $time) { $data[$i][] = 'Task Total'; $data[$i][] = ''; $data[$i][] = $this->modules->format_seconds($totals[$tid]); $i++; } excel_create($data, 'Task Report'); }