The Goal:
Quick view of all Check-In Configuration Info
This is just an HTML block with the following code:
{% assign gtIds = '506,505' | Split:',' %}
{% for gt in gtIds %}
{% sql return:'data' %}
DECLARE @groupTypeId INT = {{ gt }}
SELECT
[Id]
, [Group]
, MAX([4pm]) AS [4pm]
--, MAX([6:15pm]) AS [6:15pm]
, MAX([9am]) AS [9am]
, MAX([11:15am]) AS [11:15am]
FROM
(
SELECT
g.[Id]
, g.[Name] AS [Group]
, CASE WHEN s.[Id] = 21903 THEN STRING_AGG(l.[Name],', ') WITHIN GROUP (ORDER BY l.[Name]) END AS [4pm]
--, CASE WHEN s.[Id] = 22074 THEN STRING_AGG(l.[Name],', ') WITHIN GROUP (ORDER BY l.[Name]) END AS [6:15pm]
, CASE WHEN s.[Id] = 6 THEN STRING_AGG(l.[Name],', ') WITHIN GROUP (ORDER BY l.[Name]) END AS [9am]
, CASE WHEN s.[Id] = 13 THEN STRING_AGG(l.[Name],', ') WITHIN GROUP (ORDER BY l.[Name]) END AS [11:15am]
FROM
[Group] g
INNER JOIN [GroupLocation] gl ON gl.[GroupId] = g.[Id]
INNER JOIN [GroupLocationSchedule] gls ON gls.[GroupLocationId] = gl.[Id]
INNER JOIN [Schedule] s ON s.[Id] = gls.[ScheduleId]
INNER JOIN [Location] l ON l.[Id] = gl.[LocationId]
WHERE
g.[GroupTypeId] = @groupTypeId
AND g.[IsActive] = 1 AND g.[IsArchived] = 0
GROUP BY
g.[Id], g.[Name], s.[Id]
) AS c
GROUP BY
[Id], [Group]
{% endsql %}
{% grouptype where:'Id == {{ gt }}' %}{% endgrouptype %}
<div class="panel panel-block">
<div class="panel-heading">
<h4 class="panel-title">{{ grouptype.Name }} <a href="/page/201?CheckinTypeId=502" target="_blank"><i style="display: initial !important;" class="fa fa-edit"></i></a></h4>
</div>
{% group where:'GroupTypeId == {{ gt }} && Touchscreen == "true" && IsActive == "true"' %}
<div class="panel-body">
<div class="grid grid-panel">
<div class="table-responsive">
<table class="grid-table table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Group</th>
<th>Grade Range</th>
<th>Age Range</th>
<th>4pm Locations</th>
{% comment %}<th>6:15pm Locations</th>{% endcomment %}
<th>9am Locations</th>
<th>11:15am Locations</th>
</tr>
</thead>
<tbody>
{% for group in groupItems %}
<tr>
<td><a href="/page/2782?GroupId={{ group.Id }}">{{ group.Name }}</a></td>
{% assign gradeRange = group | Attribute:'GradeRange' %}
{% assign ageRange = group | Attribute:'AgeRange' %}
<td>{% if gradeRange != null and gradeRange != empty %}{{ gradeRange }}{% else %} - {% endif %}</td>
<td>{% if ageRange != null and ageRange != empty %}{{ ageRange }}{% else %} - {% endif %}</td>
<td>{{ data | Where:'Id',group.Id | First | Property:'4pm' | Replace:'Preschool - Room','Room' | Replace:'Elementary - Room','Room' }}</td>
{% comment %}<td>{{ data | Where:'Id',group.Id | First | Property:'6:15pm' | Replace:'Preschool - Room','Room' | Replace:'Elementary - Room','Room' }}</td>{% endcomment %}
<td>{{ data | Where:'Id',group.Id | First | Property:'9am' | Replace:'Preschool - Room','Room' | Replace:'Elementary - Room','Room' }}</td>
<td>{{ data | Where:'Id',group.Id | First | Property:'11:15am' | Replace:'Preschool - Room','Room' | Replace:'Elementary - Room','Room' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endgroup %}
{% endfor %}
There are quite a few things in this that are specific to our church, especially the hard-coded GroupType Ids at the top and Schedule names.