| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?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">
- <thead>
- <tr>
- <th class="text-right pr-3">ID</th>
- <th>Name / Address</th>
- <th>Legal Entity</th>
- <th>Internal ID</th>
- <th>Tests</th>
- <th>Retests</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($locations as $location) {
- $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">
- <?=$location->id?>
- </td>
- <td>
- <a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a>
- <?php
- if($location->closed) {
- ?>
- <span class="badge badge-danger">Closed</span>
- <?php
- }
- if($location->isArchived()) {
- ?>
- <span class="badge badge-secondary"><?=htmlspecialchars(__("Archived"))?></span>
- <?php
- }
- ?>
- <br />
- <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]))?></small>
- </td>
- <td>
- <?=htmlspecialchars($location->legal_entity_name)?>
- </td>
- <td>
- <?=htmlspecialchars($location->internal_id)?>
- </td>
- <td class="text-right">
- <?=htmlspecialchars(number_format($test_count))?>
- </td>
- <td class="text-right">
- <?=htmlspecialchars(number_format($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>
- </td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php
- if(empty($locations)) {
- ?>
- <div class="alert alert-info">
- No locations to display.
- </div>
- <?php
- }
- ?>
|