瀏覽代碼

Count only tests that have been completed

Alan Lam 2 年之前
父節點
當前提交
5f1345caab
共有 2 個文件被更改,包括 2 次插入 和 7 次删除
  1. 1 1
      controllers/locations.php
  2. 1 6
      views/location_tests_tab.php

+ 1 - 1
controllers/locations.php

@@ -149,7 +149,7 @@ $location_ids_csv = implode(", ", $location_ids);
 $sql = "SELECT `location`.*, COUNT(`test`.`id`) AS `test_count`, SUM(IF(`test`.`retest` = 1, 1, 0)) AS `retest_count` 
 $sql = "SELECT `location`.*, COUNT(`test`.`id`) AS `test_count`, SUM(IF(`test`.`retest` = 1, 1, 0)) AS `retest_count` 
 	FROM `location` 
 	FROM `location` 
     LEFT JOIN `test` ON `test`.`location_id`=`location`.`id` AND `dts_start` BETWEEN '$date_start' AND '$date_end' 
     LEFT JOIN `test` ON `test`.`location_id`=`location`.`id` AND `dts_start` BETWEEN '$date_start' AND '$date_end' 
-	WHERE `location`.`id` IN ($location_ids_csv) GROUP BY `location`.`id`
+	WHERE `location`.`id` IN ($location_ids_csv) AND (`test`.`status`='" . Test::STATUS_COMPLETED . "' OR `test`.`status` IS NULL)  GROUP BY `location`.`id`
 	ORDER BY $query_sort $order
 	ORDER BY $query_sort $order
 ";
 ";
 
 

+ 1 - 6
views/location_tests_tab.php

@@ -3,12 +3,7 @@
  * @var Location $location
  * @var Location $location
  */
  */
 
 
-if(Core::$user->isAdmin()) {
-    $tests = $location->getTests();
-}
-else {
-    $tests = $location->getCompletedTests();
-}
+$tests = $location->getCompletedTests();
 
 
 ?>
 ?>