Alan Lam 8 лет назад
Родитель
Сommit
c1546c63eb

+ 1 - 0
config.template.php

@@ -28,6 +28,7 @@ define("EMAIL_DOMAIN", "check-policy.co.uk");
 define("EMAIL_NO_REPLY", "noreply@" . EMAIL_DOMAIN);
 define("EMAIL_CONTACT", "contact@" . EMAIL_DOMAIN);
 define("EMAIL_TEST_RESULT", false);
+define("EMAIL_TEST_RESULT_COPY", false);
 
 define("GOOGLE_RECAPTCHA_SITE_KEY", "");
 define("GOOGLE_RECAPTCHA_SECRET", "");

+ 1 - 1
controllers/account.php

@@ -23,7 +23,7 @@ if(Core::$user->level >= User::LEVEL_ADMIN) {
 }
 
 if(Core::$user->level >= User::LEVEL_CUSTOMER) {
-	$links["/account/performance"] = "Performance";
+	$links["/account/reports"] = "Reports";
 	$links["/account/projects"] = "Projects";
 	$links["/account/locations"] = "Locations";
 	$links["/account/templates"] = "Templates";

+ 85 - 30
controllers/performance.php → controllers/reports.php

@@ -2,17 +2,17 @@
 
 Core::addScript("public/js/Chart.bundle.min.js");
 Core::addScript("public/js/chartjs-plugin-datalabels.min.js");
-Core::addScript("public/js/app-performance.js");
+Core::addScript("public/js/app-reports.js");
 
 Core::addBreadcrumb("/account", "Account");
-Core::addBreadcrumb("/account/performance", "Performance");
+Core::addBreadcrumb("/account/reports", "Reports");
 
 $customer = Customer::getForAdmin();
 if(!$customer) throw new Exception("You do not have permission to access this page.");
 
-$page_title = "$customer->name Performance";
+$page_title = "$customer->name Reports";
 
-Core::addBreadcrumb("/account/performance?customer_id=$customer->id", $page_title);
+Core::addBreadcrumb("/account/reports?customer_id=$customer->id", $page_title);
 
 $date_range = http::value("date_range");
 if(!$date_range) $date_range = "ytd";
@@ -426,10 +426,10 @@ if($submit) {
 		// Tests by Stage
 
 		$chart = new Chart;
-		$chart->setType("pie");
+		$chart->setType("doughnut");
 		$chart->setTitle("Tests by Stage $date_range_label");
 		$chart->setLabels(["1 - On Entry", "2 - While Browsing", "3 - During Play", "4 - On Exit", "5 - No Challenge"]);
-		$chart->addDataset("Counts", [
+		$chart->addDataset("Tests", [
 			$total_data->stage1Count,
 			$total_data->stage2Count,
 			$total_data->stage3Count,
@@ -442,9 +442,12 @@ if($submit) {
 				"#FBC02D",
 				"#FFAB91",
 				"#F44336",
-			]
+			],
+			"datalabels" => [
+				"backgroundColor" => "rgba(0, 0, 0, 0.75)",
+				"borderRadius" => "2",
+			],
 		]);
-		$chart->setDatalabelSuffixes(" Test");
 		$chart->setPrintSuffixes("");
 		$chart->print = true;
 		$chart->printPercentages = true;
@@ -505,20 +508,38 @@ if($submit) {
 		$charts[] = $chart;
 
 		// Pass Rate Period
-		$performance = array_values(array_map(function($d) {
+		$pass_rates = array_values(array_map(function($d) {
 			if($d->testCount == 0) return 0;
 			return round(($d->passCount / $d->testCount) * 100);
 		}, $data));
 
+		$fail_rates = array_values(array_map(function($d) {
+			if($d->testCount == 0) return 0;
+			$pass_rate = round(($d->passCount / $d->testCount) * 100);
+			return 100 - $pass_rate;
+		}, $data));
+
 		$chart = new Chart;
-		$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => 100]);
+		$chart->addXAxis([
+			"type" => "category",
+			"stacked" => true,
+		]);
+		$chart->addYAxis([
+			"id" => "y-axis-1",
+			"tick_config" => ["min" => 0, "max" => 100],
+			"stacked" => true,
+		]);
+
 		$chart->setType("bar");
-		$chart->setTitle("Pass Rate by $resolution_name");
+		$chart->setTitle("Pass / Fail by $resolution_name");
 		$chart->setLabels($x_data_labels);
-		$chart->addDataset("Pass Rate (%)", $performance, [
-			"background_colours" => "#2196F3"
+		$chart->addDataset("Pass Rate (%)", $pass_rates, [
+			"background_colours" => "#4CAF50"
 		]);
-		$chart->setDatalabelSuffixes("%");
+		$chart->addDataset("Fail Rate (%)", $fail_rates, [
+			"background_colours" => "#F44336"
+		]);
+		$chart->setDatalabelSuffixes("%", "%");
 		$charts[] = $chart;
 
 		// Totals by Period
@@ -531,10 +552,18 @@ if($submit) {
 		$chart->setType("bar");
 		$chart->setTitle("Totals by $resolution_name");
 		$chart->setLabels($x_data_labels);
-		$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]);
-		$chart->addYAxis("linear", "right", "y-axis-2", false, ["min" => 0, "max" => 100]);
+		$chart->addYAxis([
+			"id" => "y-axis-1",
+			"tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
+		]);
+		$chart->addYAxis([
+			"position" => "right",
+			"id" => "y-axis-2",
+			"grid_lines" => false,
+			"tick_config" => ["min" => 0, "max" => 100]
+		]);
 
-		$chart->addDataset("Pass Rate (%)", $performance, [
+		$chart->addDataset("Pass Rate (%)", $pass_rates, [
 			"border_colours" => "#FFEB3B",
 			"background_colours" => "transparent",
 			"type" => "line",
@@ -542,6 +571,7 @@ if($submit) {
 			"datalabels" => [
 				"display" => false
 			],
+			"line_tension" => 0,
 		]);
 		$chart->addDataset("Test Count", $test_counts, [
 			"background_colours" => "#2196F3",
@@ -597,9 +627,12 @@ if($submit) {
 					"#FBC02D",
 					"#FFAB91",
 					"#F44336",
-				]
+				],
+				"datalabels" => [
+					"backgroundColor" => "rgba(0, 0, 0, 0.75)",
+					"borderRadius" => "2",
+				],
 			]);
-			$chart->setDatalabelSuffixes(" Test");
 			$charts[] = $chart;
 		}
 
@@ -613,7 +646,11 @@ if($submit) {
 		}, $data));
 
 		$chart = new Chart;
-		$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]);
+		$chart->addYAxis([
+			"id" => "y-axis-1",
+			"tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]
+		]);
+
 		$chart->setType("bar");
 		$chart->setTitle("Tester Gender by $resolution_name");
 		$chart->setLabels($x_data_labels);
@@ -623,7 +660,6 @@ if($submit) {
 		$chart->addDataset("Female", $female_counts, [
 			"background_colours" => "#E91E63"
 		]);
-		$chart->setDatalabelSuffixes(" M", " F");
 		$charts[] = $chart;
 
 		// Test Count by Period
@@ -632,14 +668,16 @@ if($submit) {
 		}, $data));
 
 		$chart = new Chart;
-		$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]);
+		$chart->addYAxis([
+			"id" => "y-axis-1",
+			"tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
+		]);
 		$chart->setType("bar");
 		$chart->setTitle("Tests by $resolution_name");
 		$chart->setLabels($x_data_labels);
 		$chart->addDataset("Tests", $test_counts, [
 			"background_colours" => "#2196F3"
 		]);
-		$chart->setDatalabelSuffixes(" Test");
 		$charts[] = $chart;
 
 		$pass_counts = array_column($data, "passCount");
@@ -665,7 +703,10 @@ if($submit) {
 			}
 
 			$chart = new Chart;
-			$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => 100]);
+			$chart->addYAxis([
+				"id" => "y-axis-1",
+				"tick_config" => ["min" => 0, "max" => 100]
+			]);
 			$chart->setType("bar");
 			$chart->setTitle("Region Pass Rate $date_range_label");
 			$chart->setLabels($x_data_labels);
@@ -677,7 +718,10 @@ if($submit) {
 
 			// Region Pass Rate Period
 			$chart = new Chart;
-			$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => 100]);
+			$chart->addYAxis([
+				"id" => "y-axis-1",
+				"tick_config" => ["min" => 0, "max" => 100]
+			]);
 			$chart->setType("bar");
 			$chart->setTitle("Region Pass Rate by $resolution_name");
 			$chart->setLabels($x_data_labels);
@@ -724,7 +768,10 @@ if($submit) {
 					"labelString" => "Area Manager",
 				]
 			]);
-			$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => 100]);
+			$chart->addYAxis([
+				"id" => "y-axis-1",
+				"tick_config" => ["min" => 0, "max" => 100]
+			]);
 			$chart->setType("bar");
 			$chart->setTitle("Area Manager Pass Rate $date_range_label");
 			$chart->setLabels($x_data_labels);
@@ -743,7 +790,10 @@ if($submit) {
 					"labelString" => "Area Manager",
 				]
 			]);
-			$chart->addYAxis("linear", "left", "y-axis-1", true, ["min" => 0, "max" => 100]);
+			$chart->addYAxis([
+				"id" => "y-axis-1",
+				"tick_config" => ["min" => 0, "max" => 100]
+			]);
 			$chart->setType("bar");
 			$chart->setTitle("Area Manager Pass Rate by $resolution_name");
 			$chart->setLabels($x_data_labels);
@@ -754,7 +804,12 @@ if($submit) {
 					$a_data = $area_manager_data[$area_manager][$key];
 					$data_values[] = ($a_data->testCount == 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
 				}
-				$chart->addDataset($key_labels[$index], $data_values, ["background_colours" => $colours[$index]]);
+				$chart->addDataset($key_labels[$index], $data_values, [
+					"background_colours" => $colours[$index],
+					"datalabels" => [
+						"display" => false,
+					],
+				]);
 			}
 			$chart->setDatalabelSuffixes(...array_fill(0, count($keys), "%"));
 
@@ -779,7 +834,7 @@ if($submit) {
 			case "export-pptx":
 			case "export-odp":
 
-				require "performance_presentation.php";
+				require "reports_presentation.php";
 
 				break;
 			default:
@@ -791,7 +846,7 @@ if($submit) {
 
 
 View::includeOnce("header", compact("page_title"));
-View::include("performance", compact("customer", "date_range", "from_quarter", "to_quarter", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "region_data", "area_manager_data"));
+View::include("reports", compact("customer", "date_range", "from_quarter", "to_quarter", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "region_data", "area_manager_data"));
 View::includeOnce("footer");
 
 ?>

+ 0 - 0
controllers/performance_presentation.php → controllers/reports_presentation.php


+ 46 - 27
controllers/test.php

@@ -59,9 +59,28 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 				// Parse after the test form
 				$fields = $json->duringTest;
 
+				// Start/End times
 				if($is_started) {
-					$duration = http::value("duration", "int");
-					if(!$duration) $form_exception->addError("Duration was not submitted.");
+					$start_override = http::getDateTimeFromFields("start_override");
+					$end_override = http::getDateTimeFromFields("end_override");
+
+					$start_unix = null;
+					$end_unix = null;
+
+					if($start_override && $end_override) {
+						$start_unix = strtotime($start_override);
+						$end_unix = strtotime($end_override);
+
+						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.");
+					}
+
 				}
 
 			}
@@ -131,24 +150,6 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 
 			}
 
-			// Date/Time Overrides
-			$start_override = http::getDateTimeFromFields("start_override");
-			$end_override = http::getDateTimeFromFields("end_override");
-
-			$start_unix = null;
-			$end_unix = null;
-
-			if($start_override && $end_override) {
-				$start_unix = strtotime($start_override);
-				$end_unix = strtotime($end_override);
-
-				if($start_unix > $end_unix) $form_exception->addError("Test Start date/time must not be after Test End date/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("Test End date/time cannot be later than the recorded start date/time.");
-				}
-			}
-
 			if($form_exception->hasErrors()) throw $form_exception;
 
 			date_default_timezone_set("UTC");
@@ -161,6 +162,8 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 				$success = $test->commit();
 				if(!$success) throw new Exception("Failed to save test. Please try again later.");
 
+				Core::addAlert("success", "Photos uploaded successfully.");
+
 				HTTP::redirect("/account/tests/$id");
 
 			}
@@ -170,15 +173,13 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 				$test->status = Test::STATUS_PENDING_VERIFICATION;
 
 				if($is_started) {
-					$unix_start = strtotime($test->dts_start);
-					$unix_end = $unix_start + floor($duration / 1000); // $duration is milliseconds
-
-					$test->dts_end = date("Y-m-d H:i:s", $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);
 					}
+					else if($end_unix) {
+						$test->dts_end = date("Y-m-d H:i:s", $end_unix);
+					}
 				}
 
 				$test->pass = ($test->challenge_stage <= 2) ? 1 : 0; // Pass = Challenged during browsing or before
@@ -192,10 +193,20 @@ if(Core::$user->level == User::LEVEL_TESTER) {
 
 		}
 		catch(FormException $e) {
-			$e->generateAlerts();
+			if(HTTP::isAJAX()) {
+				$e->generateJSONError();
+			}
+			else {
+				$e->generateAlerts();
+			}
 		}
 		catch(Exception $e) {
-			Core::addAlert("danger", $e->getMessage());
+			if(HTTP::isAJAX()) {
+				JSON::fail($e->getMessage());
+			}
+			else {
+				Core::addAlert("danger", $e->getMessage());
+			}
 		}
 
 		date_default_timezone_set($previous_timezone);
@@ -238,6 +249,10 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 			$accept = http::value("accept");
 			$reject = http::value("reject");
 
+			if(($accept || $reject) && $test->status != Test::STATUS_PENDING_VERIFICATION) {
+				throw new Exception("This test is no longer pending verification.");
+			}
+
 			if(empty($test->verifier_id)) {
 				$test->verifier_id = Core::$user->id;
 				$test->dts_verified = Util::getDateTime();
@@ -359,6 +374,10 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 					$test->sendResultEmail(EMAIL_TEST_RESULT);
 				}
 
+				if(EMAIL_TEST_RESULT_COPY) {
+					$test->sendResultEmail(EMAIL_TEST_RESULT_COPY);
+				}
+
 			}
 
 			Core::addAlert("success", "Test verified successfully.");

+ 29 - 1
engine/chart.php

@@ -9,6 +9,9 @@ class Chart {
 	private $labels = [];
 	private $printLabels = null;
 
+	private $tooltipsMode = "nearest";
+	private $tooltipsIntersect = true;
+
 	private $xAxes = [];
 	private $yAxes = [];
 
@@ -34,6 +37,7 @@ class Chart {
 		$grid_lines = $options["grid_lines"] ?? true;
 		$tick_config = $options["tick_config"] ?? null;
 		$scale_label_config = $options["scale_label_config"] ?? null;
+		$stacked = $options["stacked"] ?? false;
 
 		$axis = [
 			"type" => $type,
@@ -43,6 +47,7 @@ class Chart {
 			"gridLines" => [
 				"drawOnChartArea" => $grid_lines
 			],
+			"stacked" => $stacked,
 		];
 
 		if($tick_config) {
@@ -56,7 +61,15 @@ class Chart {
 		$this->xAxes[] = $axis;
 	}
 
-	public function addYAxis($type, $position, $id, $grid_lines = true, $tick_config = []) {
+	public function addYAxis($options = []) {
+
+		$type = $options["type"] ?? "linear";
+		$position = $options["position"] ?? "left";
+		$id = $options["id"] ?? "y-axis-0";
+		$grid_lines = $options["grid_lines"] ?? true;
+		$tick_config = $options["tick_config"] ?? null;
+		$scale_label_config = $options["scale_label_config"] ?? null;
+		$stacked = $options["stacked"] ?? false;
 
 		$axis = [
 			"type" => $type,
@@ -66,6 +79,7 @@ class Chart {
 			"gridLines" => [
 				"drawOnChartArea" => $grid_lines
 			],
+			"stacked" => $stacked,
 		];
 
 		if($tick_config) {
@@ -99,6 +113,7 @@ class Chart {
 		$y_axis_id = $options["y_axis_id"] ?? false;
 		$type = $options["type"] ?? false;
 		$datalabels = $options["datalabels"] ?? false;
+		$line_tension = $options["line_tension"] ?? null;
 
 		$dataset = [
 			"label" => $label,
@@ -111,6 +126,7 @@ class Chart {
 		if($y_axis_id) $dataset["yAxisID"] = $y_axis_id;
 		if($type) $dataset["type"] = $type;
 		if($datalabels) $dataset["datalabels"] = $datalabels;
+		if(isset($line_tension)) $dataset["lineTension"] = $line_tension;
 
 		$this->datasets[] = (object) $dataset;
 
@@ -175,6 +191,10 @@ class Chart {
 				"legend" => (object) [
 					"position" => "top",
 				],
+				"tooltips" => (object) [
+					"mode" => $this->tooltipsMode,
+					"intersect" => $this->tooltipsIntersect,
+				],
 				"plugins" => (object) [
 					"datalabels" => [
 						"color" => "white",
@@ -287,6 +307,14 @@ class Chart {
 		$this->afterHtml = $html;
 	}
 
+	public function setTooltipsMode($mode) {
+		$this->tooltipsMode = $mode;
+	}
+
+	public function setTooltipsIntersect($intersect) {
+		$this->tooltipsIntersect = $intersect;
+	}
+
 }
 
 ?>

+ 89 - 92
engine/template.php

@@ -66,22 +66,7 @@ class Template extends Model {
 		?>
 		<form method="post" id="test-form">
 
-			<input type="hidden" name="duration" id="duration" value="" required />
-
-			<div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
-
-				<div>
-					<button class="btn btn-block btn-success mb-3" type="button" id="test-start-button">
-						Start Timer
-					</button>
-					<button class="btn btn-block btn-danger mb-3" type="button" id="test-stop-button" style="display: none;">
-						Stop Timer
-					</button>
-					<small><span id="test-duration-span">Photos uploaded successfully.<br />Please use the timer to record the duration that you were in the venue.<br /> Alternatively press <span class="text-danger">Stop Timer</span> immediately to skip the timer and note the duration in Additional Notes.</span></small>
-				</div>
-			</div>
-
-			<div class="collapse" id="test-main-form-container">
+			<div id="test-main-form-container">
 				<div class="alert alert-info">
 					<i class="fal fa-fw fa-info-circle"></i>
 					Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
@@ -93,91 +78,103 @@ class Template extends Model {
 				}
 				?>
 
-				<h3>Date/Time Overrides</h3>
+				<h3>Entry/Exit Times</h3>
 
-				<p>If you are submitting this form outside of the actual test, please use the following fields to specify when you did the test.</p>
+				<p>Please confirm your entry and exit times below. Please try to be as accurate as possible.</p>
 
 				<div class="row mb-1">
-					<label class="col-sm-4 col-form-label" for="start-override-hour">Test Start</label>
+					<label class="col-sm-4 col-form-label" for="start-override-hour">Entry Time <span class="badge badge-danger">Required</span></label>
 					<div class="col-sm">
-						<select class="form-control 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 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 w-auto d-inline-block" name="start_override_second" id="start-override-second">
-							<option value="">SS</option>
-							<?php
-							Form::renderSecondOptions(0);
-							?>
-						</select><br />
-						<select class="form-control 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 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 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="row">
+							<div class="col-lg">
+								<select class="form-control 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 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 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">
+								<select class="form-control 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 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 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>
+						</div>
 					</div>
 				</div>
 
 				<div class="row mb-1">
-					<label class="col-sm-4 col-form-label" for="end-override-hour">Test End</label>
+					<label class="col-sm-4 col-form-label" for="end-override-hour">Exit Time <span class="badge badge-danger">Required</span></label>
 					<div class="col-sm">
-						<select class="form-control 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 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 w-auto d-inline-block" name="end_override_second" id="end-override-second">
-							<option value="">SS</option>
-							<?php
-							Form::renderSecondOptions(0);
-							?>
-						</select><br />
-						<select class="form-control 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 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 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="row">
+							<div class="col-lg">
+								<select class="form-control 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 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 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">
+								<select class="form-control 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 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 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>
+						</div>
 					</div>
 				</div>
 

BIN
public/img/markers/address.png


+ 0 - 0
public/js/app-performance.js → public/js/app-reports.js


+ 3 - 55
public/js/app-test.js

@@ -19,11 +19,6 @@ function initialiseTestForm() {
 
 	$form = $("#test-form");
 
-	$stopButtonContainer = $("#test-stop-button-container");
-
-	$startButton = $("#test-start-button");
-	$stopButton = $("#test-stop-button");
-
 	$testMainFormContainer = $("#test-main-form-container");
 	$submitButton = $("#test-submit-button");
 
@@ -31,40 +26,6 @@ function initialiseTestForm() {
 
 	$submitStatus = $("#test-submit-status");
 
-	$startButton.on("click", function(event) {
-		event.preventDefault();
-
-		var date = new Date();
-		testStartTime = date.getTime();
-
-		$startButton.detach();
-		$stopButton.show();
-
-		updateDurationText();
-		durationInterval = setInterval(updateDurationText, 1000);
-
-	});
-
-	$stopButton.on("click", function(event) {
-
-		event.preventDefault();
-
-		clearInterval(durationInterval);
-
-		var date = new Date();
-		var testEndTime = date.getTime();
-
-		var testDuration = testEndTime - testStartTime;
-
-		$("#duration").val(testDuration);
-
-		$stopButtonContainer.addClass("d-none");
-
-		$testMainFormContainer.collapse("show");
-
-	});
-
-
 	$form.on("submit", function(event) {
 
 		event.preventDefault();
@@ -83,7 +44,8 @@ function initialiseTestForm() {
 
 				try {
 					var data = $.parseJSON(data);
-					if(!data.success) throw "Unsuccessful.";
+					if(!data.success && data.message) throw data.message;
+					else if(!data.success) throw "Please try again later.";
 
 					$submitStatus.html("Submitted. Thank you for participating in this test. You will be redirected to the Tests page in three seconds.");
 					setTimeout(function() {
@@ -91,11 +53,9 @@ function initialiseTestForm() {
 					}, 3000);
 				}
 				catch(err) {
-					$submitStatus.html("Error, please try again later.");
+					$submitStatus.html("Error: " + err);
 					$submitButton.removeAttr("disabled");
 				}
-
-				console.log(data);
 			},
 			error: function(request, status, error) {
 				console.log(request, status, error);
@@ -106,16 +66,4 @@ function initialiseTestForm() {
 		});
 
 	});
-}
-
-function updateDurationText() {
-
-	var date = new Date();
-	var testEndTime = date.getTime();
-
-	var duration = testEndTime - testStartTime;
-	var secs = Math.floor(duration / 1000) % 60;
-	var mins = Math.floor(duration / 60000);
-
-	$("#test-duration-span").text(mins + " min. " + secs + " sec.");
 }

+ 5 - 2
public/js/app-user.js

@@ -46,7 +46,8 @@ function initialiseAddresses() {
 			let options = {
 				map: map,
 				position: position,
-				title: address.name
+				title: address.name,
+				icon: "/img/markers/address.png"
 			}
 
 			bounds.extend(position);
@@ -94,7 +95,8 @@ function initialiseLocations() {
 		let options = {
 			map: map,
 			position: position,
-			title: response.name
+			title: response.name,
+			icon: "/img/markers/address.png"
 		}
 
 		bounds.extend(position);
@@ -119,6 +121,7 @@ function initialiseLocations() {
 			}
 
 			if(location.icon) options.icon = "/img/markers/" + location.icon;
+			else options.icon = "/img/markers/building-red.png";
 
 			bounds.extend(position);
 

+ 3 - 3
routes.php

@@ -120,9 +120,9 @@ $routes = [
 	// Submit ID
 	"/^account\/submit-id$/" => ["controller" => "submit_id", "require_user_level" => User::LEVEL_REGISTERED],
 
-	// Performance
-	"/^account\/performance$/" => ["controller" => "performance", "require_user_level" => User::LEVEL_VENUE],
-	"/^account\/performance\/(export-odp|export-pptx)$/" => ["controller" => "performance", "params" => ["action"], "require_user_level" => User::LEVEL_VENUE],
+	// Reports
+	"/^account\/reports$/" => ["controller" => "reports", "require_user_level" => User::LEVEL_VENUE],
+	"/^account\/reports\/(export-odp|export-pptx)$/" => ["controller" => "reports", "params" => ["action"], "require_user_level" => User::LEVEL_VENUE],
 
 
 ];

+ 2 - 2
views/performance.php → views/reports.php

@@ -19,7 +19,7 @@ $date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
 <div class="container">
 	<div class="row d-print-none">
 		<div class="col">
-			<h2><?=htmlspecialchars($customer->name)?> Performance</h2>
+			<h2><?=htmlspecialchars($customer->name)?> Reports</h2>
 		</div>
 		<div class="col-auto">
 			<?php
@@ -305,7 +305,7 @@ $date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
 		<?php
 		foreach(["pptx", "odp"] as $format) {
 			?>
-			<form id="form-<?=$format?>" method="post" action="/account/performance/export-<?=$format?>" data-rendered="0">
+			<form id="form-<?=$format?>" method="post" action="/account/reports/export-<?=$format?>" data-rendered="0">
 				<input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
 				<input type="hidden" name="customer_id" value="<?=intval($customer->id)?>" />
 				<input type="hidden" name="date_range" value="<?=htmlspecialchars($date_range)?>" />

+ 1 - 1
views/test_list_assigned.php

@@ -15,7 +15,7 @@
 
 		if(!empty($tests)) {
 			?>
-			<div class="dropdown">
+			<div class="dropdown d-inline">
 				<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
 					Actions
 				</a>