function printExpenseRow($w, $row)
{
global $kga;
$date_string = '';
if (isset($this->columns['date'])) {
$date_string = $this->date($row['time_in']);
}
if (isset($this->columns['from'])) {
$date_string .= ' ' . $this->time($row['time_in']);
}
$activity_string = isset($this->columns['activity']) && !empty($row['activityName']) ? $kga['lang']['export_extension']['expense'] . ': <i>' . $row['activityName'] . '</i>' : '';
$user_string = isset($this->columns['user']) && !empty($row['username']) ? $kga['lang']['export_extension']['by'] . ': <i>' . $row['username'] . '</i>' : '';
$comment_string = isset($this->columns['comment']) && !empty($row['comment']) ? $kga['lang']['comment'] . ': <i>' . nl2br($row['comment']) . '</i>' : '';
$wage_string = '<b>' . $this->money($row['wage']) . '</b>';
$activity_fills_row = empty($user_string) || $this->GetStringWidth($activity_string) + $this->GetStringWidth($user_string) > $w[1];
// Find out how many rows we use for this entry.
$field_rows = 2;
if (!empty($activity_string) && !empty($user_string) && $activity_fills_row) {
$field_rows++;
}
if (empty($activity_string) && empty($user_string)) {
$field_rows--;
}
if (empty($comment_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, $date_string, '', 0, 'R');
for ($i = 0; $i < 3; $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 comment
if (!empty($comment_string)) {
$this->WriteHtmlCell($w[1], 6, $this->getX(), $this->getY(), $comment_string, 'L');
$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');
if (isset($this->columns['wage'])) {
$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, '');
}
}
}
}