MYPDF::printRows PHP Method

printRows() public method

Put a new entry into the PDF document. Decide if it's a time entry or expense entry and call the appropriate functions.
public printRows ( array $data, array $widths )
$data array the data of this entry
$widths array the widths of the columns
    public function printRows($data, $widths)
    {
        $this->moneySum = 0;
        $this->timeSum = 0;
        foreach ($data as $row) {
            error_log($row['type']);
            if ($row['type'] == "expense") {
                $this->printExpenseRow($widths, $row);
                $this->moneySum += $row['wage'];
            } else {
                $this->printTimeRow($widths, $row);
                $this->moneySum += $row['wage'];
                $this->timeSum += $row['decimalDuration'] == -1 ? 0 : $row['decimalDuration'];
            }
        }
    }

Usage Example

Example #1
0
     }
     if (isset($columns['from']) && isset($columns['to'])) {
         $time_width += max($pdf->GetStringWidth(strftime($timeformat, $row['time_in'])), $pdf->GetStringWidth(strftime($timeformat, $row['time_out'])));
     } else {
         if (isset($columns['from'])) {
             $time_width += $pdf->GetStringWidth(strftime($timeformat, $row['time_in']));
         } else {
             $time_width += $pdf->GetStringWidth(strftime($timeformat, $row['time_out']));
         }
     }
     $max_time_width = max($max_time_width, $time_width);
 }
 $max_time_width += 10;
 $max_money_width += 10;
 $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');
     $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');
 } else {
     if (isset($columns['wage'])) {
         $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');
     } else {
         if (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');