Пример #1
0
 private function _tableWriteRow(&$table, $i, $x0)
 {
     $maxh = $this->_getRowHeight($table, $i);
     if ($table['multipage']) {
         $newpage = 0;
         if ($table['lasty'] + $maxh > $this->bottom) {
             if ($this->_checkLimitHeight($table, $maxh)) {
                 return;
             }
             $newpage = 1;
         } elseif (isset($table['pbr'][$i])) {
             $newpage = 1;
             unset($table['pbr'][$i]);
         } elseif (isset($table['knext'][$i]) && $i < $table['nr'] - 1) {
             $mrowh = $maxh;
             for ($j = $i + 1; $j < $table['nr']; $j++) {
                 $mrowh += $this->_getRowHeight($table, $j);
                 if (!isset($table['knext'][$j])) {
                     break;
                 }
                 unset($table['knext'][$j]);
             }
             if ($this->_checkLimitHeight($table, $mrowh)) {
                 return;
             }
             $newpage = $table['lasty'] + $mrowh > $this->bottom;
         }
         if ($newpage) {
             $this->_tableDrawBorder($table);
             $this->AddPage($this->CurOrientation);
             $table['lasty'] = $this->y;
             if ($table['repeat']) {
                 foreach ($table['repeat'] as $r) {
                     if ($r == $i) {
                         continue;
                     }
                     $this->_tableWriteRow($table, $r, $x0);
                 }
             }
         }
     }
     $y = $table['lasty'];
     for ($j = 0; $j < $table['nc']; $j++) {
         if (isset($table['cells'][$i][$j]['miw'])) {
             $c =& $table['cells'][$i][$j];
             list($x, $w) = $this->_tableGetWCell($table, $i, $j);
             $h = $this->_tableGetHCell($table, $i, $j);
             $x += $x0;
             //Fill
             $fill = isset($c['bgcolor']) ? $c['bgcolor'] : (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] : (isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0));
             if ($fill) {
                 $color = Color::HEX2RGB($fill);
                 $this->SetFillColor($color[0], $color[1], $color[2]);
                 $this->Rect($x, $y, $w, $h, 'F');
             }
             //Content
             if (isset($c['img'])) {
                 $this->Image($c['img'], $x, $y, $c['w'], $c['h']);
             } else {
                 $this->_drawCellAligned($x, $y, $c);
             }
             //Border
             if (isset($c['border'])) {
                 $table['listborder'][] = array($x, $y, $w, $h, $c['border']);
             } elseif (isset($table['border']) && $table['border']) {
                 $table['listborder'][] = array($x, $y, $w, $h, $table['border']);
             }
         }
     }
     $table['lasty'] += $table['hr'][$i];
     $this->y = $table['lasty'];
 }
Пример #2
0
 private function _tableWriteRow(&$table, $i, $x0)
 {
     $maxh = 0;
     for ($j = 0; $j < $table['nc']; $j++) {
         $h = $this->_tableGetHCell($table, $i, $j);
         if ($maxh < $h) {
             $maxh = $h;
         }
     }
     if ($table['lasty'] + $maxh > $this->bottom && $table['multipage']) {
         if ($maxh + $table['repeatH'] > $this->height) {
             $msg = 'Height of this row is greater than page height!';
             $this->SetFillColor(255, 0, 0);
             $h = $this->bottom - $table['lasty'];
             $this->Rect($this->x, $this->y = $table['lasty'], $table['w'], $h, 'F');
             $this->MultiCell($table['w'], $h, $msg);
             $table['lasty'] += $h;
             return;
         }
         $this->_tableDrawBorder($table);
         $this->AddPage($this->CurOrientation);
         $table['lasty'] = $this->y;
         if ($table['repeat']) {
             foreach ($table['repeat'] as $r) {
                 if ($r == $i) {
                     continue;
                 }
                 $this->_tableWriteRow($table, $r, $x0);
             }
         }
     }
     $y = $table['lasty'];
     for ($j = 0; $j < $table['nc']; $j++) {
         if (isset($table['cells'][$i][$j]['miw'])) {
             $c =& $table['cells'][$i][$j];
             list($x, $w) = $this->_tableGetWCell($table, $i, $j);
             $h = $this->_tableGetHCell($table, $i, $j);
             $x += $x0;
             //Fill
             $fill = isset($c['bgcolor']) ? $c['bgcolor'] : (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] : (isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0));
             if ($fill) {
                 $color = Color::HEX2RGB($fill);
                 $this->SetFillColor($color[0], $color[1], $color[2]);
                 $this->Rect($x, $y, $w, $h, 'F');
             }
             //Content
             if (isset($c['img'])) {
                 $this->Image($c['img'], $x, $y, $c['w'], $c['h']);
             } else {
                 $this->_drawCellAligned($x, $y, $c);
             }
             //Border
             if (isset($c['border'])) {
                 $table['listborder'][] = array($x, $y, $w, $h, $c['border']);
             } elseif (isset($table['border']) && $table['border']) {
                 $table['listborder'][] = array($x, $y, $w, $h, $table['border']);
             }
         }
     }
     $table['lasty'] += $table['hr'][$i];
     $this->y = $table['lasty'];
 }
Пример #3
0
 function _tableWriteRow(&$table, $i, $x0)
 {
     $maxh = 0;
     for ($j = 0; $j < $table['nc']; $j++) {
         $h = $this->_tableGetHCell($table, $i, $j);
         if ($maxh < $h) {
             $maxh = $h;
         }
     }
     if ($table['lasty'] + $maxh > $this->bottom && $table['multipage']) {
         if ($maxh + $table['repeatH'] > $this->height) {
             $msg = 'Height of this row is greater than page height!';
             $h = $this->countLine(0, $msg) * $this->getLineHeight();
             $this->SetFillColor(255, 0, 0);
             $this->Rect($this->x, $this->y = $table['lasty'], $table['w'], $h, 'F');
             $this->MultiCell($table['w'], $this->getLineHeight(), $msg);
             $table['lasty'] += $h;
             return;
         }
         $this->_tableDrawBorder($table);
         $this->AddPage($this->CurOrientation);
         $table['lasty'] = $this->y;
         if ($table['repeat']) {
             foreach ($table['repeat'] as $_z => $r) {
                 if ($r == $i) {
                     continue;
                 }
                 $this->_tableWriteRow($table, $r, $x0);
             }
         }
     }
     $y = $table['lasty'];
     for ($j = 0; $j < $table['nc']; $j++) {
         if (isset($table['cells'][$i][$j]) && $table['cells'][$i][$j]) {
             $c =& $table['cells'][$i][$j];
             list($x, $w) = $this->_tableGetWCell($table, $i, $j);
             $h = $this->_tableGetHCell($table, $i, $j);
             $x += $x0;
             //Align
             $this->x = $x;
             $this->y = $y;
             $align = isset($c['a']) ? $c['a'] : 'L';
             //Vertical align
             $verticalAlign = !isset($c['va']) ? 'T' : $c['va'];
             $verticalAlign = strpos('TMB', $verticalAlign) === false ? 'T' : $verticalAlign;
             if ($verticalAlign == 'M') {
                 $this->y += $c['mih'] > $c['ch'] ? ($h - $c['ch']) / 2 : ($h - $c['mih']) / 2;
             } elseif ($verticalAlign == 'B') {
                 $this->y += $c['mih'] > $c['ch'] ? $h - $c['ch'] : $h - $c['mih'];
             }
             //Fill
             $fill = isset($c['bgcolor']) ? $c['bgcolor'] : (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] : (isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0));
             if ($fill) {
                 $color = Color::HEX2RGB($fill);
                 $this->SetFillColor($color[0], $color[1], $color[2]);
                 $this->Rect($x, $y, $w, $h, 'F');
             }
             //Content
             $f = $this->_setFontText($c);
             if (isset($c['color'])) {
                 $color = Color::HEX2RGB($c['color']);
                 $this->SetTextColor($color[0], $color[1], $color[2]);
             } else {
                 unset($color);
             }
             $this->MultiCell($w, $this->getLineHeight($f), implode("\n", $c['text']), 0, $align);
             if (isset($color)) {
                 $this->SetTextColor(0);
             }
             //Border
             if (isset($c['border'])) {
                 $table['listborder'][] = array($x, $y, $w, $h, $c['border']);
             } elseif (isset($table['border']) && $table['border']) {
                 $table['listborder'][] = array($x, $y, $w, $h, $table['border']);
             }
         }
     }
     $table['lasty'] += $table['hr'][$i];
     $this->y = $table['lasty'];
 }