function cvs_total_task_times_group($group_obj, $grouped_objects, $options, $skip_groups = array(), $level = 0, $prev = "", &$total = 0) { $pad_str = ""; for ($k = 0; $k < $level; $k++) { $pad_str .= " "; } $cls_suffix = $level > 2 ? "all" : $level; $next_level = $level + 1; $group_name = $group_obj['group']['name']; echo '"' . $pad_str . iconv('utf-8', 'iso-8859-1', $group_name) . '"' . "\n"; $mem_index = $prev . $group_obj['group']['id']; $group_total = 0; $table_total = 0; // draw the table for the values if (isset($grouped_objects[$mem_index]) && count($grouped_objects[$mem_index]) > 0) { cvs_total_task_times_table($grouped_objects[$mem_index], $pad_str, $options, $group_name, $table_total); $group_total += $table_total; } if (!is_array($group_obj['subgroups'])) { return; } $subgroups = order_groups_by_name($group_obj['subgroups']); foreach ($subgroups as $subgroup) { $sub_total = 0; cvs_total_task_times_group($subgroup, $grouped_objects, $options, $skip_groups, $next_level, $prev . $group_obj['group']['id'] . "_", $sub_total); $group_total += $sub_total; } $total += $group_total; echo "{$group_name};;;;" . lang('total') . ': ' . DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($group_total * 60), "hm", 60) . ";\n\n"; }
function total_task_times_print_group($group_obj, $grouped_objects, $options, $skip_groups = array(), $level = 0, $prev = "", &$total = 0, &$billing_total = 0) { $margin_left = 15 * $level; $cls_suffix = $level > 2 ? "all" : $level; $next_level = $level + 1; $group_name = $group_obj['group']['name']; echo '<div style="margin-left:' . $margin_left.'px;" class="report-group-heading-'.$cls_suffix.'">' . $group_name . '</div>'; $mem_index = $prev . $group_obj['group']['id']; $group_total = 0; $group_billing_total = 0; $table_total = 0; $table_billing_total = 0; // draw the table for the values if (isset($grouped_objects[$mem_index]) && count($grouped_objects[$mem_index]) > 0) { total_task_times_print_table($grouped_objects[$mem_index], $margin_left, $options, $group_name, $table_total, $table_billing_total); $group_total += $table_total; $group_billing_total += $table_billing_total; } if (!is_array($group_obj['subgroups'])) return; $subgroups = order_groups_by_name($group_obj['subgroups']); foreach ($subgroups as $subgroup) { $sub_total = 0; $sub_total_billing = 0; total_task_times_print_group($subgroup, $grouped_objects, $options, array(), $next_level, $prev . $group_obj['group']['id'] . "_", $sub_total, $sub_total_billing); $group_total += $sub_total; $group_billing_total += $sub_total_billing; } $total += $group_total; $billing_total += $group_billing_total; echo '<div style="margin-left:' . $margin_left . 'px;" class="report-group-footer">' . $group_name; echo '<div style="float:right;width:140px;" class="bold right">' . DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($group_total * 60), "hm", 60) . '</div>'; if (array_var($options, 'show_billing') == 'checked') { echo '<div style="float:right;" class="bold">' . config_option('currency_code', '$') . " " . number_format($billing_total, 2) . '</div>'; } echo '</div>'; }
private function total_task_times_csv_export($grouped_timeslots) { $text = ""; $skip_groups = array(); if (!isset($context)) { $context = active_context(); } foreach ($context as $selection) { if ($selection instanceof Member) { $sel_parents = $selection->getAllParentMembersInHierarchy(); foreach ($sel_parents as $sp) { $skip_groups[] = $sp->getId(); } } } $groups = order_groups_by_name($grouped_timeslots['groups']); $total = 0; foreach ($groups as $gid => $group_obj) { $text .= $this->cvs_total_task_times_group($group_obj, $grouped_timeslots['grouped_objects'], array_var($_SESSION, 'total_task_times_parameters'), $skip_groups, 0, "", $total); } $text .= ";;;" . lang('total') . ': ' . ";" . $total . ";\n"; $filename = lang('task time report'); file_put_contents(ROOT . "/tmp/{$filename}.csv", $text); return $filename; }