diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/correspondence.class.php | 32 | ||||
-rw-r--r-- | classes/offer.class.php | 2 |
2 files changed, 32 insertions, 2 deletions
diff --git a/classes/correspondence.class.php b/classes/correspondence.class.php index ac3da64..8330ea0 100644 --- a/classes/correspondence.class.php +++ b/classes/correspondence.class.php @@ -103,6 +103,13 @@ class correspondence extends FPDF { ); /** + * @var $page_height The height of a page in millimeters + * @var $margin_bottom The bottom margin in millimeters + */ + protected static $page_height = 297; // A4 + protected static $margin_bottom = 30; + + /** * Translate a string * * @see $translations The array holding the translations @@ -125,8 +132,8 @@ class correspondence extends FPDF { * @param string $unit See the FPDF class specs * @param string $size See the FPDF class specs */ - function __construct($orientation='P',$unit='mm',$size='A4') { - $this->FPDF($orientation,$unit,$size); + function __construct() { + $this->FPDF('P','mm','A4'); $this->SetMargins(30,20,20); $this->SetAuthor(constants::invoice_name); @@ -282,4 +289,25 @@ class correspondence extends FPDF { $this->_out('/Creator '.$this->_textstring($this->creator)); $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); } + + /** + * Have we reached the bottom of the page yet? + * + * @return bool + */ + public function endOfPage() { + return ($this->GetY() > self::$page_height - self::$margin_bottom); + } + + /** + * Start a new page if we're on the end + */ + public function addPageIfOnEnd() { + if ($this->endOfPage()) { + $this->Ln(); + $this->AddPage(); + $this->Cell(100, 5, ''); // blank line + $this->Ln(); + } + } }
\ No newline at end of file diff --git a/classes/offer.class.php b/classes/offer.class.php index d8e2692..ac4549f 100644 --- a/classes/offer.class.php +++ b/classes/offer.class.php @@ -535,6 +535,7 @@ class offer { $pdf->Cell($width[3],6,correspondence::valuta().number_format($row[3],2),'',0,'R'); $pdf->Ln(); $pdf->SetY($newy); + $pdf->addPageIfOnEnd(); $subtotal += $row[1]; if (!isset($btw[$row[2]])) $btw[$row[2]] = 0; $btw[$row[2]] += $row[3] - $row[1]; @@ -576,6 +577,7 @@ class offer { // Footer $pdf->Ln(); + $pdf->addPageIfOnEnd(); if ($pdf->GetY() < 230) { $pdf->SetY(230); } |