aboutsummaryrefslogtreecommitdiff
path: root/classes/correspondence.class.php
diff options
context:
space:
mode:
authorCamil Staps2015-02-15 12:11:23 +0100
committerCamil Staps2015-02-15 12:11:23 +0100
commit08b99fa1cd4818afbe560b160f17ae2bb726cbaf (patch)
tree7b0147f11691111b0b6ad283d174dd23653436ce /classes/correspondence.class.php
parentAdded sorting indicators (diff)
Fix multipage invoices
Diffstat (limited to 'classes/correspondence.class.php')
-rw-r--r--classes/correspondence.class.php32
1 files changed, 30 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