|
|
@@ -2,6 +2,11 @@
|
|
|
|
|
|
/**
|
|
|
* @var Project $project
|
|
|
+ * @var Template[] $templates
|
|
|
+ * @var Customer $customer
|
|
|
+ * @var int[] $location_ids
|
|
|
+ * @var Location[] $locations
|
|
|
+ * @var Template $template
|
|
|
*/
|
|
|
|
|
|
$date_start = explode(" ", date("Y-m-d H:i:s", strtotime($project->dts_start . " UTC")))[0];
|
|
|
@@ -25,6 +30,80 @@ $time_of_day_options = [
|
|
|
$name_readonly = $project->id ? "" : "readonly";
|
|
|
$autogen_checked = $project->id ? "" : "checked";
|
|
|
|
|
|
+$tests = [];
|
|
|
+if($project->id) {
|
|
|
+ $tests = $project->getTests();
|
|
|
+ $location_test = [];
|
|
|
+ foreach($tests as $test) {
|
|
|
+ $location_test[$test->location_id] = $test;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+$selected_locations = array_filter($locations, function(Location $l) use ($location_ids) { return in_array($l->id, $location_ids); });
|
|
|
+$deselected_locations = array_filter($locations, function(Location $l) use ($location_ids) { return !in_array($l->id, $location_ids); });
|
|
|
+
|
|
|
+$output_locations = function(array $locations, bool $selected) use ($location_test) {
|
|
|
+ foreach($locations as $location) {
|
|
|
+ $address = $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
|
|
|
+
|
|
|
+ $filter_parts = array_filter([
|
|
|
+ $address, $location->name
|
|
|
+ ]);
|
|
|
+ $filter = strtolower(implode("", $filter_parts));
|
|
|
+
|
|
|
+ $button_class = $selected ? "danger" : "success";
|
|
|
+ $button_text = $selected ? "Deselect" : "Select";
|
|
|
+ $icon = $selected ? "times" : "check";
|
|
|
+
|
|
|
+ $test = $location_test[$location->id] ?? null;
|
|
|
+ $test_status = $test_class = "";
|
|
|
+ if($test) {
|
|
|
+ $test_status = $test->getStatusText();
|
|
|
+ $test_class = $test->getStatusClass();
|
|
|
+ }
|
|
|
+
|
|
|
+ ?>
|
|
|
+ <div class="list-group-item" data-location-id="<?=$location->id?>" data-internal-id="<?=htmlspecialchars($location->internal_id)?>" data-name="<?=htmlspecialchars($location->name)?>" data-filter-value="<?=htmlspecialchars($filter)?>">
|
|
|
+ <div class="row no-gutters">
|
|
|
+ <div class="col-2 text-right">
|
|
|
+ <?=$location->id?>
|
|
|
+ </div>
|
|
|
+ <div class="col hover-container px-3">
|
|
|
+ <a href="/account/locations/<?=$location->id?>" target="_blank"><?=htmlspecialchars($location->name)?></a>
|
|
|
+ <a class="visible-on-hover float-right" href="/account/locations/<?=$location->id?>/edit" target="_blank"><i class="fal fa-pencil"></i> Edit</a>
|
|
|
+ <div>
|
|
|
+ <?php
|
|
|
+ if($test) {
|
|
|
+ ?>
|
|
|
+ <div class="badge badge-<?=$test_class?>">
|
|
|
+ <?=htmlspecialchars($test_status)?>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ if($location->internal_id) {
|
|
|
+ ?>
|
|
|
+ <span class="badge badge-primary">Internal ID: <?=htmlspecialchars($location->internal_id)?></span>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <small><?=htmlspecialchars($address)?></small>
|
|
|
+ </div>
|
|
|
+ <div class="col-auto align-self-center text-right">
|
|
|
+ <button class="btn btn-outline-<?=$button_class?>" type="button">
|
|
|
+ <i class="fas fa-<?=$icon?>"></i>
|
|
|
+ <span class="sr-only"><?=htmlspecialchars($button_text)?></span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
?>
|
|
|
<div class="container mt-3 py-4">
|
|
|
<h2>
|
|
|
@@ -335,44 +414,7 @@ $autogen_checked = $project->id ? "" : "checked";
|
|
|
|
|
|
<div class="list-group list-group-flush limit-height-2" id="selected-locations-list-group">
|
|
|
<?php
|
|
|
- foreach($locations as $index => $location) {
|
|
|
- if(!in_array($location->id, $location_ids)) continue;
|
|
|
-
|
|
|
- $address = $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
|
|
|
-
|
|
|
- $filter_parts = array_filter([
|
|
|
- $address, $location->name
|
|
|
- ]);
|
|
|
- $filter = strtolower(implode("", $filter_parts));
|
|
|
- ?>
|
|
|
- <div class="list-group-item" data-location-id="<?=$location->id?>" data-internal-id="<?=htmlspecialchars($location->internal_id)?>" data-name="<?=htmlspecialchars($location->name)?>" data-filter-value="<?=htmlspecialchars($filter)?>">
|
|
|
- <div class="row no-gutters">
|
|
|
- <div class="col-2 text-right">
|
|
|
- <?=$location->id?>
|
|
|
- </div>
|
|
|
- <div class="col hover-container px-3">
|
|
|
- <a href="/account/locations/<?=$location->id?>" target="_blank"><?=htmlspecialchars($location->name)?></a>
|
|
|
- <a class="visible-on-hover float-right" href="/account/locations/<?=$location->id?>/edit" target="_blank"><i class="fal fa-pencil"></i> Edit</a>
|
|
|
- <?php
|
|
|
- if($location->internal_id) {
|
|
|
- ?>
|
|
|
- <br />
|
|
|
- <small class="text-primary">Internal ID: <?=htmlspecialchars($location->internal_id)?></small>
|
|
|
- <?php
|
|
|
- }
|
|
|
- ?><br />
|
|
|
- <small><?=htmlspecialchars($address)?></small>
|
|
|
- </div>
|
|
|
- <div class="col-auto align-self-center text-right">
|
|
|
- <button class="btn btn-outline-danger" type="button">
|
|
|
- <i class="fas fa-times"></i>
|
|
|
- <span class="sr-only">Deselect</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <?php
|
|
|
- }
|
|
|
+ $output_locations($selected_locations, true);
|
|
|
?>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -397,47 +439,9 @@ $autogen_checked = $project->id ? "" : "checked";
|
|
|
</div>
|
|
|
|
|
|
<div class="list-group list-group-flush limit-height-2" id="not-selected-locations-list-group">
|
|
|
- <?php
|
|
|
- foreach($locations as $index => $location) {
|
|
|
- if(in_array($location->id, $location_ids)) continue;
|
|
|
-
|
|
|
- $address = $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
|
|
|
-
|
|
|
- $filter_parts = array_filter([
|
|
|
- $address, $location->name
|
|
|
- ]);
|
|
|
- $filter = strtolower(implode("", $filter_parts));
|
|
|
- ?>
|
|
|
- <div class="list-group-item" data-location-id="<?=$location->id?>" data-internal-id="<?=htmlspecialchars($location->internal_id)?>" data-name="<?=htmlspecialchars($location->name)?>" data-filter-value="<?=htmlspecialchars($filter)?>">
|
|
|
- <div class="row no-gutters">
|
|
|
- <div class="col-2 text-right">
|
|
|
- <?=$location->id?>
|
|
|
- </div>
|
|
|
- <div class="col hover-container px-3">
|
|
|
- <a href="/account/locations/<?=$location->id?>" target="_blank"><?=htmlspecialchars($location->name)?></a>
|
|
|
- <a class="visible-on-hover float-right" href="/account/locations/<?=$location->id?>/edit" target="_blank"><i class="fal fa-pencil"></i> Edit</a>
|
|
|
- <?php
|
|
|
- if($location->internal_id) {
|
|
|
- ?>
|
|
|
- <br />
|
|
|
- <small class="text-primary">Internal ID: <?=htmlspecialchars($location->internal_id)?></small>
|
|
|
- <?php
|
|
|
- }
|
|
|
- ?>
|
|
|
- <br />
|
|
|
- <small><?=htmlspecialchars($address)?></small>
|
|
|
- </div>
|
|
|
- <div class="col-auto align-self-center text-right">
|
|
|
- <button class="btn btn-outline-success" type="button">
|
|
|
- <i class="fas fa-check"></i>
|
|
|
- <span class="sr-only">Select</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
<?php
|
|
|
- }
|
|
|
- ?>
|
|
|
+ $output_locations($deselected_locations, false);
|
|
|
+ ?>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|