Explorar o código

Add support for tester invoice statuses

Alan Lam %!s(int64=7) %!d(string=hai) anos
pai
achega
75ff00fcbb

+ 17 - 1
controllers/test.php

@@ -254,6 +254,9 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 			$accept = http::value("accept");
 			$accept = http::value("accept");
 			$reject = http::value("reject");
 			$reject = http::value("reject");
 
 
+			$accept_tester_invoice = http::value("accept_tester_invoice");
+			$reject_tester_invoice = http::value("reject_tester_invoice");
+
 			if(($accept || $reject) && $test->status != Test::STATUS_PENDING_VERIFICATION) {
 			if(($accept || $reject) && $test->status != Test::STATUS_PENDING_VERIFICATION) {
 				throw new Exception("This test is no longer pending verification.");
 				throw new Exception("This test is no longer pending verification.");
 			}
 			}
@@ -402,10 +405,23 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 				if(EMAIL_TEST_RESULT_COPY) {
 				if(EMAIL_TEST_RESULT_COPY) {
 					$test->sendResultEmail(EMAIL_TEST_RESULT_COPY);
 					$test->sendResultEmail(EMAIL_TEST_RESULT_COPY);
 				}
 				}
+			}
+
+			if($test->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
+
+				if($accept_tester_invoice) {
+					$success = $test->markTesterInvoicePaid();
+					if(!$success) throw new Exception("Failed to mark tester invoice as paid.");
+				}
+
+				if($reject_tester_invoice) {
+					$success = $test->rejectTesterInvoice();
+					if(!$success) throw new Exception("Failed to reject tester invoice.");
+				}
 
 
 			}
 			}
 
 
-			Core::addAlert("success", "Test verified successfully.");
+			Core::addAlert("success", "Test updated successfully.");
 			HTTP::redirect("/account/tests/$id");
 			HTTP::redirect("/account/tests/$id");
 		}
 		}
 		catch(FormException $e) {
 		catch(FormException $e) {

+ 28 - 17
controllers/test_invoice.php

@@ -24,12 +24,29 @@ $travel_cost = (float) http::value("travel_cost", "float");
 $invoice_total = $fee + $play_spent + $travel_cost;
 $invoice_total = $fee + $play_spent + $travel_cost;
 
 
 $test->test_travel_cost = $travel_cost;
 $test->test_travel_cost = $travel_cost;
-$test->commit();
 
 
 $address = $tester->getInvoiceAddress();
 $address = $tester->getInvoiceAddress();
 if(!$address) throw new Exception(_("Invoice address not found. Please set an address as the invoice address then try again."));
 if(!$address) throw new Exception(_("Invoice address not found. Please set an address as the invoice address then try again."));
 if(!$tester->hasValidPaymentMethod()) throw new Exception(_("No valid payment method found. Please go to the Settings page and make sure all respective fields are filled in and then try again."));
 if(!$tester->hasValidPaymentMethod()) throw new Exception(_("No valid payment method found. Please go to the Settings page and make sure all respective fields are filled in and then try again."));
 
 
+// Filename
+$reference =
+	"T" . str_pad($test->id, 3, "0", STR_PAD_LEFT) .
+	"/L" . str_pad($location->id, 3, "0", STR_PAD_LEFT) .
+	"/U" . str_pad($tester->id, 3, "0", STR_PAD_LEFT);
+
+$download_filename = str_replace("/", "_", $reference) . " - " . $tester->getDisplayName() . " - Invoice.pdf";
+
+// Check for existing PDF
+$directory = $test->getDirectory();
+$pdf_filepath = $directory . "/tester_invoice.pdf";
+if($test->hasTesterInvoicePDF()) {
+	http::setDownloadHeaders($download_filename);
+	readfile($pdf_filepath);
+	exit;
+}
+
+// Initialise for PDF generation
 $address_parts = array_filter([
 $address_parts = array_filter([
 	$address->address_1,
 	$address->address_1,
 	$address->address_2,
 	$address->address_2,
@@ -45,11 +62,6 @@ $bill_to_address_parts = [
 	"PL14 3JJ",
 	"PL14 3JJ",
 ];
 ];
 
 
-$reference =
-	"T" . str_pad($test->id, 3, "0", STR_PAD_LEFT) .
-	"/L" . str_pad($location->id, 3, "0", STR_PAD_LEFT) .
-	"/U" . str_pad($tester->id, 3, "0", STR_PAD_LEFT);
-
 list($date_start, $time_start) = explode(" ", $test->dts_start);
 list($date_start, $time_start) = explode(" ", $test->dts_start);
 list($date_end, $time_end) = explode(" ", $test->dts_end);
 list($date_end, $time_end) = explode(" ", $test->dts_end);
 
 
@@ -60,15 +72,6 @@ $diff = $dt_start->diff($dt_end, true);
 
 
 $date_start = date("d/m/Y", strtotime($test->dts_start));
 $date_start = date("d/m/Y", strtotime($test->dts_start));
 
 
-
-$tiny_font_size = 8;
-$small_font_size = 10;
-$normal_font_size = 10;
-$header_font_size = 14;
-
-$cell_height = 5;
-$cell_margin = 2;
-
 // A4 size: 210x297mm
 // A4 size: 210x297mm
 $mpdf = new Mpdf();
 $mpdf = new Mpdf();
 
 
@@ -240,6 +243,14 @@ $html = ob_get_clean();
 
 
 $mpdf->WriteHTML($html);
 $mpdf->WriteHTML($html);
 
 
-$name = str_replace("/", "_", $reference) . " - " . $tester->getDisplayName() . " - Invoice.pdf";
+// Save PDF to directory
+$pdf_string = $mpdf->Output("", "S");
+file_put_contents($pdf_filepath, $pdf_string);
+
+// Mark invoice generated
+$test->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PENDING;
+$test->dts_tester_invoice_generated = Util::getDateTime();
+$test->commit();
 
 
-$mpdf->Output($name, "D");
+// Output to browser
+$mpdf->Output($download_filename, "D");

+ 34 - 4
controllers/tests_admin_list.php

@@ -25,6 +25,18 @@ if($submit) {
 				Core::addAlert("success", "$test_unassigned_count of $test_count test(s) unassigned successfully.");
 				Core::addAlert("success", "$test_unassigned_count of $test_count test(s) unassigned successfully.");
 
 
 				break;
 				break;
+
+			case "mark_tester_invoice_paid":
+
+				$actioned_count = 0;
+
+				foreach($tests as $test) {
+					$actioned_count += ($test->markTesterInvoicePaid()) ? 1 : 0;
+				}
+
+				Core::addAlert("success", "{$actioned_count} of {$test_count} test(s) marked as paid successfully.");
+				break;
+
 			default:
 			default:
 				throw new Exception("Invalid action.");
 				throw new Exception("Invalid action.");
 		}
 		}
@@ -40,10 +52,12 @@ if($submit) {
 // Batch Action End
 // Batch Action End
 
 
 $status = http::value("status", "int");
 $status = http::value("status", "int");
+$status_tester_invoice = http::value("status_tester_invoice");
 $customer_id = http::value("customer_id", "int");
 $customer_id = http::value("customer_id", "int");
 $project_id = http::value("project_id", "int");
 $project_id = http::value("project_id", "int");
 $location_id = http::value("location_id", "int");
 $location_id = http::value("location_id", "int");
 $test_id = http::value("test_id", "int");
 $test_id = http::value("test_id", "int");
+$tester_id = http::value("tester_id", "int");
 $location_internal_id = http::value("location_internal_id", "int");
 $location_internal_id = http::value("location_internal_id", "int");
 $pass = http::value("pass", "int");
 $pass = http::value("pass", "int");
 $custom = http::value("custom");
 $custom = http::value("custom");
@@ -51,16 +65,28 @@ $custom = http::value("custom");
 $filter_count_offset = 0;
 $filter_count_offset = 0;
 
 
 $nvp = [];
 $nvp = [];
+
+// Status
 if(strlen($status) > 0) $nvp["status"] = $status;
 if(strlen($status) > 0) $nvp["status"] = $status;
 else {
 else {
 	$nvp["status"] = (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED);
 	$nvp["status"] = (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED);
 	$filter_count_offset--;
 	$filter_count_offset--;
 }
 }
+
+// Status Tester Invoice
+if(strlen($status_tester_invoice)) {
+	$status_tester_invoice = (int) $status_tester_invoice;
+	$nvp["status_tester_invoice"] = $status_tester_invoice;
+}
+
+// Project
 if($project_id) $nvp["project_id"] = $project_id;
 if($project_id) $nvp["project_id"] = $project_id;
 else if($customer_id) {
 else if($customer_id) {
 	$projects = Project::query(["customer_id" => $customer_id]);
 	$projects = Project::query(["customer_id" => $customer_id]);
 	$nvp["project_id"] = array_column($projects, "id");
 	$nvp["project_id"] = array_column($projects, "id");
 }
 }
+
+// Location
 if($location_id) $nvp["location_id"] = $location_id;
 if($location_id) $nvp["location_id"] = $location_id;
 else if($location_internal_id) {
 else if($location_internal_id) {
 	$locations = Location::query(["internal_id" => $location_internal_id]);
 	$locations = Location::query(["internal_id" => $location_internal_id]);
@@ -68,7 +94,14 @@ else if($location_internal_id) {
 		$nvp["location_id"] = array_column($locations, "id");
 		$nvp["location_id"] = array_column($locations, "id");
 	}
 	}
 }
 }
+
+// Test ID
 if($test_id) $nvp["id"] = $test_id;
 if($test_id) $nvp["id"] = $test_id;
+
+// Tester ID
+if($tester_id) $nvp["tester_id"] = $tester_id;
+
+// Pass
 if(strlen($pass) > 0) $nvp["pass"] = $pass;
 if(strlen($pass) > 0) $nvp["pass"] = $pass;
 
 
 $filter_count = count($nvp);
 $filter_count = count($nvp);
@@ -128,7 +161,6 @@ $tests = array_slice($tests, $pagination_object->offset, $pagination_object->pag
 $testers = User::load(array_column($tests, "tester_id"));
 $testers = User::load(array_column($tests, "tester_id"));
 $customers = Customer::query([], ["sort" => "name"]);
 $customers = Customer::query([], ["sort" => "name"]);
 
 
-
 usort($projects, function($a, $b) {
 usort($projects, function($a, $b) {
 	return $a->name <=> $b->name;
 	return $a->name <=> $b->name;
 });
 });
@@ -140,6 +172,4 @@ $sorts = [
 ];
 ];
 
 
 View::includeOnce("header", compact("page_title"));
 View::includeOnce("header", compact("page_title"));
-View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "custom", "test_id", "filter_count", "status"));
-
-?>
+View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "pass", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));

+ 67 - 1
engine/test.php

@@ -4,7 +4,7 @@ class Test extends Model {
 
 
 	protected static $table = "test";
 	protected static $table = "test";
 	protected static $id_field = "id";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "test_fee", "test_time", "test_travel_cost", "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", "verifier_id", "verifier_notes", "pass", "retest", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
+	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "test_fee", "test_time", "test_travel_cost", "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", "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"];
 	const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
 
 
@@ -18,6 +18,10 @@ class Test extends Model {
 	const STATUS_PENDING_VERIFICATION = 8;
 	const STATUS_PENDING_VERIFICATION = 8;
 	const STATUS_COMPLETED = 16;
 	const STATUS_COMPLETED = 16;
 
 
+	const STATUS_TESTER_INVOICE_NONE = 0;
+	const STATUS_TESTER_INVOICE_PENDING = 100;
+	const STATUS_TESTER_INVOICE_PAID = 200;
+
 	const STATUSES = [
 	const STATUSES = [
 		0 => "Cancelled",
 		0 => "Cancelled",
 		1 => "Unassigned",
 		1 => "Unassigned",
@@ -28,6 +32,12 @@ class Test extends Model {
 		16 => "Completed",
 		16 => "Completed",
 	];
 	];
 
 
+	const STATUSES_TESTER_INVOICE = [
+		Test::STATUS_TESTER_INVOICE_NONE,
+		Test::STATUS_TESTER_INVOICE_PENDING,
+		Test::STATUS_TESTER_INVOICE_PAID
+	];
+
 	const STAGES = [
 	const STAGES = [
 		0 => "",
 		0 => "",
 		1 => "Challenge on entry",
 		1 => "Challenge on entry",
@@ -41,6 +51,31 @@ class Test extends Model {
 	const TEST_TIME_DAY = 2;
 	const TEST_TIME_DAY = 2;
 	const TEST_TIME_NIGHT = 3;
 	const TEST_TIME_NIGHT = 3;
 
 
+	// Static methods
+	public static function getStatusTesterInvoiceText($status) {
+		switch($status) {
+			case Test::STATUS_TESTER_INVOICE_NONE:
+				return _("No Invoice Generated");
+			case Test::STATUS_TESTER_INVOICE_PENDING:
+				return _("Pending Payment");
+			case Test::STATUS_TESTER_INVOICE_PAID:
+				return _("Paid");
+		}
+		return _("Unknown");
+	}
+
+	public static function getStatusTesterInvoiceClass($status) {
+		switch($status) {
+			case Test::STATUS_TESTER_INVOICE_NONE:
+				return "secondary";
+			case Test::STATUS_TESTER_INVOICE_PENDING:
+				return "warning";
+			case Test::STATUS_TESTER_INVOICE_PAID:
+				return "success";
+		}
+		return "";
+	}
+
 	// Object methods
 	// Object methods
 	public function sendAssignEmail($message) {
 	public function sendAssignEmail($message) {
 
 
@@ -395,5 +430,36 @@ class Test extends Model {
 	public function isPendingVerification() {
 	public function isPendingVerification() {
 		return $this->status == Test::STATUS_PENDING_VERIFICATION;
 		return $this->status == Test::STATUS_PENDING_VERIFICATION;
 	}
 	}
+
+	public function hasTesterInvoicePDF() {
+		$directory = $this->getDirectory();
+		return file_exists($directory . "/tester_invoice.pdf");
+	}
+
+	public function markTesterInvoicePaid() {
+
+		if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
+			$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_PAID;
+			$this->dts_tester_invoice_paid = Util::getDateTime();
+			return $this->commit();
+		}
+
+		return false;
+	}
+
+	public function rejectTesterInvoice() {
+		if($this->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
+			$this->status_tester_invoice = Test::STATUS_TESTER_INVOICE_NONE;
+			$this->dts_tester_invoice_generated = null;
+
+			$pdf_filepath = $this->getDirectory() . "/tester_invoice.pdf";
+			unlink($pdf_filepath);
+
+			return $this->commit();
+		}
+
+		return false;
+	}
+
 }
 }
 ?>
 ?>

+ 5 - 0
engine/util.php

@@ -234,6 +234,11 @@ class Util {
 		return date($format, $time);
 		return date($format, $time);
 	}
 	}
 
 
+	public static function getDisplayDateTimeFromUTC($dts) {
+		$unix = Util::getUnixTimeFromUTC($dts);
+		return Util::getDisplayDateTime($unix);
+	}
+
 	public static function sortObjectArray($array, $field, $compare_function = "") {
 	public static function sortObjectArray($array, $field, $compare_function = "") {
 
 
 		usort($array, function($a, $b) use ($compare_function, $field) {
 		usort($array, function($a, $b) use ($compare_function, $field) {

+ 1 - 0
views/modal_test_invoice.php

@@ -27,6 +27,7 @@
 					<div class="row">
 					<div class="row">
 						<div class="col-sm offset-sm-4">
 						<div class="col-sm offset-sm-4">
 							<button class="btn btn-primary" type="submit"><?=htmlspecialchars(_("Download Invoice"))?></button>
 							<button class="btn btn-primary" type="submit"><?=htmlspecialchars(_("Download Invoice"))?></button>
+							<small class="form-text text-danger"><?=htmlspecialchars(_("Travel costs are locked after downloading for the first time, please ensure it is correct!"))?></small>
 						</div>
 						</div>
 					</div>
 					</div>
 				</div>
 				</div>

+ 49 - 2
views/test_list.php

@@ -97,6 +97,23 @@ $custom_filters = [
 								</select>
 								</select>
 							</div>
 							</div>
 						</div>
 						</div>
+						<div class="row mb-1">
+							<label class="col-form-label col-sm-4" for="status-tester-invoice">Tester Invoice Status</label>
+							<div class="col-sm">
+								<select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
+									<option value="">Any</option>
+									<?php
+									foreach(Test::STATUSES_TESTER_INVOICE as $value) {
+										$display = Test::getStatusTesterInvoiceText($value);
+										$selected = ($value === $status_tester_invoice) ? "selected" : "";
+										?>
+										<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+										<?php
+									}
+									?>
+								</select>
+							</div>
+						</div>
 						<div class="row mb-1">
 						<div class="row mb-1">
 							<label class="col-form-label col-sm-4" for="customer-id">Customer</label>
 							<label class="col-form-label col-sm-4" for="customer-id">Customer</label>
 							<div class="col-sm">
 							<div class="col-sm">
@@ -152,6 +169,12 @@ $custom_filters = [
 								<input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
 								<input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
 							</div>
 							</div>
 						</div>
 						</div>
+						<div class="row mb-1">
+							<label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
+							<div class="col-sm">
+								<input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
+							</div>
+						</div>
 						<div class="row mb-1">
 						<div class="row mb-1">
 							<label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
 							<label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
 							<div class="col-sm">
 							<div class="col-sm">
@@ -246,6 +269,7 @@ $custom_filters = [
 						$unix_start = strtotime($test->dts_start . " UTC");
 						$unix_start = strtotime($test->dts_start . " UTC");
 						$unix_end = strtotime($test->dts_end . " UTC");
 						$unix_end = strtotime($test->dts_end . " UTC");
 
 
+
 						?>
 						?>
 
 
 						<tr>
 						<tr>
@@ -278,6 +302,14 @@ $custom_filters = [
 								?>
 								?>
 								<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
 								<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
 								<?php
 								<?php
+								if($test->status_tester_invoice > 0) {
+									$time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
+									$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>
+									<?php
+								}
 							}
 							}
 							else {
 							else {
 								?>
 								?>
@@ -304,12 +336,26 @@ $custom_filters = [
 								<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
 								<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
 							</td>
 							</td>
 							<td class="text-center align-middle text-<?=$test->getPassClass()?>">
 							<td class="text-center align-middle text-<?=$test->getPassClass()?>">
-								<div data-toggle="tooltip" title="<?=$test->getPassText()?>">
+								<div title="<?=$test->getPassText()?>">
 									<i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
 									<i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
 								</div>
 								</div>
 							</td>
 							</td>
 							<td class="text-right align-middle">
 							<td class="text-right align-middle">
-								<a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
+								<div class="dropdown">
+									<button class="btn btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+										Actions
+									</button>
+									<div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
+										<a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
+										<?php
+										if($test->hasTesterInvoicePDF()) {
+											?>
+											<a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
+											<?php
+										}
+										?>
+									</div>
+								</div>
 							</td>
 							</td>
 						</tr>
 						</tr>
 						<?php
 						<?php
@@ -330,6 +376,7 @@ $custom_filters = [
 						<select class="form-control" name="batch_action" required>
 						<select class="form-control" name="batch_action" required>
 							<option value="">Select Action</option>
 							<option value="">Select Action</option>
 							<option value="unassign">Unassign</option>
 							<option value="unassign">Unassign</option>
+							<option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
 						</select>
 						</select>
 						<div class="input-group-append">
 						<div class="input-group-append">
 							<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
 							<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">

+ 44 - 1
views/test_verify_form.php

@@ -30,7 +30,13 @@ if($tester) {
 		"Date of Birth" => $tester->date_of_birth,
 		"Date of Birth" => $tester->date_of_birth,
 		"Gender" => $tester->getGenderText(),
 		"Gender" => $tester->getGenderText(),
 		"Phone" => $tester->phone,
 		"Phone" => $tester->phone,
-		"Score" => $tester->score
+		"Score" => $tester->score,
+	];
+
+	$tester_invoice_details = [
+		"Status" => Test::getStatusTesterInvoiceText($test->status_tester_invoice),
+		"Generated" => $test->dts_tester_invoice_generated ? Util::getDisplayDateTimeFromUTC($test->dts_tester_invoice_generated) : "N/A",
+		"Paid" => $test->dts_tester_invoice_paid ? Util::getDisplayDateTimeFromUTC($test->dts_tester_invoice_paid) : "N/A",
 	];
 	];
 }
 }
 
 
@@ -79,6 +85,11 @@ function render_card_list_group($details) {
 						<a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/pdf" target="_blank">View Sent PDF</a>
 						<a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/pdf" target="_blank">View Sent PDF</a>
 						<?php
 						<?php
 					}
 					}
+					if($test->hasTesterInvoicePDF()) {
+						?>
+						<a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice" target="_blank">Download Tester PDF</a>
+						<?php
+					}
 					?>
 					?>
 				</div>
 				</div>
 			</div>
 			</div>
@@ -164,6 +175,38 @@ function render_card_list_group($details) {
 							render_card_list_group($tester_details);
 							render_card_list_group($tester_details);
 							?>
 							?>
 						</div>
 						</div>
+
+						<?php
+						if(isset($tester_invoice_details)) {
+							?>
+							<div class="card mb-3">
+								<div class="card-header">
+									Tester Invoice
+								</div>
+								<?php
+								render_card_list_group($tester_invoice_details);
+
+								if($test->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
+									?>
+									<div class="card-body text-center">
+										<button class="btn btn-success" type="submit" name="accept_tester_invoice" value="1">
+											Accept
+										</button>
+										<button class="btn btn-danger" type="submit" name="reject_tester_invoice" value="1">
+											Reject
+										</button>
+									</div>
+									<?php
+								}
+
+								?>
+
+
+							</div>
+							<?php
+						}
+						?>
+
 					</div>
 					</div>
 				</div>
 				</div>