content['links'] = array(
'#prefix' => '
',
'#weight' => -25,
);
// Code to create invoice auto_add link
if (module_exists('storminvoice') && user_access('Storm invoice: add')) {
if ($node->billable && !$node->billed) {
$v = '';
$v = ''. t('Invoice this item:') .'';
$v .= '';
$v .= '- '. l('Add to new invoice', 'storm/invoice/auto_add/new/'. $node->nid) .'
';
$v .= '- '. l('Add to existing invoice', 'storm/invoice/auto_add/existing/'. $node->nid) .'
';
$v .= '
';
}
elseif ($node->billed) {
$v = '';
$v .= ''. t('Item already billed.') .'';
}
else {
$v = '';
$v .= ''. t('Item marked unbillable.') .'';
}
$node->content['links']['auto_invoice'] = array(
'#prefix' => variable_get('storm_icons_display', TRUE) ? '' : '',
'#suffix' => '',
'#value' => $v,
'#weight' => 1,
);
}
$node->content['group1'] = array(
'#prefix' => '',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
$node->content['group1']['organization'] = array(
'#prefix' => '',
'#suffix' => '
',
'#value' => theme('storm_view_item', t('Organization'), l($node->organization_title, 'node/'. $node->organization_nid)),
'#weight' => 1,
);
$node->content['group1']['project'] = array(
'#prefix' => '',
'#suffix' => '
',
'#value' => theme('storm_view_item', t('Project'), l($node->project_title, 'node/'. $node->project_nid)),
'#weight' => 2,
);
$node->content['group1']['task'] = array(
'#prefix' => '',
'#suffix' => '
',
'#value' => theme('storm_view_item', t('Task'), l($node->task_title, 'node/'. $node->task_nid)),
'#weight' => 3,
);
$node->content['group1']['ticket'] = array(
'#prefix' => '',
'#suffix' => '
',
'#value' => theme('storm_view_item', t('Ticket'), l($node->ticket_title, 'node/'. $node->ticket_nid)),
'#weight' => 4,
);
$node->content['body_field'] = array(
'#prefix' => '',
'#suffix' => '
',
'#value' => theme('storm_view_item', t('Description'), $node->content['body']['#value']),
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'body_field') : 0,
);
unset($node->content['body']);
return $node;
}
function theme_stormtimetracking_list_form_report_reports() {
$reports = array(
'std' => t('Standard'),
'for_organization' => t('For an organization'),
'for_organization_w_task' => t('For an org. with tasks'),
'for_project' => t('For a project'),
);
return $reports;
}
function theme_stormtimetracking_list_report($report, $language, $timetrackings) {
switch ($report) {
case 'std':
$header = array(
t('Organization', array(), $language),
t('Project', array(), $language),
t('Title', array(), $language),
t('Date', array(), $language),
t('Billing duration (hours)', array(), $language));
$total_billing_duration = 0;
foreach ($timetrackings as $timetracking) {
$rows[] = array(
$timetracking->organization_title,
$timetracking->project_title,
$timetracking->title,
format_date($timetracking->trackingdate, 'small'),
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
);
$total_billing_duration += $timetracking->billing_duration;
}
$title = ''. t('Timetrackings report', array(), $language) .'
';
break;
case 'for_organization':
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
$header = array(
t('Project', array(), $language),
t('Title', array(), $language),
t('Date', array(), $language),
t('Billing duration (hours)', array(), $language));
$total_billing_duration = 0;
foreach ($timetrackings as $timetracking) {
$rows[] = array(
$timetracking->project_title,
$timetracking->title,
format_date($timetracking->trackingdate, 'small'),
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
);
$total_billing_duration += $timetracking->billing_duration;
}
$title = ''. t('Timetrackings report', array(), $language) .'
';
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'
';
break;
case 'for_organization_w_task':
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
$header = array(
t('Project', array(), $language),
t('Task', array(), $language),
t('Title', array(), $language),
t('Date', array(), $language),
t('Billing duration (hours)', array(), $language));
$total_billing_duration = 0;
foreach ($timetrackings as $timetracking) {
$rows[] = array(
$timetracking->project_title,
$timetracking->task_title,
$timetracking->title,
format_date($timetracking->trackingdate, 'small'),
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
);
$total_billing_duration += $timetracking->billing_duration;
}
$title = ''. t('Timetrackings report', array(), $language) .'
';
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'
';
break;
case 'for_project':
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
$project = node_load($_SESSION['stormtimetracking_list_filter']['project_nid']);
$header = array(
t('Task', array(), $language),
t('Title', array(), $language),
t('Date', array(), $language),
t('Duration (hours)', array(), $language));
$total_billing_duration = 0;
foreach ($timetrackings as $timetracking) {
$rows[] = array(
$timetracking->task_title,
$timetracking->title,
format_date($timetracking->trackingdate, 'small'),
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
);
$total_billing_duration += $timetracking->billing_duration;
}
$title = ''. t('Timetrackings report', array(), $language) .'
';
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'
';
$title .= t('Project : @project', array('@project' => $project->title), $language) .'
';
break;
}
$footer = ''. t('Total billing duration : %total_billing_duration', array('%total_billing_duration' => format_plural($total_billing_duration, '1 hour', '@count hours', array(), $language)), $language) .'
';
return theme('storm_list_report', $header, $rows, $title, $footer);
}