Alan Lam пре 4 година
родитељ
комит
77372a7266
1 измењених фајлова са 2 додато и 20 уклоњено
  1. 2 20
      views/location_list.php

+ 2 - 20
views/location_list.php

@@ -1,23 +1,8 @@
 <?php
 /**
- * @var Customer $customer
  * @var Location[] $locations
  */
 
-[$date_start, $date_end] = $customer->getYearCycleDates();
-
-$counts = [];
-
-if($locations) {
-	$location_ids_csv = implode(", ", array_column($locations, "id"));
-
-	$sql = "SELECT `location_id`, COUNT(`id`) AS `test_count`, SUM(IF(`retest` = 1, 1, 0)) AS `retest_count` FROM `test` WHERE `location_id` IN ($location_ids_csv) AND `dts_start` BETWEEN '$date_start' AND '$date_end' GROUP BY `location_id`";
-	$result = DB::query($sql);
-	while($row = DB::fetchAssoc($result)) {
-		$counts[$row["location_id"]] = $row;
-	}
-}
-
 ?>
 <div class="table-responsive limit-height-2">
 	<table class="table table-sm table-sm-text table-hover">
@@ -38,9 +23,6 @@ if($locations) {
 			$class = "";
 			if($location->isArchived()) $class = "text-muted";
 
-			$test_count = $counts[$location->id]["test_count"] ?? 0;
-			$retest_count = $counts[$location->id]["retest_count"] ?? 0;
-
 			?>
 			<tr class="<?=$class?>">
 				<td class="text-right pr-3">
@@ -70,10 +52,10 @@ if($locations) {
 					<?=htmlspecialchars($location->internal_id)?>
 				</td>
 				<td class="text-right">
-					<?=htmlspecialchars(number_format($test_count))?>
+					<?=htmlspecialchars(number_format($location->test_count))?>
 				</td>
 				<td class="text-right">
-					<?=htmlspecialchars(number_format($retest_count))?>
+					<?=htmlspecialchars(number_format($location->retest_count))?>
 				</td>
 				<td class="text-right align-middle">
 					<a class="btn btn-sm btn-outline-primary" href="/account/locations/<?=$location->id?>/edit">Edit</a>