X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/a58bca2afc5d6457d07c886c7c20fb10c941752a..47b6c704a5375b9f98376bf4eb727d4ee49fe3e2:/WEB-INF/lib/ttReportHelper.class.php diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 4d510bbb..538830c3 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -127,7 +127,7 @@ class ttReportHelper { $canViewReports = $user->can('view_reports') || $user->can('view_all_reports'); $isClient = $user->isClient(); - $group_by_option = $options['group_by']; + $group_by_option = $options['group_by1']; $convertTo12Hour = ('%I:%M %p' == $user->time_format) && ($options['show_start'] || $options['show_end']); // Prepare a query for time items in tt_log table. @@ -394,7 +394,7 @@ class ttReportHelper { static function getSubtotals($options) { global $user; - $group_by_option = $options['group_by']; + $group_by_option = $options['group_by1']; if ('no_grouping' == $group_by_option) return null; $mdb2 = getConnection(); @@ -657,7 +657,7 @@ class ttReportHelper { } // prepareReportBody - prepares an email body for report. - static function prepareReportBody($bean, $comment) + static function prepareReportBody($options, $comment = null) { global $user; global $i18n; @@ -665,10 +665,9 @@ class ttReportHelper { // Determine these once as they are used in multiple places in this function. $canViewReports = $user->can('view_reports') || $user->can('view_all_reports'); $isClient = $user->isClient(); - $options = ttReportHelper::getReportOptions($bean); $items = ttReportHelper::getItems($options); - $group_by = $bean->getAttribute('group_by'); + $group_by = $options['group_by1']; if ($group_by && 'no_grouping' != $group_by) $subtotals = ttReportHelper::getSubtotals($options); $totals = ttReportHelper::getTotals($options); @@ -700,321 +699,6 @@ class ttReportHelper { // Output comment. if ($comment) $body .= '
'.htmlspecialchars($comment).'
'; - if ($bean->getAttribute('chtotalsonly')) { - // Totals only report. Output subtotals. - - // Determine group_by header. - if ('cf_1' == $group_by) - $group_by_header = htmlspecialchars($custom_fields->fields[0]['label']); - else { - $key = 'label.'.$group_by; - $group_by_header = $i18n->get($key); - } - - $body .= '| '.$group_by_header.' | '; - if ($bean->getAttribute('chduration')) - $body .= ''.$i18n->get('label.duration').' | '; - if ($bean->getAttribute('chunits')) - $body .= ''.$i18n->get('label.work_units_short').' | '; - if ($bean->getAttribute('chcost')) - $body .= ''.$i18n->get('label.cost').' | '; - $body .= '
| '.($subtotal['name'] ? htmlspecialchars($subtotal['name']) : ' ').' | '; - if ($bean->getAttribute('chduration')) { - $body .= ''; - if ($subtotal['time'] <> '0:00') $body .= $subtotal['time']; - $body .= ' | '; - } - if ($bean->getAttribute('chunits')) { - $body .= ''; - $body .= $subtotal['units']; - $body .= ' | '; - } - if ($bean->getAttribute('chcost')) { - $body .= ''; - $body .= ($canViewReports || $isClient) ? $subtotal['cost'] : $subtotal['expenses']; - $body .= ' | '; - } - $body .= '
| '.$i18n->get('label.total').' | '; - if ($bean->getAttribute('chduration')) { - $body .= ''; - if ($totals['time'] <> '0:00') $body .= $totals['time']; - $body .= ' | '; - } - if ($bean->getAttribute('chunits')) { - $body .= ''; - $body .= $totals['units']; - $body .= ' | '; - } - if ($bean->getAttribute('chcost')) { - $body .= ''.htmlspecialchars($user->currency).' '; - $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; - $body .= ' | '; - } - $body .= '
| '.$i18n->get('label.date').' | '; - if ($canViewReports || $isClient) - $body .= ''.$i18n->get('label.user').' | '; - if ($bean->getAttribute('chclient')) - $body .= ''.$i18n->get('label.client').' | '; - if ($bean->getAttribute('chproject')) - $body .= ''.$i18n->get('label.project').' | '; - if ($bean->getAttribute('chtask')) - $body .= ''.$i18n->get('label.task').' | '; - if ($bean->getAttribute('chcf_1')) - $body .= ''.htmlspecialchars($custom_fields->fields[0]['label']).' | '; - if ($bean->getAttribute('chstart')) - $body .= ''.$i18n->get('label.start').' | '; - if ($bean->getAttribute('chfinish')) - $body .= ''.$i18n->get('label.finish').' | '; - if ($bean->getAttribute('chduration')) - $body .= ''.$i18n->get('label.duration').' | '; - if ($bean->getAttribute('chunits')) - $body .= ''.$i18n->get('label.work_units_short').' | '; - if ($bean->getAttribute('chnote')) - $body .= ''.$i18n->get('label.note').' | '; - if ($bean->getAttribute('chcost')) - $body .= ''.$i18n->get('label.cost').' | '; - if ($bean->getAttribute('chpaid')) - $body .= ''.$i18n->get('label.paid').' | '; - if ($bean->getAttribute('chip')) - $body .= ''.$i18n->get('label.ip').' | '; - if ($bean->getAttribute('chinvoice')) - $body .= ''.$i18n->get('label.invoice').' | '; - $body .= '
| '.$i18n->get('label.subtotal').' | '; - $subtotal_name = htmlspecialchars($subtotals[$prev_grouped_by]['name']); - if ($canViewReports || $isClient) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chclient')) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chproject')) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chtask')) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chcf_1')) $body .= ''.($group_by == 'cf_1' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chstart')) $body .= ''; - if ($bean->getAttribute('chfinish')) $body .= ' | '; - if ($bean->getAttribute('chduration')) $body .= ' | '.$subtotals[$prev_grouped_by]['time'].' | '; - if ($bean->getAttribute('chunits')) $body .= ''.$subtotals[$prev_grouped_by]['units'].' | '; - if ($bean->getAttribute('chnote')) $body .= ''; - if ($bean->getAttribute('chcost')) { - $body .= ' | '; - $body .= ($canViewReports || $isClient) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses']; - $body .= ' | '; - } - if ($bean->getAttribute('chpaid')) $body .= ''; - if ($bean->getAttribute('chip')) $body .= ' | '; - if ($bean->getAttribute('chinvoice')) $body .= ' | '; - $body .= ' |
| '.$record['date'].' | '; - if ($canViewReports || $isClient) - $body .= ''.htmlspecialchars($record['user']).' | '; - if ($bean->getAttribute('chclient')) - $body .= ''.htmlspecialchars($record['client']).' | '; - if ($bean->getAttribute('chproject')) - $body .= ''.htmlspecialchars($record['project']).' | '; - if ($bean->getAttribute('chtask')) - $body .= ''.htmlspecialchars($record['task']).' | '; - if ($bean->getAttribute('chcf_1')) - $body .= ''.htmlspecialchars($record['cf_1']).' | '; - if ($bean->getAttribute('chstart')) - $body .= ''.$record['start'].' | '; - if ($bean->getAttribute('chfinish')) - $body .= ''.$record['finish'].' | '; - if ($bean->getAttribute('chduration')) - $body .= ''.$record['duration'].' | '; - if ($bean->getAttribute('chunits')) - $body .= ''.$record['units'].' | '; - if ($bean->getAttribute('chnote')) - $body .= ''.htmlspecialchars($record['note']).' | '; - if ($bean->getAttribute('chcost')) - $body .= ''.$record['cost'].' | '; - if ($bean->getAttribute('chpaid')) { - $body .= ''; - $body .= $record['paid'] == 1 ? $i18n->get('label.yes') : $i18n->get('label.no'); - $body .= ' | '; - } - if ($bean->getAttribute('chip')) { - $body .= ''; - $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $record['created_ip'].' '.$record['created']; - $body .= ' | '; - } - if ($bean->getAttribute('chinvoice')) - $body .= ''.htmlspecialchars($record['invoice']).' | '; - $body .= '
| '.$i18n->get('label.subtotal').' | '; - $subtotal_name = htmlspecialchars($subtotals[$cur_grouped_by]['name']); - if ($canViewReports || $isClient) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chclient')) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chproject')) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chtask')) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chcf_1')) $body .= ''.($group_by == 'cf_1' ? $subtotal_name : '').' | '; - if ($bean->getAttribute('chstart')) $body .= ''; - if ($bean->getAttribute('chfinish')) $body .= ' | '; - if ($bean->getAttribute('chduration')) $body .= ' | '.$subtotals[$cur_grouped_by]['time'].' | '; - if ($bean->getAttribute('chunits')) $body .= ''.$subtotals[$cur_grouped_by]['units'].' | '; - if ($bean->getAttribute('chnote')) $body .= ''; - if ($bean->getAttribute('chcost')) { - $body .= ' | '; - $body .= ($canViewReports || $isClient) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses']; - $body .= ' | '; - } - if ($bean->getAttribute('chpaid')) $body .= ''; - if ($bean->getAttribute('chip')) $body .= ' | '; - if ($bean->getAttribute('chinvoice')) $body .= ' | '; - $body .= ' |
| '.$i18n->get('label.total').' | '; - if ($canViewReports || $isClient) $body .= ''; - if ($bean->getAttribute('chclient')) $body .= ' | '; - if ($bean->getAttribute('chproject')) $body .= ' | '; - if ($bean->getAttribute('chtask')) $body .= ' | '; - if ($bean->getAttribute('chcf_1')) $body .= ' | '; - if ($bean->getAttribute('chstart')) $body .= ' | '; - if ($bean->getAttribute('chfinish')) $body .= ' | '; - if ($bean->getAttribute('chduration')) $body .= ' | '.$totals['time'].' | '; - if ($bean->getAttribute('chunits')) $body .= ''.$totals['units'].' | '; - if ($bean->getAttribute('chnote')) $body .= ''; - if ($bean->getAttribute('chcost')) { - $body .= ' | '.htmlspecialchars($user->currency).' '; - $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; - $body .= ' | '; - } - if ($bean->getAttribute('chpaid')) $body .= ''; - if ($bean->getAttribute('chip')) $body .= ' | '; - if ($bean->getAttribute('chinvoice')) $body .= ' | '; - $body .= ' |
'.$i18n->get('form.mail.footer').'
'; - - // Finish creating email body. - $body .= '