Просмотр исходного кода

Change date/time inputs in test form; tidy up Template and Test classes; allow null values in TestValue records

Alan Lam 5 лет назад
Родитель
Сommit
03feb3d9f4

+ 39 - 41
controllers/test_tester_form.php

@@ -10,13 +10,9 @@
  * @var string[] $template_keys
  */
 
-$is_confirmed = $test->isConfirmed();
-$is_started = $test->hasStarted();
-$is_unverified = $test->isPendingVerification();
-
 Core::$show_footer_content = false;
 
-if(Core::$user->getId() != $test->getTesterId()) throw new Exception(__("You do not have permission to view this page."));
+if((int) Core::$user->getId() !== $test->getTesterId()) throw new Exception(__("You do not have permission to view this page."));
 if($test->getStatus() === Test::STATUS_ASSIGNED) throw new Exception(__("You do not have permission to view this page as you have not accepted the test yet."));
 
 // Show completed message
@@ -42,42 +38,44 @@ if($submit) {
 		$void = HTTP::value("void", "int");
 
 		// Parse before the test form
-		if($is_confirmed) {
+		if($test->isConfirmed()) {
 			$fields = $json->beforeTest;
 		}
 
 		// Parse after the test form
-		if($is_started || $is_unverified) {
+		$has_started = $test->hasStarted();
+
+		if($has_started || $test->isPendingVerification()) {
 			$fields = $json->duringTest;
 
 			// Start/End times
 
 			if($void) {
-				$start_unix = time();
-				$end_unix = time();
+				$unix_start = time();
+				$unix_end = time();
 			}
-			else {
-				if($is_started) {
-					$start_override = http::getDateTimeFromFields("start_override");
-					$end_override = http::getDateTimeFromFields("end_override");
+			else if($has_started) {
+				$start_override = HTTP::value("start_override");
+				$end_override = HTTP::value("end_override");
 
-					$start_unix = null;
-					$end_unix = null;
+				$unix_start = null;
+				$unix_end = null;
 
-					if($start_override && $end_override) {
-						$start_unix = strtotime($start_override);
-						$end_unix = strtotime($end_override);
+				if($start_override && $end_override) {
+					$dt_start = new DateTime($start_override, new DateTimeZone(TIMEZONE));
+					$dt_end = new DateTime($start_override, new DateTimeZone(TIMEZONE));
 
-						if($start_unix > $end_unix) $form_exception->addError(__("Entry Time must not be after Exit Time."));
-						if(!$start_unix && $end_unix && $test->dts_start) {
-							$recorded_start_unix = Util::getUnixTimeFromUTC($test->dts_start);
-							if($end_unix < $recorded_start_unix) $form_exception->addError(__("Exit Time cannot be later than the recorded Entry Time."));
-						}
-					}
-					else {
-						$form_exception->addError(__("Entry Time and Exit Time must be filled in."));
-					}
+					$unix_start = $dt_start->format("U");
+					$unix_end = $dt_end->format("U");
 
+					if($unix_start > $unix_end) $form_exception->addError(__("Entry Time must not be after Exit Time."));
+					if(!$unix_start && $unix_end && $test->dts_start) {
+						$recorded_start_unix = Util::getUnixTimeFromUTC($test->dts_start);
+						if($unix_end < $recorded_start_unix) $form_exception->addError(__("Exit Time cannot be later than the recorded Entry Time."));
+					}
+				}
+				else {
+					$form_exception->addError(__("Entry Time and Exit Time must be filled in."));
 				}
 			}
 		}
@@ -90,7 +88,7 @@ if($submit) {
 				if(empty($name)) continue; // Not a field
 
 				$required_key = $field->requiredKey ?? null;
-				if($required_key && !in_array($required_key, $template_keys)) continue;
+				if($required_key && !in_array($required_key, $template_keys, true)) continue;
 
 				$label = $field->label ?? "";
 				$type = $field->type;
@@ -130,11 +128,12 @@ if($submit) {
 				}
 				else {
 					$value = http::value($name, "trim");
+					if($value === "") $value = null;
 
 					if($required && $value === null) $form_exception->addError(sprintf(__("%s is required."), $label));
-					if($values && !in_array($value, $values)) $form_exception->addError(sprintf(__("Value for %s is invalid."), $label));
+					if($values && !in_array($value, $values, false)) $form_exception->addError(sprintf(__("Value for %s is invalid."), $label));
 
-					if(in_array($name, Test::TEST_FIELDS)) {
+					if(in_array($name, Test::TEST_FIELDS, true)) {
 						$test->$name = $value;
 					}
 					else {
@@ -157,7 +156,7 @@ if($submit) {
 		date_default_timezone_set("UTC");
 
 		// Before the Test
-		if($is_confirmed) {
+		if($test->isConfirmed()) {
 			$test->status = Test::STATUS_STARTED;
 			$test->dts_start = Util::getDateTime();
 			$test->dts_updated = Util::getDateTime();
@@ -167,28 +166,27 @@ if($submit) {
 			Core::addAlert("success", __("Photos uploaded successfully."));
 
 			HTTP::redirect("/account/tests/$id");
-
 		}
 
 		// During the test
 
-		if($is_started || $is_unverified) {
+		if($has_started || $test->isPendingVerification()) {
 
 			$test->status = Test::STATUS_PENDING_VERIFICATION;
 
-			if($is_started) {
+			if($has_started) {
 
 				/**
-				 * @var int $start_unix
-				 * @var int $end_unix
+				 * @var int $unix_start
+				 * @var int $unix_end
 				 */
 
-				if($start_unix && $end_unix) {
-					$test->dts_start = date("Y-m-d H:i:s", $start_unix);
-					$test->dts_end = date("Y-m-d H:i:s", $end_unix);
+				if($unix_start && $unix_end) {
+					$test->dts_start = date("Y-m-d H:i:s", $unix_start);
+					$test->dts_end = date("Y-m-d H:i:s", $unix_end);
 				}
-				else if($end_unix) {
-					$test->dts_end = date("Y-m-d H:i:s", $end_unix);
+				else if($unix_end) {
+					$test->dts_end = date("Y-m-d H:i:s", $unix_end);
 				}
 			}
 

+ 5 - 1
controllers/tests_admin_list.php

@@ -1,4 +1,8 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+
+/**
+ * @var string $page_title
+ */
 
 // Batch Action
 $submit = http::value("submit");

+ 15 - 0
db/migrations/20210713222705_change_test_value_value_field_nullable.php

@@ -0,0 +1,15 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class ChangeTestValueValueFieldNullable extends AbstractMigration {
+	public function up() {
+		$this->table("test_value")
+			->changeColumn("value", "string", ["limit" => 200, "null" => true])
+			->update();
+	}
+
+	public function down() {
+
+	}
+}

+ 29 - 100
engine/template.php

@@ -23,7 +23,7 @@ class Template extends Model {
 	private $keys = [];
 
 	// Object methods
-	public function setKeys($keys) {
+	public function setKeys($keys): void {
 		$this->keys = $keys;
 	}
 
@@ -45,7 +45,7 @@ class Template extends Model {
 	 * @param Test[] $tests
 	 * @throws Exception
 	 */
-	public function exportTestsCSV(string $processing_file, array $tests = []) {
+	public function exportTestsCSV(string $processing_file, array $tests = []): void {
 
 		// Preload
 		Project::load(array_column($tests, "project_id"));
@@ -59,16 +59,17 @@ class Template extends Model {
 		$config = json_decode($this->getJSON());
 
 		$fields = array_merge($config->beforeTest, $config->duringTest);
-		$fields = array_filter($fields, function($field) {
+		/** @noinspection PhpUnusedLocalVariableInspection */
+		$fields = array_filter($fields, static function($field) {
 			if(!isset($field->name)) return false;
-			if($field->type == "file") return false;
+			if($field->type === "file") return false;
 			return true;
 		});
 
 		// Output
 		HTTP::setDownloadHeaders("export.csv");
 
-		$handle = fopen("php://output", "w");
+		$handle = fopen("php://output", "wb");
 		require $processing_file_path;
 		fclose($handle);
 	}
@@ -172,7 +173,7 @@ class Template extends Model {
 
 		$invoice_fields = $this->getTesterInvoiceFields();
 		foreach($invoice_fields as $field) {
-			$costs += (float) $values[$field->name] ?? 0;
+			$costs += (float) ($values[$field->name] ?? 0);
 		}
 
 		return $costs;
@@ -181,7 +182,7 @@ class Template extends Model {
 	/**
 	 * @param array $overrides
 	 */
-	public function setOverrides(array $overrides) {
+	public function setOverrides(array $overrides): void {
 		$this->overrides = $overrides;
 	}
 
@@ -192,11 +193,10 @@ class Template extends Model {
 	public function applyOverridesToField(object $field): object {
 		foreach($this->overrides as $override) {
 			if(empty($field->name)) continue;
-			if($override->field == $field->name) {
-				switch($override->element) {
-					case "label":
-						$field->label = $override->value;
-						break;
+			if($override->field === $field->name) {
+				$element = $override->element;
+				if($element === "label") {
+					$field->label = $override->value;
 				}
 			}
 		}
@@ -206,7 +206,7 @@ class Template extends Model {
 	/**
 	 * @throws Exception
 	 */
-	public function renderBeforeTestForm() {
+	public function renderBeforeTestForm(): void {
 
 		$json = json_decode($this->getJSON());
 		$fields = $json->beforeTest;
@@ -242,11 +242,16 @@ class Template extends Model {
 	/**
 	 * @throws Exception
 	 */
-	public function renderDuringTestForm() {
+	public function renderDuringTestForm(): void {
 
 		$json = json_decode($this->getJSON());
 		$fields = $json->duringTest;
 
+		$dt_now = new DateTime("now", new DateTimeZone(TIMEZONE));
+
+		$dts = $dt_now->format("Y-m-d\TH:i:00");
+
+
 		?>
 		<form method="post" id="test-form">
 
@@ -270,98 +275,22 @@ class Template extends Model {
 
 				<p>Please confirm your entry and exit times below. Please try to be as accurate as possible.</p>
 
-				<div class="form-group">
-					<label for="start-override-hour">Entry Time <span class="badge badge-danger">Required</span></label>
-					<div class="form-row">
-						<div class="col-lg-auto">
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_hour" id="start-override-hour">
-								<option value="">HH</option>
-								<?php
-								Form::renderHourOptions();
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_minute" id="start-override-minute">
-								<option value="">MM</option>
-								<?php
-								Form::renderMinuteOptions();
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_second" id="start-override-second">
-								<option value="">SS</option>
-								<?php
-								Form::renderSecondOptions(0);
-								?>
-							</select>
-						</div>
-						<div class="col-lg-auto">
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_day" id="start-override-day">
-								<option value="">Day</option>
-								<?php
-								Form::renderDayOptions(date("j"));
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_month" id="start-override-month">
-								<option value="">Month</option>
-								<?php
-								Form::renderMonthOptions(date("n"));
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="start_override_year" id="start-override-year">
-								<option value="">Year</option>
-								<?php
-								Form::renderYearOptionsDescending(2017, date("Y"), date("Y"));
-								?>
-							</select>
+				<div class="form-row">
+					<div class="col-sm-6">
+						<div class="form-group">
+							<label for="start-override">Entry Time <span class="badge badge-danger">Required</span></label>
+							<input class="form-control" type="datetime-local" name="start_override" id="start-override" step="1" value="<?=htmlspecialchars($dts)?>" />
 						</div>
 					</div>
-				</div>
-
-				<div class="form-group">
-					<label for="end-override-hour">Exit Time <span class="badge badge-danger">Required</span></label>
-					<div class="form-row">
-						<div class="col-lg-auto">
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_hour" id="end-override-hour">
-								<option value="">HH</option>
-								<?php
-								Form::renderHourOptions();
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_minute" id="end-override-minute">
-								<option value="">MM</option>
-								<?php
-								Form::renderMinuteOptions();
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_second" id="end-override-second">
-								<option value="">SS</option>
-								<?php
-								Form::renderSecondOptions(0);
-								?>
-							</select>
-						</div>
-						<div class="col-lg-auto">
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_day" id="end-override-day">
-								<option value="">Day</option>
-								<?php
-								Form::renderDayOptions(date("j"));
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_month" id="end-override-month">
-								<option value="">Month</option>
-								<?php
-								Form::renderMonthOptions(date("n"));
-								?>
-							</select>
-							<select class="form-control form-control-sm w-auto d-inline-block" name="end_override_year" id="end-override-year">
-								<option value="">Year</option>
-								<?php
-								Form::renderYearOptionsDescending(2017, date("Y"), date("Y"));
-								?>
-							</select>
+					<div class="col-sm-6">
+						<div class="form-group">
+							<label for="end-override">Exit Time <span class="badge badge-danger">Required</span></label>
+							<input class="form-control" type="datetime-local" name="end_override" id="end-override" step="1" value="<?=htmlspecialchars($dts)?>" />
 						</div>
 					</div>
 				</div>
 
+
 				<input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
 				<input type="hidden" name="void" id="void" value="0" />
 

+ 57 - 58
engine/test.php

@@ -47,23 +47,23 @@ class Test extends Model {
 	protected static $id_field = "id";
 	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "customer_fee", "test_fee", "test_time", "test_travel_cost", "test_travel_cost_description", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "dts_tester_invoice_generated", "dts_tester_invoice_paid", "verifier_id", "verifier_notes", "pass", "retest", "void", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
 
-	const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
+	public const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
 
 	// Constants
 
-	const STATUS_CANCELLED = 0;
-	const STATUS_UNASSIGNED = 1; // Location needs a tester
-	const STATUS_ASSIGNED = 2; // Tester assigned
-	const STATUS_CONFIRMED = 3; // Tester has said they can do it
-	const STATUS_STARTED = 4;
-	const STATUS_PENDING_VERIFICATION = 8;
-	const STATUS_COMPLETED = 16;
+	public const STATUS_CANCELLED = 0;
+	public const STATUS_UNASSIGNED = 1; // Location needs a tester
+	public const STATUS_ASSIGNED = 2; // Tester assigned
+	public const STATUS_CONFIRMED = 3; // Tester has said they can do it
+	public const STATUS_STARTED = 4;
+	public const STATUS_PENDING_VERIFICATION = 8;
+	public const STATUS_COMPLETED = 16;
 
-	const STATUS_TESTER_INVOICE_NONE = 0;
-	const STATUS_TESTER_INVOICE_PENDING = 100;
-	const STATUS_TESTER_INVOICE_PAID = 200;
+	public const STATUS_TESTER_INVOICE_NONE = 0;
+	public const STATUS_TESTER_INVOICE_PENDING = 100;
+	public const STATUS_TESTER_INVOICE_PAID = 200;
 
-	const STATUSES = [
+	public const STATUSES = [
 		0 => "Cancelled",
 		1 => "Unassigned",
 		2 => "Assigned",
@@ -73,13 +73,13 @@ class Test extends Model {
 		16 => "Completed",
 	];
 
-	const STATUSES_TESTER_INVOICE = [
+	public const STATUSES_TESTER_INVOICE = [
 		Test::STATUS_TESTER_INVOICE_NONE,
 		Test::STATUS_TESTER_INVOICE_PENDING,
 		Test::STATUS_TESTER_INVOICE_PAID
 	];
 
-	const STAGES = [
+	public const STAGES = [
 		0 => "",
 		1 => "Challenge on entry",
 		2 => "Challenge while browsing",
@@ -88,10 +88,6 @@ class Test extends Model {
 		5 => "No challenge",
 	];
 
-	const TEST_TIME_ANYTIME = 1;
-	const TEST_TIME_DAY = 2;
-	const TEST_TIME_NIGHT = 3;
-
 	// Static methods
 
 	/**
@@ -100,11 +96,11 @@ class Test extends Model {
 	 */
 	public static function getStatusTesterInvoiceText(int $status): string {
 		switch($status) {
-			case Test::STATUS_TESTER_INVOICE_NONE:
+			case self::STATUS_TESTER_INVOICE_NONE:
 				return __("No Invoice Generated");
-			case Test::STATUS_TESTER_INVOICE_PENDING:
+			case self::STATUS_TESTER_INVOICE_PENDING:
 				return __("Pending Payment");
-			case Test::STATUS_TESTER_INVOICE_PAID:
+			case self::STATUS_TESTER_INVOICE_PAID:
 				return __("Paid");
 		}
 		return __("Unknown");
@@ -116,11 +112,11 @@ class Test extends Model {
 	 */
 	public static function getStatusTesterInvoiceClass(int $status): string {
 		switch($status) {
-			case Test::STATUS_TESTER_INVOICE_NONE:
+			case self::STATUS_TESTER_INVOICE_NONE:
 				return "secondary";
-			case Test::STATUS_TESTER_INVOICE_PENDING:
+			case self::STATUS_TESTER_INVOICE_PENDING:
 				return "warning";
-			case Test::STATUS_TESTER_INVOICE_PAID:
+			case self::STATUS_TESTER_INVOICE_PAID:
 				return "success";
 		}
 		return "";
@@ -145,7 +141,8 @@ class Test extends Model {
 		// Output
 		HTTP::setDownloadHeaders("export.csv");
 
-		$handle = fopen("php://output", "w");
+		$handle = fopen("php://output", "wb");
+		/** @noinspection PhpIncludeInspection */
 		require $processing_file_path;
 		fclose($handle);
 	}
@@ -406,7 +403,7 @@ class Test extends Model {
 	public function decline(): bool {
 		$this->sendDeclineEmail();
 
-		$this->status = Test::STATUS_UNASSIGNED;
+		$this->status = self::STATUS_UNASSIGNED;
 		$this->tester_id = null;
 		$this->dts_due = null;
 		$this->dts_assigned = null;
@@ -419,14 +416,14 @@ class Test extends Model {
 	 */
 	public function getChallengeStageText(): string {
 		if(is_null($this->challenge_stage)) return "";
-		return Test::STAGES[$this->challenge_stage];
+		return self::STAGES[$this->challenge_stage];
 	}
 
 	/**
 	 * @return string
 	 */
 	public function getStatusText(): string {
-		return Test::STATUSES[$this->status];
+		return self::STATUSES[$this->status];
 	}
 
 	/**
@@ -434,17 +431,17 @@ class Test extends Model {
 	 */
 	public function getStatusClass(): string {
 		switch($this->status) {
-			case Test::STATUS_CANCELLED:
+			case self::STATUS_CANCELLED:
 				return "secondary";
-			case Test::STATUS_UNASSIGNED:
+			case self::STATUS_UNASSIGNED:
 				return "danger";
-			case Test::STATUS_ASSIGNED:
-			case Test::STATUS_CONFIRMED:
-			case Test::STATUS_STARTED:
+			case self::STATUS_ASSIGNED:
+			case self::STATUS_CONFIRMED:
+			case self::STATUS_STARTED:
 				return "warning";
-			case Test::STATUS_PENDING_VERIFICATION:
+			case self::STATUS_PENDING_VERIFICATION:
 				return "primary";
-			case Test::STATUS_COMPLETED:
+			case self::STATUS_COMPLETED:
 				return "success";
 		}
 		return "";
@@ -491,9 +488,10 @@ class Test extends Model {
 		$rows = TestValue::query(["test_id" => $this->id]);
 
 		if($as_assoc_array) {
-			$k = array_column($rows, "name");
-			$v = array_column($rows, "value");
-			$values = array_combine($k, $v);
+			$values = [];
+			foreach($rows as $row) {
+				$values[$row->name] = $row->value;
+			}
 		}
 		else {
 			$values = $rows;
@@ -515,9 +513,8 @@ class Test extends Model {
 	 * @return bool|float|int
 	 */
 	public function getDuration() {
-		if(is_null($this->dts_end)) return false;
-		$seconds = Util::getDurationFromDTS($this->dts_start, $this->dts_end);
-		return $seconds;
+		if($this->dts_end === null) return false;
+		return Util::getDurationFromDTS($this->dts_start, $this->dts_end);
 	}
 
 	/**
@@ -526,7 +523,7 @@ class Test extends Model {
 	public function getDisplayDuration(): string {
 		$secs = $this->getDuration();
 		$mins = floor($secs / 60);
-		$secs = $secs % 60;
+		$secs %= 60;
 
 		return "$mins min. $secs sec.";
 	}
@@ -535,7 +532,8 @@ class Test extends Model {
 	 * @return string Bootstrap class name
 	 */
 	public function getPassClass(): string {
-		if(is_null($this->pass)) return "secondary";
+		if($this->isVoid()) return "muted";
+		if($this->pass === null) return "secondary";
 		return $this->pass ? "success" : "danger";
 	}
 
@@ -543,7 +541,8 @@ class Test extends Model {
 	 * @return string FA icon name without prefix
 	 */
 	public function getPassIcon(): string {
-		if(is_null($this->pass)) return "clock";
+		if($this->isVoid()) return "minus-circle";
+		if($this->pass === null) return "clock";
 		return $this->pass ? "check-circle" : "times-circle";
 	}
 
@@ -551,15 +550,18 @@ class Test extends Model {
 	 * @return string Pending, Pass or Fail
 	 */
 	public function getPassText(): string {
-		if(is_null($this->pass)) return __("Pending");
+		if($this->isVoid()) return __("Void");
+		if($this->pass === null) return __("Pending");
 		return $this->pass ? __("Pass") : __("Fail");
 	}
 
+	/** @noinspection PhpUnusedLocalVariableInspection */
 	public function getMPDF(): Mpdf {
-		/** @var Mpdf $mpdf */
 		$id = $this->id;
 		$output = false;
 		require ROOT_DIR . "/controllers/test_pdf.php";
+
+		/** @var Mpdf $mpdf */
 		return $mpdf;
 	}
 
@@ -571,12 +573,9 @@ class Test extends Model {
 	public function assignTester(User $tester): bool {
 		$this->tester_id = $tester->id;
 		$this->dts_assigned = Util::getDateTime();
-		$success = $this->commit();
-
 		// TODO: Notify tester
 
-		return $success;
-
+		return $this->commit();
 	}
 
 	/**
@@ -588,10 +587,10 @@ class Test extends Model {
 		$nvp = [
 			"dts_start" => (new Constraint("LESS_THAN"))->setValues($this->dts_start),
 			"location_id" => $this->location_id,
-			"status" => Test::STATUS_COMPLETED,
+			"status" => self::STATUS_COMPLETED,
 		];
 
-		$tests = Test::query($nvp, [
+		$tests = self::query($nvp, [
 			"sort" => "dts_start",
 			"order" => "desc",
 		]);
@@ -605,7 +604,7 @@ class Test extends Model {
 	 * @throws Exception
 	 */
 	public function unassignTester(): bool {
-		$this->status = Test::STATUS_UNASSIGNED;
+		$this->status = self::STATUS_UNASSIGNED;
 		$this->tester_id = null;
 		$this->dts_due = null;
 		$this->dts_assigned = null;
@@ -649,7 +648,7 @@ class Test extends Model {
 		return $this->getStatus() === self::STATUS_PENDING_VERIFICATION;
 	}
 
-	public function getPDFPath() {
+	public function getPDFPath(): string {
 		$directory = $this->getDirectory();
 		return sprintf("%s/pdf.pdf", $directory);
 	}
@@ -693,8 +692,8 @@ class Test extends Model {
 	 */
 	public function markTesterInvoicePaid(): bool {
 
-		if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
-			$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PAID;
+		if($this->getTesterInvoiceStatus() === self::STATUS_TESTER_INVOICE_PENDING) {
+			$this->status_tester_invoice = self::STATUS_TESTER_INVOICE_PAID;
 			$this->dts_tester_invoice_paid = Util::getDateTime();
 			return $this->commit();
 		}
@@ -707,8 +706,8 @@ class Test extends Model {
 	 * @throws Exception
 	 */
 	public function rejectTesterInvoice(): bool {
-		if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
-			$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_NONE;
+		if($this->getTesterInvoiceStatus() === self::STATUS_TESTER_INVOICE_PENDING) {
+			$this->status_tester_invoice = self::STATUS_TESTER_INVOICE_NONE;
 			$this->dts_tester_invoice_generated = null;
 
 			if($this->hasTesterInvoicePDF()) {

+ 2 - 3
views/test_list.php

@@ -16,6 +16,7 @@
  * @var int $location_id
  * @var int $location_internal_id
  * @var int $custom
+ * @var object $pagination_object
  */
 
 $filters_collapse = $filter_count ? "collapse show" : "collapse";
@@ -295,8 +296,6 @@ $custom_filters = [
 
 							$unix_start = strtotime($test->dts_start . " UTC");
 							$unix_end = strtotime($test->dts_end . " UTC");
-
-
 							?>
 
 							<tr>
@@ -337,7 +336,7 @@ $custom_filters = [
 										$dts = Util::getDisplayDateTime($time);
 										?>
 										<br />
-										<span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=$test->getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
+										<span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=Test::getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
 										<?php
 									}
 								}