Browse Source

Adds N/A to region/manager if they are not set.

Alan Lam 8 years ago
parent
commit
ac3413d8f1
2 changed files with 31 additions and 2 deletions
  1. 4 1
      controllers/test_pdf.php
  2. 27 1
      engine/test_pdf.php

+ 4 - 1
controllers/test_pdf.php

@@ -115,7 +115,10 @@ $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
 $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
 $pdf->Cell(30, $cell_height, "Region / Manager:", 0, 0);
 $pdf->SetX($pdf->GetX() + 5);
-$pdf->Cell(100, $cell_height, "$location->region / $location->area_manager", 0, 1);
+$pdf->Write($cell_height, $location->region);
+$pdf->Write($cell_height, "/ ");
+$pdf->Write($cell_height, $location->area_manager);
+$pdf->SetY($pdf->GetY() + $cell_height);
 $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
 
 $pdf->Cell(30, $cell_height, "Phone:", 0, 0);

+ 27 - 1
engine/test_pdf.php

@@ -16,11 +16,29 @@ class TestPDF extends FPDF {
 		parent::SetTextColor($r, $g, $b);
 	}
 
-	public function Cell($width, $height = 0, $text = "", $border = 0, $line_mode = 0, $align = "", $fill = false, $link = "") {
+	public function Write($height, $text, $link = "") {
 
 		$font_size = $this->GetFontSize();
 
+		if(empty($text)) {
+			$text = "N/A";
+		}
+
+		if($text == "N/A") {
+			$this->SetTextColor(192, 192, 192);
+		}
+
+		parent::Write($height, $text, $link);
+
+		call_user_func_array([$this, "SetTextColor"], $this->currentTextColor);
+
+		// Restore font size
+		$this->SetFontSize($font_size);
+	}
 
+	public function Cell($width, $height = 0, $text = "", $border = 0, $line_mode = 0, $align = "", $fill = false, $link = "") {
+
+		$font_size = $this->GetFontSize();
 
 		if(empty($text)) {
 			$text = "N/A";
@@ -39,6 +57,14 @@ class TestPDF extends FPDF {
 		$this->SetFontSize($font_size);
 	}
 
+	public function MoveX($adjustment) {
+		$this->SetX($this->GetX() + $adjustment);
+	}
+
+	public function MoveY($adjustment) {
+		$this->SetY($this->GetY() + $adjustment);
+	}
+
 }
 
 ?>