From b527c3d58b7af656ee32b3715c1210a2e0062f77 Mon Sep 17 00:00:00 2001 From: Claude Gelinas Date: Sat, 27 Aug 2016 22:16:24 -0400 Subject: [PATCH] export in dec_time or std_time in export_pdf2 --- extensions/ki_export/export_pdf2.php | 107 +++++++++++++++++++-------- 1 file changed, 78 insertions(+), 29 deletions(-) diff --git a/extensions/ki_export/export_pdf2.php b/extensions/ki_export/export_pdf2.php index 27e0ce0c9..79a6f7e7b 100644 --- a/extensions/ki_export/export_pdf2.php +++ b/extensions/ki_export/export_pdf2.php @@ -65,14 +65,14 @@ public function getHtmlStringLines($string, $line_width) { public function Footer() { global $kga, $customerData, $projectData; - // Position at 1.5 cm from bottom + // Position at 1.5 cm from bottom $this->SetY(-15); // customer data /*$this->SetFont('freesans', '', 8); // Set font $this->Cell(80, 10, $customerData['customerName'].' ('.$projectData['pct_name'].')', 0, 0, 'L');*/ - // Page number + // Page number $this->SetFont('freesans', 'I', 8); // Set font $this->Cell(30, 10, $kga['lang']['export_extension']['page'] . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, 0, 'C'); @@ -102,7 +102,16 @@ public function printRows($data, $widths) { else { $this->printTimeRow($widths, $row); $this->moneySum += $row['wage']; - $this->timeSum += $row['decimalDuration'] == -1 ? 0 : $row['decimalDuration']; + if ($_REQUEST['time_type'] == "dec_time") { + if (isset($this->columns['dec_time'])) { + $this->timeSum += $row['decimalDuration'] == - 1 ? 0 : $row['decimalDuration']; + } + } else { + if (isset($this->columns['time'])) { + $this->timeSum = $this->SumStdTime($row['formattedDuration'] == - 1 ? 0 : $row['formattedDuration'], $this->timeSum); + } + } + } } } @@ -143,9 +152,14 @@ function printExpenseRow($w, $row) { // check if page break is nessessary if ($this->getPageHeight() - $this->pagedim[$this->page]['bm'] - ($this->getY() + ($field_rows + $probable_comment_lines + 4) * 6) < 0) { - if (isset($this->columns['wage']) && isset($this->columns['dec_time'])) { - $this->ln(); - $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + if (isset($this->columns['wage']) && (isset($this->columns['dec_time']) || isset($this->columns['time']))) { + if ($_REQUEST['time_type'] == "dec_time") { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + } else { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->time_unit($this->timeSum), '', 0, 0, true, 'R'); + } $this->ln(); $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->money($this->moneySum), '', 0, 0, true, 'R'); @@ -153,10 +167,16 @@ function printExpenseRow($w, $row) { $this->ln(); $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->money($this->moneySum), '', 0, 0, true, 'R'); - } elseif (isset($this->columns['dec_time'])) { - $this->ln(); - $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); - $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + } else { + if($_REQUEST['time_type']=="dec_time") { + $this->ln(); + $this->WriteHtmlCell($w[0]+$w[1], 6, $this->getX(),$this->getY(),$kga['lang']['export_extension']['subtotal'].':', '',0,0,true,'R'); + $this->WriteHtmlCell($w[2], 6, $this->getX(),$this->getY(),$this->timespan($this->timeSum),'',0,0,true,'R'); + } else { + $this->ln(); + $this->WriteHtmlCell($w[0]+$w[1], 6, $this->getX(),$this->getY(),$kga['lang']['export_extension']['subtotal'].':', '',0,0,true,'R'); + $this->WriteHtmlCell($w[2], 6, $this->getX(),$this->getY(),$this->time_unit($this->timeSum),'',0,0,true,'R'); + } } $this->AddPage(); } @@ -269,10 +289,17 @@ function printTimeRow($w, $row) { else $comment_string = ''; - if (isset($this->columns['time']) && !empty($row['formattedDuration'])) - $time_string = $kga['lang']['export_extension']['duration'] . ': ' . $row['formattedDuration'] . ' ' . $kga['lang']['export_extension']['duration_unit'] . ''; - else - $time_string = ''; + if ($_REQUEST['time_type'] == "dec_time") { + if (isset($this->columns['dec_time']) && ! empty($row['decimalDuration'])) + $time_string = $kga['lang']['export_extension']['duration'] . ': ' . $row['decimalDuration'] . ' ' . $kga['lang']['export_extension']['duration_unit'] . ''; + else + $time_string = ''; + } else { + if (isset($this->columns['time']) && ! empty($row['formattedDuration'])) + $time_string = $kga['lang']['export_extension']['duration'] . ': ' . $row['formattedDuration'] . ' ' . $kga['lang']['export_extension']['duration_unit'] . ''; + else + $time_string = ''; + } if (isset($this->columns['rate']) && !empty($row['rate'])) $rate_string = $kga['lang']['rate'] . ': ' . $row['rate'] . ''; @@ -307,9 +334,14 @@ function printTimeRow($w, $row) { // check if page break is nessessary if ($this->getPageHeight() - $this->pagedim[$this->page]['bm'] - ($this->getY() + ($field_rows + $probable_comment_lines + 4) * 6) < 0) { - if (isset($this->columns['wage']) && isset($this->columns['dec_time'])) { - $this->ln(); - $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + if (isset($this->columns['wage']) && (isset($this->columns['dec_time']) || isset($this->columns['time']))) { + if ($_REQUEST['time_type'] == "dec_time") { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + } else { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1] + $w[2], 6, $this->getX(), $this->getY(), $this->time_unit($this->timeSum), '', 0, 0, true, 'R'); + } $this->ln(); $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->money($this->moneySum), '', 0, 0, true, 'R'); @@ -317,10 +349,16 @@ function printTimeRow($w, $row) { $this->ln(); $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->money($this->moneySum), '', 0, 0, true, 'R'); - } elseif (isset($this->columns['dec_time'])) { - $this->ln(); - $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); - $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + } else { + if ($_REQUEST['time_type'] == "dec_time") { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); + $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->timespan($this->timeSum), '', 0, 0, true, 'R'); + } else { + $this->ln(); + $this->WriteHtmlCell($w[0] + $w[1], 6, $this->getX(), $this->getY(), $kga['lang']['export_extension']['subtotal'] . ':', '', 0, 0, true, 'R'); + $this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY(), $this->time_unit($this->timeSum), '', 0, 0, true, 'R'); + } } $this->AddPage(); } @@ -559,10 +597,15 @@ function printTimeRow($w, $row) { $widths = $pdf->columnWidths($max_time_width, $max_money_width); $pdf->printRows($customer[$project_id], $widths); - - if (isset($columns['wage']) && isset($columns['dec_time'])) { - $pdf->ln(); - $pdf->WriteHtmlCell($widths[0] + $widths[1] + $widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->timespan($pdf->timeSum), '', 0, 0, true, 'R'); + + if (isset($columns['wage']) && (isset($columns['dec_time']) || isset($this->columns['time']))) { + if ($_REQUEST['time_type'] == "dec_time") { + $pdf->ln(); + $pdf->WriteHtmlCell($widths[0] + $widths[1] + $widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->timespan($pdf->timeSum), '', 0, 0, true, 'R'); + } else { + $pdf->ln(); + $pdf->WriteHtmlCell($widths[0] + $widths[1] + $widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->time_unit($pdf->timeSum), '', 0, 0, true, 'R'); + } $pdf->ln(); $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R'); $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->money($pdf->moneySum), '', 0, 0, true, 'R'); @@ -570,10 +613,16 @@ function printTimeRow($w, $row) { $pdf->ln(); $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R'); $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->money($pdf->moneySum), '', 0, 0, true, 'R'); - } elseif (isset($columns['dec_time'])) { - $pdf->ln(); - $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R'); - $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->timespan($pdf->timeSum), '', 0, 0, true, 'R'); + } else { + if ($_REQUEST['time_type'] == "dec_time") { + $pdf->ln(); + $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R'); + $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->timespan($pdf->timeSum), '', 0, 0, true, 'R'); + } else { + $pdf->ln(); + $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R'); + $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->time_unit($pdf->timeSum), '', 0, 0, true, 'R'); + } } } }