projects
/
timetracker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Work in progress on week view. Fixed the links.
[timetracker.git]
/
topdf.php
diff --git
a/topdf.php
b/topdf.php
index
7aed32d
..
b1195a4
100644
(file)
--- a/
topdf.php
+++ b/
topdf.php
@@
-49,7
+49,7
@@
if (!ttAccessCheck(right_view_reports)) {
}
// Use custom fields plugin if it is enabled.
}
// 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);
}
require_once('plugins/CustomFields.class.php');
$custom_fields = new CustomFields($user->team_id);
}
@@
-87,6
+87,9
@@
if ($items && 'no_grouping' != $group_by) {
$cur_grouped_by = '';
}
$cur_grouped_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'];
+
// Start preparing HTML to build PDF from.
$styleHeader = 'style="background-color:#a6ccf7;"';
$styleSubtotal = 'style="background-color:#e0e0e0;"';
// Start preparing HTML to build PDF from.
$styleHeader = 'style="background-color:#a6ccf7;"';
$styleSubtotal = 'style="background-color:#e0e0e0;"';
@@
-159,7
+162,7
@@
if ($totals_only) {
if ($bean->getAttribute('chinvoice')) { $colspan++; $html .= '<td>'.$i18n->getKey('label.invoice').'</td>'; }
$html .= '</tr>';
$html .= '</thead>';
if ($bean->getAttribute('chinvoice')) { $colspan++; $html .= '<td>'.$i18n->getKey('label.invoice').'</td>'; }
$html .= '</tr>';
$html .= '</thead>';
-
+
foreach ($items as $item) {
// Print a subtotal for a block of grouped values.
$cur_date = $item['date'];
foreach ($items as $item) {
// Print a subtotal for a block of grouped values.
$cur_date = $item['date'];
@@
-234,11
+237,11
@@
if ($totals_only) {
}
if ($bean->getAttribute('chinvoice')) $html .= '<td>'.htmlspecialchars($item['invoice']).'</td>';
$html .= '</tr>';
}
if ($bean->getAttribute('chinvoice')) $html .= '<td>'.htmlspecialchars($item['invoice']).'</td>';
$html .= '</tr>';
-
+
$prev_date = $item['date'];
if ($print_subtotals) $prev_grouped_by = $item['grouped_by'];
}
$prev_date = $item['date'];
if ($print_subtotals) $prev_grouped_by = $item['grouped_by'];
}
-
+
// Print a terminating subtotal.
if ($print_subtotals) {
$html .= '<tr style="background-color:#e0e0e0;">';
// Print a terminating subtotal.
if ($print_subtotals) {
$html .= '<tr style="background-color:#e0e0e0;">';
@@
-283,7
+286,7
@@
if ($totals_only) {
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
$html .= '</tr>';
}
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
$html .= '</tr>';
}
-
+
// Print totals.
$html .= '<tr><td colspan="'.$colspan.'"> </td></tr>';
$html .= '<tr style="background-color:#e0e0e0;">';
// Print totals.
$html .= '<tr><td colspan="'.$colspan.'"> </td></tr>';
$html .= '<tr style="background-color:#e0e0e0;">';
@@
-302,13
+305,18
@@
if ($totals_only) {
if ($user->canManageTeam() || $user->isClient())
$html .= $totals['cost'];
else
if ($user->canManageTeam() || $user->isClient())
$html .= $totals['cost'];
else
- $html .= $totals['expenses'];
+ $html .= $totals['expenses'];
$html .= '</td>';
}
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
$html .= '</tr>';
$html .= '</table>';
}
$html .= '</td>';
}
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
$html .= '</tr>';
$html .= '</table>';
}
+
+// Output footer.
+if (!defined('REPORT_FOOTER') || !(REPORT_FOOTER == false)) // By default we print it unless explicitely defined as false.
+ $html .= '<p style="text-align: center;">'.$i18n->getKey('form.mail.footer').'</p>';
+
// By this time we have html ready.
// Determine title for report.
// By this time we have html ready.
// Determine title for report.
@@
-322,27
+330,27
@@
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private', false);
header('Content-Type: application/pdf');
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.
// Extend TCPDF class so that we can use custom header and footer.
// Beginning of TCPDF code here.
// Extend TCPDF class so that we can use custom header and footer.
-class
Myy
PDF extends TCPDF {
+class
tt
PDF extends TCPDF {
public $image_file = 'images/tt_logo.png'; // Image file for the logo in header.
public $page_word = 'Page'; // Localized "Page" word in footer, ex: Page 1/2.
public $image_file = 'images/tt_logo.png'; // Image file for the logo in header.
public $page_word = 'Page'; // Localized "Page" word in footer, ex: Page 1/2.
-
+
// SetImageFile - sets image file name.
public function SetImageFile($imgFile) {
$this->image_file = $imgFile;
}
// SetImageFile - sets image file name.
public function SetImageFile($imgFile) {
$this->image_file = $imgFile;
}
-
+
// SetPageWord - sets page word for footer.
public function SetPageWord($pageWord) {
$this->page_word = $pageWord;
}
// SetPageWord - sets page word for footer.
public function SetPageWord($pageWord) {
$this->page_word = $pageWord;
}
-
+
// Page header.
public function Header() {
// Print logo, which is the only element of our custom header.
// Page header.
public function Header() {
// Print logo, which is the only element of our custom header.
@@
-361,7
+369,7
@@
class MyyPDF extends TCPDF {
}
// Create new PDF document.
}
// Create new PDF document.
-$pdf = new
Myy
PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
+$pdf = new
tt
PDF(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'))
// If custom logo file exists - set it.
if (file_exists('images/'.$user->team_id.'.png'))
@@
-399,7
+407,6
@@
$pdf->writeHTML($html, true, false, false, false, '');
// Close and output PDF document.
// $pdf->Output('timesheet.pdf', 'I'); // This will display inline in browser.
// 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.
// End of of TCPDF code.
-?>
\ No newline at end of file