function theme_support_pm_user_hours_summary in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_pm/support_pm.module \theme_support_pm_user_hours_summary()
Pie chart summary.
2 theme calls to theme_support_pm_user_hours_summary()
- support_pm_admin_reports in support_pm/
support_pm.admin.inc - support_pm_plan_overview_weekly in support_pm/
support_pm.module
File
- support_pm/
support_pm.module, line 813 - Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support
Code
function theme_support_pm_user_hours_summary($variables) {
$output = '';
$totals = $variables['totals'];
$load_callback = $variables['load_callback'];
$max = $variables['max'];
$message = $variables['message'];
if (!is_array($totals)) {
return;
}
arsort($totals);
$data = array();
foreach ($totals as $id => $total) {
if ($id) {
if (!isset($data['totals'][$id])) {
$data['totals'][$id] = 0;
}
$data['totals'][$id] += $total;
$data['labels'][$id] = format_plural($total, '1 hr', '@count hrs');
$data['colors'][$id] = support_pm_chartapi_color($id, 'user');
$details = $load_callback($id);
$data['legend'][$id] = check_plain($details->name);
}
}
if (isset($data['totals']) && is_array($data['totals'])) {
foreach ($data['totals'] as $id => $total) {
if (!$total) {
unset($data['totals'][$id]);
unset($data['labels'][$id]);
unset($data['colors'][$id]);
unset($data['legend'][$id]);
}
}
}
if (!empty($data)) {
$total = array_sum($data['totals']);
if ($max && $total < $max) {
if (!isset($data['totals']['filler'])) {
$data['totals']['filler'] = 0;
}
$data['totals']['filler'] += $max - $total;
$data['labels']['filler'] = format_plural($max - $total, '1 hr', '@count hrs');
$data['colors']['filler'] = 'DDDDDD';
$data['legend']['filler'] = $message;
}
// TODO: Allow attribute overrides
$attributes = array(
'class' => 'chart',
);
$output = support_pm_chartapi_render(array(
'cht' => 'p',
'chs' => '450x245',
'chtt' => format_plural($total, '1 hr', '@count hrs'),
'chd' => 't:' . implode(',', $data['totals']),
'chdl' => implode('|', $data['legend']),
'chco' => implode(',', $data['colors']),
'chl' => implode('|', $data['labels']),
'chma' => '25,0,15,15',
), $attributes);
}
return $output;
}