X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=topdf.php;h=3177d155973b8e67c6c7845858e97c3948a3fb96;hb=e02d7592b0556895e35f4d028939197c132f6b09;hp=0126bc616b6a0f45dcf110c36b1d213e08f2d7f5;hpb=b027832862272283d9203c994ec8fd39f6196887;p=timetracker.git diff --git a/topdf.php b/topdf.php index 0126bc61..3177d155 100644 --- a/topdf.php +++ b/topdf.php @@ -35,6 +35,12 @@ import('form.Form'); import('form.ActionForm'); import('ttReportHelper'); +// Access check. +if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) { + header('Location: access_denied.php'); + exit(); +} + // Check whether TCPDF library is available. if (!file_exists('WEB-INF/lib/tcpdf/')) die('TCPDF library is not found in WEB-INF/lib/tcpdf/'); @@ -42,14 +48,8 @@ if (!file_exists('WEB-INF/lib/tcpdf/')) // Include TCPDF library. require_once('WEB-INF/lib/tcpdf/tcpdf.php'); -// Access check. -if (!ttAccessCheck(right_view_reports)) { - header('Location: access_denied.php'); - exit(); -} - // Use custom fields plugin if it is enabled. -if (in_array('cf', explode(',', $user->plugins))) { +if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); $custom_fields = new CustomFields($user->team_id); } @@ -68,7 +68,7 @@ if ('no_grouping' != $group_by) { $group_by_header = $custom_fields->fields[0]['label']; else { $key = 'label.'.$group_by; - $group_by_header = $i18n->getKey($key); + $group_by_header = $i18n->get($key); } } @@ -87,13 +87,16 @@ if ($items && 'no_grouping' != $group_by) { $cur_grouped_by = ''; } +// Build a string to use as filename for the files being downloaded. +$filename = strtolower($i18n->get('title.report')).'_'.$bean->mValues['start_date'].'_'.$bean->mValues['end_date']; + // Start preparing HTML to build PDF from. $styleHeader = 'style="background-color:#a6ccf7;"'; $styleSubtotal = 'style="background-color:#e0e0e0;"'; $styleCentered = 'style="text-align:center;"'; $styleRightAligned = 'style="text-align:right;"'; -$title = $i18n->getKey('title.report').": ".$totals['start_date']." - ".$totals['end_date']; +$title = $i18n->get('title.report').": ".$totals['start_date']." - ".$totals['end_date']; $html = '

'.$title.'

'; $html .= ''; @@ -104,8 +107,8 @@ if ($totals_only) { $html .= ''; $html .= ""; $html .= ''; - if ($bean->getAttribute('chduration')) { $colspan++; $html .= "'; } - if ($bean->getAttribute('chcost')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chduration')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chcost')) { $colspan++; $html .= "'; } $html .= ''; $html .= ''; // Print subtotals. @@ -126,7 +129,7 @@ if ($totals_only) { // Print totals. $html .= ''; $html .= ""; - $html .= ''; + $html .= ''; if ($bean->getAttribute('chduration')) $html .= "'; if ($bean->getAttribute('chcost')) { $html .= "'; $html .= ""; - $html .= ''; - if ($user->canManageTeam() || $user->isClient()) { $colspan++; $html .= ''; } - if ($bean->getAttribute('chclient')) { $colspan++; $html .= ''; } - if ($bean->getAttribute('chproject')) { $colspan++; $html .= ''; } - if ($bean->getAttribute('chtask')) { $colspan++; $html .= ''; } + $html .= ''; + if ($user->canManageTeam() || $user->isClient()) { $colspan++; $html .= ''; } + if ($bean->getAttribute('chclient')) { $colspan++; $html .= ''; } + if ($bean->getAttribute('chproject')) { $colspan++; $html .= ''; } + if ($bean->getAttribute('chtask')) { $colspan++; $html .= ''; } if ($bean->getAttribute('chcf_1')) { $colspan++; $html .= ''; } - if ($bean->getAttribute('chstart')) { $colspan++; $html .= "'; } - if ($bean->getAttribute('chfinish')) { $colspan++; $html .= "'; } - if ($bean->getAttribute('chduration')) { $colspan++; $html .= "'; } - if ($bean->getAttribute('chnote')) { $colspan++; $html .= ''; } - if ($bean->getAttribute('chcost')) { $colspan++; $html .= "'; } - if ($bean->getAttribute('chinvoice')) { $colspan++; $html .= ''; } + if ($bean->getAttribute('chstart')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chfinish')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chduration')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chnote')) { $colspan++; $html .= ''; } + if ($bean->getAttribute('chcost')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chpaid')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chip')) { $colspan++; $html .= "'; } + if ($bean->getAttribute('chinvoice')) { $colspan++; $html .= ''; } $html .= ''; $html .= ''; @@ -167,7 +172,7 @@ if ($totals_only) { $cur_grouped_by = $item['grouped_by']; if ($cur_grouped_by != $prev_grouped_by && !$first_pass) { $html .= ''; - $html .= ''; + $html .= ''; if ($user->canManageTeam() || $user->isClient()) { $html .= ''; } + if ($bean->getAttribute('chpaid')) $html .= ''; + if ($bean->getAttribute('chip')) $html .= ''; if ($bean->getAttribute('chinvoice')) $html .= ''; $html .= ''; $html .= ''; @@ -232,6 +239,16 @@ if ($totals_only) { $html .= $item['expense']; $html .= ''; } + if ($bean->getAttribute('chpaid')) { + $html .= ''; + } + if ($bean->getAttribute('chip')) { + $html .= ''; + } if ($bean->getAttribute('chinvoice')) $html .= ''; $html .= ''; @@ -242,7 +259,7 @@ if ($totals_only) { // Print a terminating subtotal. if ($print_subtotals) { $html .= ''; - $html .= ''; + $html .= ''; if ($user->canManageTeam() || $user->isClient()) { $html .= ''; } + if ($bean->getAttribute('chpaid')) $html .= ''; + if ($bean->getAttribute('chip')) $html .= ''; if ($bean->getAttribute('chinvoice')) $html .= ''; $html .= ''; } @@ -287,7 +306,7 @@ if ($totals_only) { // Print totals. $html .= ''; $html .= ''; - $html .= ''; + $html .= ''; if ($user->canManageTeam() || $user->isClient()) $html .= ''; if ($bean->getAttribute('chclient')) $html .= ''; if ($bean->getAttribute('chproject')) $html .= ''; @@ -305,6 +324,8 @@ if ($totals_only) { $html .= $totals['expenses']; $html .= ''; } + if ($bean->getAttribute('chpaid')) $html .= ''; + if ($bean->getAttribute('chip')) $html .= ''; if ($bean->getAttribute('chinvoice')) $html .= ''; $html .= ''; $html .= '
'.htmlspecialchars($group_by_header).'".$i18n->getKey('label.duration').'".$i18n->getKey('label.cost').'".$i18n->get('label.duration').'".$i18n->get('label.cost').'
 
'.$i18n->getKey('label.total').''.$i18n->get('label.total').'".$totals['time'].'"; @@ -145,18 +148,20 @@ if ($totals_only) { // Table header. $html .= '
'.$i18n->getKey('label.date').''.$i18n->getKey('label.user').''.$i18n->getKey('label.client').''.$i18n->getKey('label.project').''.$i18n->getKey('label.task').''.$i18n->get('label.date').''.$i18n->get('label.user').''.$i18n->get('label.client').''.$i18n->get('label.project').''.$i18n->get('label.task').''.htmlspecialchars($custom_fields->fields[0]['label']).'".$i18n->getKey('label.start').'".$i18n->getKey('label.finish').'".$i18n->getKey('label.duration').''.$i18n->getKey('label.note').'".$i18n->getKey('label.cost').''.$i18n->getKey('label.invoice').'".$i18n->get('label.start').'".$i18n->get('label.finish').'".$i18n->get('label.duration').''.$i18n->get('label.note').'".$i18n->get('label.cost').'".$i18n->get('label.paid').'".$i18n->get('label.ip').''.$i18n->get('label.invoice').'
'.$i18n->getKey('label.subtotal').''.$i18n->get('label.subtotal').''; if ($group_by == 'user') $html .= htmlspecialchars($subtotals[$prev_grouped_by]['name']); @@ -205,6 +210,8 @@ if ($totals_only) { $html .= $subtotals[$prev_grouped_by]['expenses']; $html .= '
 
'; + $html .= $item['paid'] == 1 ? $i18n->get('label.yes') : $i18n->get('label.no'); + $html .= ''; + $html .= $item['modified'] ? $item['modified_ip'].' '.$item['modified'] : $item['created_ip'].' '.$item['created']; + $html .= ''.htmlspecialchars($item['invoice']).'
'.$i18n->getKey('label.subtotal').''.$i18n->get('label.subtotal').''; if ($group_by == 'user') $html .= htmlspecialchars($subtotals[$prev_grouped_by]['name']); @@ -280,6 +297,8 @@ if ($totals_only) { $html .= $subtotals[$prev_grouped_by]['expenses']; $html .= '
 
'.$i18n->getKey('label.total').''.$i18n->get('label.total').'
'; @@ -312,12 +333,12 @@ if ($totals_only) { // Output footer. if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false)) // By default we print it unless explicitely defined as false. - $html .= '

'.$i18n->getKey('form.mail.footer').'

'; + $html .= '

'.$i18n->get('form.mail.footer').'

'; // By this time we have html ready. // Determine title for report. -$title = $i18n->getKey('title.report').": ".$totals['start_date']." - ".$totals['end_date']; +$title = $i18n->get('title.report').": ".$totals['start_date']." - ".$totals['end_date']; header('Pragma: public'); // This is needed for IE8 to download files over https. header('Content-Type: text/html; charset=utf-8'); @@ -327,7 +348,7 @@ header('Cache-Control: post-check=0, pre-check=0', false); header('Cache-Control: private', false); header('Content-Type: application/pdf'); -header('Content-Disposition: attachment; filename="timesheet.pdf"'); +header('Content-Disposition: attachment; filename="'.$filename.'.pdf"'); // Beginning of TCPDF code here. @@ -373,7 +394,7 @@ if (file_exists('images/'.$user->team_id.'.png')) $pdf->SetImageFile('images/'.$user->team_id.'.png'); // Set page word for the footer. -$pdf->SetPageWord($i18n->getKey('label.page')); +$pdf->SetPageWord($i18n->get('label.page')); // Set document information. $pdf->SetCreator(PDF_CREATOR); @@ -404,6 +425,6 @@ $pdf->writeHTML($html, true, false, false, false, ''); // Close and output PDF document. // $pdf->Output('timesheet.pdf', 'I'); // This will display inline in browser. -$pdf->Output('timesheet.pdf', 'D'); // D is for downloads. +$pdf->Output($filename.'.pdf', 'D'); // D is for downloads. // End of of TCPDF code.