Browse Source

Merge branch 'develop'

Alan Lam 7 years ago
parent
commit
004be95a77

+ 8 - 0
controllers/account.php

@@ -27,6 +27,14 @@ if($user->level >= User::LEVEL_ADMIN) {
 	$icons[] = new AccountIcon(_("Projects"), "/account/projects", "list");
 	$icons[] = new AccountIcon(_("Locations"), "/account/locations", "map-marker");
 	$icons[] = new AccountIcon(_("Templates"), "/account/templates", "file-alt");
+
+	$pending_tester_invoice_test_count = count(Test::query(["status_tester_invoice" => Test::STATUS_TESTER_INVOICE_PENDING]));
+
+	$invoice_icon = new AccountIcon(_("Invoices"), "/account/tests?status_tester_invoice=100", "file-invoice");
+	$invoice_icon->setCounter($pending_tester_invoice_test_count);
+
+	$icons[] = $invoice_icon;
+
 }
 
 if($user->level >= User::LEVEL_CUSTOMER) {

+ 2 - 1
controllers/location_add.php

@@ -36,8 +36,9 @@ if($submit) {
 		$location->shop_right = http::value("shop_right", "trim");
 
 		$location->legal_entity_name = http::value("legal_entity_name", "trim");
-		$location->region = http::value("region", "trim");
 		$location->internal_id = http::value("internal_id", "trim");
+		$location->brand = http::value("brand", "trim");
+		$location->region = http::value("region", "trim");
 		$location->area_manager = http::value("area_manager", "trim");
 		$location->area_manager_email = http::value("area_manager_email", "email");
 

+ 2 - 1
controllers/location_edit.php

@@ -33,8 +33,9 @@ if($submit) {
 		$location->longitude = http::value("longitude", "float");
 
 		$location->legal_entity_name = http::value("legal_entity_name", "trim");
-		$location->region = http::value("region", "trim");
 		$location->internal_id = http::value("internal_id", "trim");
+		$location->region = http::value("region", "trim");
+		$location->brand = http::value("brand", "trim");
 		$location->area_manager = http::value("area_manager", "trim");
 		$location->area_manager_email = http::value("area_manager_email", "email");
 

+ 16 - 15
controllers/reports_presentation.php

@@ -60,40 +60,40 @@ $slide = $presentation->createSlide();
 
 // Title
 $shape = $slide->createRichTextShape()
-	->setHeight(60)->setWidth(940)
+	->setHeight(60)->setWidth(900)
 	->setOffsetX(30)->setOffsetY(10);
 $run = $shape->createTextRun("Summary");
 $run->getFont()->setBold(true)->setSize(24);
 
 // Date range
 $shape = $slide->createRichTextShape()
-	->setHeight(60)->setWidth(940)
+	->setHeight(60)->setWidth(900)
 	->setOffsetX(30)->setOffsetY(70);
 $run = $shape->createTextRun($date_range_label);
 $run->getFont()->setBold(true)->setSize(24);
 
-// Test count
-$shape = $slide->createRichTextShape()
-	->setHeight(60)->setWidth(940)
-	->setOffsetX(30)->setOffsetY(130);
-$run = $shape->createTextRun("Test Count: {$total_data->testCount}");
-$run->getFont()->setBold(true)->setSize(24);
+// Test Count
+$count_text = "Test Count: {$total_data->testCount}";
 
 // Pass/Fail count
 if(isset($total_data->passCount)) {
-
 	$pass_percentage = 0;
+	$fail_percentage = 0;
 	if($total_data->testCount > 0) {
 		$pass_percentage = number_format(($total_data->passCount * 100) / $total_data->testCount, 2);
+		$fail_percentage = 100 - $pass_percentage;
 	}
 
-	$shape = $slide->createRichTextShape()
-		->setHeight(60)->setWidth(940)
-		->setOffsetX(30)->setOffsetY(190);
-	$run = $shape->createTextRun("Pass/Fail Count: {$total_data->passCount} / {$total_data->failCount} ({$pass_percentage}%)");
-	$run->getFont()->setBold(true)->setSize(24);
+	$count_text .= "\nPass Count: {$total_data->passCount} ({$pass_percentage}%)";
+	$count_text .= "\nFail Count: {$total_data->failCount}  ({$fail_percentage}%)";
 }
 
+$shape = $slide->createRichTextShape()
+	->setHeight(60)->setWidth(900)
+	->setOffsetX(30)->setOffsetY(130);
+$run = $shape->createTextRun($count_text);
+$run->getFont()->setBold(true)->setSize(16);
+
 // Tests by stage
 foreach($charts as $chart) {
 	if(stripos($chart->getTitle(), "Tests by Stage") === false) continue;
@@ -217,15 +217,16 @@ foreach([0, 1] as $mode) {
 	}
 }
 
-
 if($action == "export-pptx") {
 	header("Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation");
+	http::setDownloadHeaders("report.pptx");
 	$pptx_writer = IOFactory::createWriter($presentation, "PowerPoint2007");
 	$pptx_writer->save("php://output");
 }
 
 if($action == "export-odp") {
 	header("Content-Type: application/vnd.oasis.opendocument.presentation");
+	http::setDownloadHeaders("report.odp");
 	$odp_writer = IOFactory::createWriter($presentation, "ODPresentation");
 	$odp_writer->save("php://output");
 }

+ 17 - 1
controllers/test.php

@@ -254,6 +254,9 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 			$accept = http::value("accept");
 			$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) {
 				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) {
 					$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");
 		}
 		catch(FormException $e) {

+ 29 - 17
controllers/test_invoice.php

@@ -24,12 +24,30 @@ $travel_cost = (float) http::value("travel_cost", "float");
 $invoice_total = $fee + $play_spent + $travel_cost;
 
 $test->test_travel_cost = $travel_cost;
-$test->commit();
 
 $address = $tester->getInvoiceAddress();
 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."));
 
+// 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);
+	header("Content-Type: application/pdf");
+	readfile($pdf_filepath);
+	exit;
+}
+
+// Initialise for PDF generation
 $address_parts = array_filter([
 	$address->address_1,
 	$address->address_2,
@@ -45,11 +63,6 @@ $bill_to_address_parts = [
 	"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_end, $time_end) = explode(" ", $test->dts_end);
 
@@ -60,15 +73,6 @@ $diff = $dt_start->diff($dt_end, true);
 
 $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
 $mpdf = new Mpdf();
 
@@ -240,6 +244,14 @@ $html = ob_get_clean();
 
 $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");

+ 8 - 4
controllers/test_pdf.php

@@ -64,7 +64,7 @@ $template_processing_file_path = $template->getProcessingFilePath("test_pdf.php"
 // Start PDF Building
 $mpdf = new Mpdf([
 	"margin_top" => 26,
-	"margin_bottom" => 30,
+	"margin_bottom" => 15,
 	"margin_left" => 15,
 	"margin_right" => 15,
 ]);
@@ -177,9 +177,13 @@ ob_start()
 		<htmlpagefooter name="Footer">
 			<div class="hr"></div>
 			<br />
-			<strong>Check Policy Limited</strong><br />
-			8 Market Street, Liskeard, Cornwall, PL14 3JJ<br />
-			Company Number: 09506865
+			<table width="100%">
+				<tr>
+					<td width="33%"><strong>Check Policy Limited</strong></td>
+					<td width="33%" align="middle">8 Market Street, Liskeard, Cornwall, PL14 3JJ</td>
+					<td width="33%" align="right">Company Number: 09506865</td>
+				</tr>
+			</table>
 		</htmlpagefooter>
 
 		<sethtmlpageheader name="Header" value="on" show-this-page="1" />

+ 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.");
 
 				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:
 				throw new Exception("Invalid action.");
 		}
@@ -40,10 +52,12 @@ if($submit) {
 // Batch Action End
 
 $status = http::value("status", "int");
+$status_tester_invoice = http::value("status_tester_invoice");
 $customer_id = http::value("customer_id", "int");
 $project_id = http::value("project_id", "int");
 $location_id = http::value("location_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");
 $pass = http::value("pass", "int");
 $custom = http::value("custom");
@@ -51,16 +65,28 @@ $custom = http::value("custom");
 $filter_count_offset = 0;
 
 $nvp = [];
+
+// Status
 if(strlen($status) > 0) $nvp["status"] = $status;
 else {
 	$nvp["status"] = (new Constraint("NOT_EQUALS"))->setValues(Test::STATUS_CANCELLED);
 	$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;
 else if($customer_id) {
 	$projects = Project::query(["customer_id" => $customer_id]);
 	$nvp["project_id"] = array_column($projects, "id");
 }
+
+// Location
 if($location_id) $nvp["location_id"] = $location_id;
 else if($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");
 	}
 }
+
+// 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;
 
 $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"));
 $customers = Customer::query([], ["sort" => "name"]);
 
-
 usort($projects, function($a, $b) {
 	return $a->name <=> $b->name;
 });
@@ -140,6 +172,4 @@ $sorts = [
 ];
 
 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 $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"];
 
@@ -18,6 +18,10 @@ class Test extends Model {
 	const STATUS_PENDING_VERIFICATION = 8;
 	const STATUS_COMPLETED = 16;
 
+	const STATUS_TESTER_INVOICE_NONE = 0;
+	const STATUS_TESTER_INVOICE_PENDING = 100;
+	const STATUS_TESTER_INVOICE_PAID = 200;
+
 	const STATUSES = [
 		0 => "Cancelled",
 		1 => "Unassigned",
@@ -28,6 +32,12 @@ class Test extends Model {
 		16 => "Completed",
 	];
 
+	const STATUSES_TESTER_INVOICE = [
+		Test::STATUS_TESTER_INVOICE_NONE,
+		Test::STATUS_TESTER_INVOICE_PENDING,
+		Test::STATUS_TESTER_INVOICE_PAID
+	];
+
 	const STAGES = [
 		0 => "",
 		1 => "Challenge on entry",
@@ -41,6 +51,31 @@ class Test extends Model {
 	const TEST_TIME_DAY = 2;
 	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
 	public function sendAssignEmail($message) {
 
@@ -395,5 +430,36 @@ class Test extends Model {
 	public function isPendingVerification() {
 		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);
 	}
 
+	public static function getDisplayDateTimeFromUTC($dts) {
+		$unix = Util::getUnixTimeFromUTC($dts);
+		return Util::getDisplayDateTime($unix);
+	}
+
 	public static function sortObjectArray($array, $field, $compare_function = "") {
 
 		usort($array, function($a, $b) use ($compare_function, $field) {

+ 1 - 0
template_processing/age_verification/reports_build_charts.php

@@ -25,6 +25,7 @@ $chart->addDataset("Tests", [
 $chart->setPrintSuffixes("");
 $chart->print = true;
 $chart->printPercentages = true;
+$chart->printTotalColumn = true;
 $chart->setPrintLabels(["Stage 1", "Stage 2", "Stage 3", "Stage 4", "Stage 5"]);
 
 $charts[] = $chart;

+ 12 - 7
template_processing/age_verification/test_pdf.php

@@ -111,13 +111,6 @@ $pass_image = $test->pass ? "pass.png" : "fail.png";
 	<strong>Description:</strong><br />
 	<?=TestPDF::getValueHtml($test->challenger_description)?><br />
 
-	<br />
-
-	<div class="subheader">
-		<strong>Tester's Notes</strong>
-	</div>
-
-	<?=TestPDF::getValueHtml($test->additional_notes)?>
 </div>
 
 <div style="float: right; width: 49.5%">
@@ -281,3 +274,15 @@ $pass_image = $test->pass ? "pass.png" : "fail.png";
 		<?=TestPDF::getValueHtml($values["think_21_poster_notes"] ?? "")?>
 	</div>
 </div>
+
+<div class="clear"></div>
+
+<br />
+
+<div>
+	<div class="subheader">
+		<strong>Tester's Notes</strong>
+	</div>
+
+	<?=TestPDF::getValueHtml($test->additional_notes)?>
+</div>

+ 1 - 0
template_processing/age_verification_mitchells_butlers/reports_build_charts.php

@@ -25,6 +25,7 @@ $chart->addDataset("Tests", [
 $chart->setPrintSuffixes("");
 $chart->print = true;
 $chart->printPercentages = true;
+$chart->printTotalColumn = true;
 $chart->setPrintLabels(["Stage 1", "Stage 2", "Stage 3", "Stage 4", "Stage 5"]);
 
 $charts[] = $chart;

+ 12 - 7
template_processing/age_verification_mitchells_butlers/test_pdf.php

@@ -127,13 +127,6 @@ $pass_image = $test->pass ? "pass.png" : "fail.png";
 	<strong>Description:</strong><br />
 	<?=TestPDF::getValueHtml($test->challenger_description)?><br />
 
-	<br />
-
-	<div class="subheader">
-		<strong>Tester's Notes</strong>
-	</div>
-
-	<?=TestPDF::getValueHtml($test->additional_notes)?>
 </div>
 
 <div style="float: right; width: 49.5%">
@@ -302,3 +295,15 @@ $pass_image = $test->pass ? "pass.png" : "fail.png";
 		<?=TestPDF::getValueHtml($values["think_21_poster_notes"] ?? "")?>
 	</div>
 </div>
+
+<div class="clear"></div>
+
+<br />
+
+<div>
+	<div class="subheader">
+		<strong>Tester's Notes</strong>
+	</div>
+
+	<?=TestPDF::getValueHtml($test->additional_notes)?>
+</div>

+ 1 - 0
template_processing/mystery_shop/reports_build_charts.php

@@ -24,6 +24,7 @@ $chart->addDataset("Tests", [
 ]);
 $chart->setPrintSuffixes("");
 $chart->print = true;
+$chart->printTotalColumn = true;
 $chart->printPercentages = true;
 
 $charts[] = $chart;

+ 12 - 4
views/location_form.php

@@ -141,15 +141,23 @@ $tabs = [
 						<h3>Extra Details</h3>
 
 						<div class="row mb-1">
-							<label class="col-sm-4 col-form-label" for="region">Region <span class="badge badge-secondary"></span></label>
+							<label class="col-sm-4 col-form-label" for="internal-id">Internal ID</label>
 							<div class="col-sm">
-								<input class="form-control" type="text" name="region" id="region" placeholder="Enter region" value="<?=htmlspecialchars($location->region)?>" />
+								<input class="form-control" type="text" name="internal_id" id="internal-id" placeholder="Enter internal ID" value="<?=htmlspecialchars($location->internal_id)?>" />
 							</div>
 						</div>
+
 						<div class="row mb-1">
-							<label class="col-sm-4 col-form-label" for="internal-id">Internal ID</label>
+							<label class="col-sm-4 col-form-label" for="brand">Brand</label>
 							<div class="col-sm">
-								<input class="form-control" type="text" name="internal_id" id="internal-id" placeholder="Enter internal ID" value="<?=htmlspecialchars($location->internal_id)?>" />
+								<input class="form-control" type="text" name="brand" id="brand" placeholder="Enter brand" value="<?=htmlspecialchars($location->brand)?>" />
+							</div>
+						</div>
+
+						<div class="row mb-1">
+							<label class="col-sm-4 col-form-label" for="region">Region <span class="badge badge-secondary"></span></label>
+							<div class="col-sm">
+								<input class="form-control" type="text" name="region" id="region" placeholder="Enter region" value="<?=htmlspecialchars($location->region)?>" />
 							</div>
 						</div>
 						<div class="row mb-1">

+ 1 - 0
views/modal_test_invoice.php

@@ -27,6 +27,7 @@
 					<div class="row">
 						<div class="col-sm offset-sm-4">
 							<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>

+ 49 - 2
views/test_list.php

@@ -97,6 +97,23 @@ $custom_filters = [
 								</select>
 							</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">
 							<label class="col-form-label col-sm-4" for="customer-id">Customer</label>
 							<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?>" />
 							</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">
 							<label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
 							<div class="col-sm">
@@ -246,6 +269,7 @@ $custom_filters = [
 						$unix_start = strtotime($test->dts_start . " UTC");
 						$unix_end = strtotime($test->dts_end . " UTC");
 
+
 						?>
 
 						<tr>
@@ -278,6 +302,14 @@ $custom_filters = [
 								?>
 								<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
 								<?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 {
 								?>
@@ -304,12 +336,26 @@ $custom_filters = [
 								<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
 							</td>
 							<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>
 								</div>
 							</td>
 							<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>
 						</tr>
 						<?php
@@ -330,6 +376,7 @@ $custom_filters = [
 						<select class="form-control" name="batch_action" required>
 							<option value="">Select Action</option>
 							<option value="unassign">Unassign</option>
+							<option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
 						</select>
 						<div class="input-group-append">
 							<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">

+ 57 - 1
views/test_verify_form.php

@@ -30,8 +30,27 @@ if($tester) {
 		"Date of Birth" => $tester->date_of_birth,
 		"Gender" => $tester->getGenderText(),
 		"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",
+	];
+
+	if($test->test_travel_cost) {
+		$tester_invoice_details["Travel Costs"] = "£" . number_format($test->test_travel_cost, 2);
+	}
+	else {
+		$tester_invoice_details["Travel Costs"] = "N/A";
+	}
+
+
+	if($test->hasTesterInvoicePDF()) {
+		$tester_invoice_details["PDF"] = "<a href=\"/account/tests/{$test->id}/invoice\" target=\"_blank\">Download Invoice</a>";
+	}
+
 }
 
 function render_card_list_group($details) {
@@ -79,6 +98,11 @@ function render_card_list_group($details) {
 						<a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/pdf" target="_blank">View Sent PDF</a>
 						<?php
 					}
+					if($test->hasTesterInvoicePDF()) {
+						?>
+						<a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice" target="_blank">Download Tester Invoice</a>
+						<?php
+					}
 					?>
 				</div>
 			</div>
@@ -164,6 +188,38 @@ function render_card_list_group($details) {
 							render_card_list_group($tester_details);
 							?>
 						</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">
+											Paid Invoice
+										</button>
+										<button class="btn btn-danger" type="submit" name="reject_tester_invoice" value="1">
+											Reject Invoice
+										</button>
+									</div>
+									<?php
+								}
+
+								?>
+
+
+							</div>
+							<?php
+						}
+						?>
+
 					</div>
 				</div>