A non-profit organization that works with foster care sponsored this report so they could generate a mail merge spreadsheet to copy into excel or google sheets. The greeting combines the first names of adults in the household unless that adult has a custom communication tab 'No Mail' field set to Yes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{{ helpers.bootstrap_3 }}
<style>
table { border-collapse: collapse; margin-top: 20px; }
table th { background-color: white; font-weight: bold; text-align: left; padding: 10px; border:solid 1px #999; }
table tr td { border-bottom:solid 1px #999; padding: 10px; vertical-align: top; }
table tr td.person { background-color: #000; color: white }
table tr td.name { background-color: white; border-right:solid 1px #999; border-left:solid 1px #999; }
table tr td.inner { border-right:solid 1px #bbb; }
table tr td.last {border-right:solid 1px #999; }
</style>
</head>
<body>
<div class="container">
<h1>
{{ filter.name }}
</h1>
<table>
<thead>
<tr>
<th>Greeting</th>
<th>Last Name</th>
<th>Adress Line 1</th>
<th>Adress Line 2</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>
</thead>
{% for person in people %}
{% if person.primary_contacts == empty %}
<tr>
<td class="name">{{person.first_name}}</td>
<td class="inner">{{ person.last_name }}</td>
<td class="inner">{{ person.primary_address.street_line_1 }}</td>
<td class="inner">{{ person.primary_address.street_line_2 }}</td>
<td class="inner">{{ person.primary_address.city }}</td>
<td class="inner">{{ person.primary_address.state }}</td>
<td class="last">{{ person.primary_address.zip}}</td>
</tr>
{% else %}<tr>
<td class="name">
{% for household in person.households %}
{% assign greeting = '' %}
{% assign names = '' %}
{% assign count = 0 %} <!-- Initialize a counter variable -->
{% for adult in household.adults %}
{% if adult.custom_tabs.communication.no_mail.value != 'true' %}
{% assign count = count | plus: 1 %} <!-- Increment the counter -->
{% if count > 1 and count == household.adults.size %}
<!-- Add ' and ' before the last name -->
{% assign names = names | append: ' & ' %}
{% elsif count > 1 %}
<!-- Add ', ' between names -->
{% assign names = names | append: ' & ' %}
{% endif %}
{% assign names = names | append: adult.first_name %}
{% endif %}
{% endfor %}
{{ names }}
</td>
<td class="inner">{{ person.last_name }}</td>
<td class="inner">{{ person.primary_address.street_line_1 }}</td>
<td class="inner">{{ person.primary_address.street_line_2 }}</td>
<td class="inner">{{ person.primary_address.city }}</td>
<td class="inner">{{ person.primary_address.state }}</td>
<td class="last">{{ person.primary_address.zip}}</td>
{% endfor %}
{% endif %}
</tr>
{% endfor %}
</table>
</div>
</body>
</html>