function printTimeRow($w, $row)
{
global $kga;
$from_date_string = '';
if (isset($this->columns['date'])) {
$from_date_string = $this->date($row['time_in']);
}
if (isset($this->columns['from'])) {
$from_date_string .= ' ' . $this->time($row['time_in']);
}
$to_date_string = '';
if (isset($this->columns['to'])) {
if (isset($this->columns['date'])) {
$to_date_string = $this->date($row['time_out']);
}
$to_date_string .= ' ' . $this->time($row['time_out']);
}
if (isset($this->columns['activity']) && !empty($row['activityName'])) {
$activity_string = $kga['lang']['activity'] . ': <i>' . $row['activityName'] . '</i>';
} else {
$activity_string = '';
}
if (isset($this->columns['user']) && !empty($row['username'])) {
$user_string = $kga['lang']['export_extension']['done_by'] . ': <i>' . $row['username'] . '</i>';
} else {
$user_string = '';
}
if (isset($this->columns['location']) && !empty($row['location'])) {
$location_string = $kga['lang']['location'] . ': <i>' . $row['location'] . '</i>';
} else {
$location_string = '';
}
if (isset($this->columns['trackingNumber']) && !empty($row['trackingNumber'])) {
$trackingNumber_string = $kga['lang']['trackingNumber'] . ': <i>' . $row['trackingNumber'] . '</i>';
} else {
$trackingNumber_string = '';
}
if (isset($this->columns['comment']) && !empty($row['comment'])) {
$comment_string = $kga['lang']['comment'] . ': <i>' . nl2br($row['comment']) . '</i>';
} else {
$comment_string = '';
}
if (isset($this->columns['time']) && !empty($row['formattedDuration'])) {
$time_string = $kga['lang']['export_extension']['duration'] . ': <i>' . $row['formattedDuration'] . ' ' . $kga['lang']['export_extension']['duration_unit'] . '</i>';
} else {
$time_string = '';
}
if (isset($this->columns['rate']) && !empty($row['rate'])) {
$rate_string = $kga['lang']['rate'] . ': <i>' . $row['rate'] . '</i>';
} else {
$rate_string = '';
}
if (isset($this->columns['wage']) && !empty($row['wage'])) {
$wage_string = '<b>' . $this->money($row['wage']) . '</b>';
} else {
$wage_string = '';
}
$activity_fills_row = empty($user_string) || $this->GetStringWidth($activity_string) + $this->GetStringWidth($user_string) > $w[1];
$field_rows = 4;
// number of rows in block of values
if (!empty($activity_string) && !empty($user_string) && $activity_fills_row) {
$field_rows++;
}
if (empty($activity_string) && empty($user_string)) {
$field_rows--;
}
if (empty($location_string) && empty($trackingNumber_string)) {
$field_rows--;
}
if (empty($comment_string)) {
$field_rows--;
}
if (empty($time_string) && empty($rate_string)) {
$field_rows--;
}
$probable_comment_lines = $this->getHtmlStringLines($comment_string, $w[1]);
// 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');
$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['wage'])) {
$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');
}
$this->AddPage();
}
$this->ln();
$this->Cell($w[0], 6, $from_date_string, '', 0, 'R');
for ($i = 0; $i < 5; $i++) {
$handled_row = false;
switch ($i) {
case 0:
// row with activity or activity and user
if ($activity_fills_row && !empty($activity_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $activity_string, 'L');
$handled_row = true;
} elseif (!empty($activity_string) && !empty($user_string)) {
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $activity_string, 'L');
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $user_string, '');
$handled_row = true;
} elseif (!empty($user_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $user_string, 'L');
$handled_row = true;
}
break;
case 1:
// row with user
if ($activity_fills_row && !empty($user_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $user_string, 'L');
$handled_row = true;
}
break;
case 2:
// row with location and/or tracking number
if (!empty($location_string) && empty($trackingNumber_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $location_string, 'L');
$handled_row = true;
} elseif (empty($location_string) && !empty($trackingNumber_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $trackingNumber_string, 'L');
$handled_row = true;
} elseif (!empty($location_string) && !empty($trackingNumber_string)) {
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $location_string, 'L');
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $trackingNumber_string, '');
$handled_row = true;
}
break;
case 3:
// row with comment
if (!empty($comment_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $comment_string, 'L');
$handled_row = true;
}
break;
case 4:
// row with time and/or rate
if (!empty($time_string) && empty($rate_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $time_string, 'L');
$handled_row = true;
} elseif (empty($time_string) && !empty($rate_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $rate_string, 'L');
$handled_row = true;
} elseif (!empty($time_string) && !empty($rate_string)) {
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $time_string, 'L');
$this->WriteHtmlCell($w[1] / 2, 6, $this->getX(), $this->getY(), $rate_string, '');
$handled_row = true;
}
break;
}
if ($handled_row) {
$field_rows--;
if ($field_rows == 0) {
// if this is the last row
$this->ln($this->getLastH());
$this->Cell($w[0], 6, '');
$this->Cell($w[1], 6, '', 'T');
$this->WriteHtmlCell($w[2], 6, $this->getX(), $this->getY() - $this->getLastH(), $wage_string, '', 0, 0, true, 'R');
$this->ln();
//$this->ln();
break;
// leave for loop
} else {
$this->ln();
$this->Cell($w[0], 6, '');
}
}
}
}