X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=topdf.php;h=9149e1c690702bbaffb1057c182433cf253c1c63;hb=bf5a31da67e50256caa4dae27f54832581dbcf7c;hp=f0fdb6023483437e1997652820bd8a9ce6c381db;hpb=b0f22cc10650051b1b7d58a33a6d4d603f936f0b;p=timetracker.git diff --git a/topdf.php b/topdf.php index f0fdb602..9149e1c6 100644 --- a/topdf.php +++ b/topdf.php @@ -35,6 +35,13 @@ import('form.Form'); import('form.ActionForm'); import('ttReportHelper'); +// Access checks. +if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) { + header('Location: access_denied.php'); + exit(); +} +// End of access checks. + // 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,16 +49,10 @@ 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 ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); } // Report settings are stored in session bean before we get here. @@ -68,7 +69,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); } } @@ -88,7 +89,7 @@ if ($items && 'no_grouping' != $group_by) { } // Build a string to use as filename for the files being downloaded. -$filename = strtolower($i18n->getKey('title.report')).'_'.$bean->mValues['start_date'].'_'.$bean->mValues['end_date']; +$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;"'; @@ -96,7 +97,7 @@ $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 .= ''; @@ -107,8 +108,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. @@ -129,7 +130,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('chpaid')) { $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 .= ''; @@ -171,7 +173,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 .= ''; @@ -239,7 +242,12 @@ if ($totals_only) { } if ($bean->getAttribute('chpaid')) { $html .= ''; + } + if ($bean->getAttribute('chip')) { + $html .= ''; } if ($bean->getAttribute('chinvoice')) $html .= ''; @@ -252,7 +260,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 .= ''; } @@ -298,7 +307,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 .= ''; @@ -317,6 +326,7 @@ if ($totals_only) { $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'].'"; @@ -148,19 +149,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.paid').''.$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']); @@ -210,6 +212,7 @@ if ($totals_only) { $html .= '
 
'; - $html .= $item['paid'] == 1 ? $i18n->getKey('label.yes') : $i18n->getKey('label.no'); + $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']); @@ -291,6 +299,7 @@ if ($totals_only) { $html .= '
 
'.$i18n->getKey('label.total').''.$i18n->get('label.total').'
'; @@ -324,12 +334,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'); @@ -381,11 +391,11 @@ class ttPDF extends TCPDF { $pdf = new ttPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // If custom logo file exists - set it. -if (file_exists('images/'.$user->team_id.'.png')) - $pdf->SetImageFile('images/'.$user->team_id.'.png'); +if (file_exists('images/'.$user->group_id.'.png')) + $pdf->SetImageFile('images/'.$user->group_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);