Преглед изворни кода

Add additional test details to location markers

Alan Lam пре 8 година
родитељ
комит
3e6a1f9347
2 измењених фајлова са 54 додато и 5 уклоњено
  1. 32 3
      controllers/map_overview_ajax.php
  2. 22 2
      public/js/app-map-overview.js

+ 32 - 3
controllers/map_overview_ajax.php

@@ -43,6 +43,9 @@ if($submit) {
 					}
 					}
 				}
 				}
 
 
+				$tester_ids = array_column($location_test_array, "tester_id");
+				User::load($tester_ids);
+
 				$output = [];
 				$output = [];
 
 
 				foreach($locations as $location) {
 				foreach($locations as $location) {
@@ -51,18 +54,27 @@ if($submit) {
 
 
 					$customer_slug = str_replace("-", "_", Util::slug($customer->name));
 					$customer_slug = str_replace("-", "_", Util::slug($customer->name));
 
 
+					$tester = null;
+					$formatted_due_dts = null;
+
 					$icon = null;
 					$icon = null;
 					$icon_file = "{$customer_slug}_none.png";
 					$icon_file = "{$customer_slug}_none.png";
 
 
+					$past_due = false;
+
 					if($test) {
 					if($test) {
 
 
-						$unix_due = Util::getUnixTimeFromUTC($test->dts_due);
+						$tester = $test->getTester();
+
+						$unix_due = strtotime($test->dts_due);
+						$formatted_due_dts = date("d/m/Y H:i", $unix_due);
 
 
 						if(is_null($test->pass)) {
 						if(is_null($test->pass)) {
 							$icon_file = "{$customer_slug}_pending.png";
 							$icon_file = "{$customer_slug}_pending.png";
 
 
-							if(time() > $unix_due) {
+							if($tester && $test->dts_due && time() > $unix_due) {
 								$icon_file = "{$customer_slug}_past_due.png";
 								$icon_file = "{$customer_slug}_past_due.png";
+								$past_due = true;
 							}
 							}
 						}
 						}
 						else if($test->pass) {
 						else if($test->pass) {
@@ -84,9 +96,26 @@ if($submit) {
 						"name" => $location->name,
 						"name" => $location->name,
 						"latitude" => (float) $location->latitude,
 						"latitude" => (float) $location->latitude,
 						"longitude" => (float) $location->longitude,
 						"longitude" => (float) $location->longitude,
-						"icon" => $icon
+						"icon" => $icon,
+						"test" => null,
 					];
 					];
 
 
+					if($test) {
+						$data["test"] = [
+							"id" => $test->id,
+							"formattedDueDts" => $formatted_due_dts,
+							"tester" => null,
+							"pastDue" => $past_due,
+						];
+
+						if($tester) {
+							$data["test"]["tester"] = [
+								"id" => $tester->id,
+								"name" => $tester->getDisplayName(),
+							];
+						}
+					}
+
 					$output[] = $data;
 					$output[] = $data;
 				}
 				}
 
 

+ 22 - 2
public/js/app-map-overview.js

@@ -217,9 +217,29 @@ function addMarkerClickListenerForLocation(m, l) {
 	m.addListener("click", function() {
 	m.addListener("click", function() {
 		let content = "<strong><a href=\"/account/locations/" + l.id + "\" target=\"_blank\">" + l.name + "</a></strong><br />";
 		let content = "<strong><a href=\"/account/locations/" + l.id + "\" target=\"_blank\">" + l.name + "</a></strong><br />";
 		if(l.internalId) {
 		if(l.internalId) {
-			content += "Internal ID: " + l.internalId + "<br />";
+			content += "<div class=\"small\"><strong>Internal ID:</strong> " + l.internalId + "</div>";
 		}
 		}
-		content += "ID: " + l.id + "<br />";
+		content += "<div class=\"small\"><strong>Location ID:</strong> " + l.id + "</div>";
+
+		if(l.test) {
+
+			content += '<div class="small"><strong>Test ID:</strong> <a href="/account/tests/' + l.test.id + '" target="_blank">' + l.test.id + '</a></div>';
+
+			if(l.test.tester) {
+				content += '<div class="small"><strong>Tester ID:</strong> ' + l.test.tester.id + '</div>';
+				content += '<div class="small"><strong>Tester Name:</strong> <a href="/account/users/' + l.test.tester.id + '" target="_blank">' + l.test.tester.name + '</a></div>';
+			}
+
+			let pastDueBadge = '';
+			if(l.test.pastDue) {
+				pastDueBadge = '<span class="badge badge-lg badge-primary">Past Due</span>';
+			}
+
+			if(l.test.formattedDueDts) {
+				content += '<div class="small"><strong>Due:</strong> ' + l.test.formattedDueDts + ' ' + pastDueBadge + '</div>';
+			}
+		}
+
 
 
 		infoWindow.setContent(content);
 		infoWindow.setContent(content);
 		infoWindow.open(map, m);
 		infoWindow.open(map, m);