Household Directory - Dynamic Names
Imports: 5

This is for creation of a printed directory to distribute to congregants. It does a few things: Groups and alphabetizes by Household, with primary address and home phone in left column. Adults print in center column with their mobile phone and email address, and Children and right column. When Household adults have different last names, it lists both last names in the left column, otherwise it just prints a single last name. Left column also includes an "other" address, for 'Snowbirds' or others with multiple addresses Left column also includes a "church mailbox #" which is custom field we created for an on-site pigeonhole mailbox system we have for distributing communications Lastly, this report designates those with "Participating Member" membership type by putting a * next to the first name. Credit to many of you - for the patchwork of other recipes I built upon, and to Ron for resolving a few issues for me.

Preview

Report Preview


  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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<!--
This report dynamically generates directory listings based on the results from a list.
Only the names of people on the list will be included on the directory. If
both members of a married couple are included on the list, they will print as
either "Smith" or "Smith, Doe," based on whether they share
the same last name. If two unmarried adults (who are members of the same
household) are included, they will show as "Smith, Doe." In all cases,
the primary contact will be listed first, and all names will include a prefix (if
set). If only children in a household are included, the household name will be
printed instead.

Updated 1/24/2025 to sort by household primary contact
-->
<html>
<head>
    <title>Directory</title>
    <style>

        @page {
            margin: 0in;

        }

        .avatar {
            width: 30px;
            height: 30px;
            border-radius: 50px 50px 50px 50px;
            padding: 0px;
        }

        table {
            border-collapse: collapse;
            margin-top: 1px;
            margin-left: 0px;
            width: 100%;
        }

        table th {
            border-top: solid .5px #000;
            border-bottom: solid .5px #000;
            width: auto;
            font-family: montserrat, sans-serif;
            font-size: 14px;
            font-weight: 700;
            font-style: normal;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1.0px;
            text-align: left;
            padding: 5px;
            word-wrap: break-word;
        }

        table tr {
            break-inside: avoid-page;
        !important

        }

        table tr td {
            border-bottom: solid .5px #bfbfbf;
            padding: 5px;
            text-align: left;
            vertical-align: top;
            word-wrap: break-word;
            width: auto;
            font-size: 14px;
            font-family: arial, serif;
            font-weight: 400;
            font-style: normal;

        }

        table tr td:first-child {
            width: 30%;
        }

        table tr td:nth-child(2) {
            width: 30%;
        }

        table tr td:nth-child(3) {
            width: 30%;
        }

        table tr td:last-child {
            width: 30%;
        }

        .container {
            width: 99%;
            padding-top: 30px;
            padding-bottom: 30px;

        }


        .family_member {
            width: 120px;
            text-align: left;
            padding-right: 5px;
        }

        .family_member_name {
            text-align: Left;
            padding-top: 3px;
        }

        .tab {
            width: 49%;
            text-align: left;
            padding: 10px;
        }

        .tab-title {
            font-size: 1.3em;
            background-color: #eee;
            padding: 5px;
            border: 1px solid #eee;
        }

        .answer {
            padding: 5px;
            border: 1px solid #eee;
            border-top: 0px;

        }

        @media print {
            @page {
                size: 8.5in 11in;
                margin-top: 0.25in;
                margin-bottom: 0.25in;
                margin-left: .25in;
                margin-right: .25in;

            }

            @page {
                @bottom-center {
                    content: 'D' counter(page) ' of ' counter(pages);
                }
            }
        }


    </style>
</head>


<!--Directory Info -->

<body>
<table border="1" align="left">
    {% assign sorted_people = people | sort: 'last_name' %}

    <div class="clearfix"></div>
    <div class="container">
        <table style="width: 100%">
            <table border=0 col>

                <thead>
                <tr>
                    <th>Name & Address</th>
                    <th>Contact Information</th>
                    <th>Household Children</th>
                </tr>
                </thead>


                <tbody>

                {% assign inclusionArray = '' | split: '$' %}
                {% for person in sorted_people %}
                    {% assign addArray = person.id | split: '$' %}
                    {% assign inclusionArray = inclusionArray | concat: addArray % | sort: primary_contact.last_name %}
                {% endfor %}
                {% assign sorted_households = households | sort: 'name' %}
                {% for household in sorted_households %}

                {% assign lastNameArray = '' % | split: '$' | sort: primary_contact.last_name %}
                {% assign marriedAdults = 0 %}
                {% assign includedAdults = 0 %}
                {% assign sameLast = false %}

                <!-- Count number of married adults, and total adults on the list in this household -->
                {% for person in household.adults %}
                    <!-- Convert Person ID from number to string -->
                    {% assign personID = person.id | downcase %}
                    {% if inclusionArray contains personID %}
                        {% assign includedAdults = includedAdults | plus: 1 %}
                        {% if person.marital_status == 'Married' %}
                            {% assign marriedAdults = marriedAdults | plus: 1 %}
                        {% endif %}
                        <!-- Add last names to array -->
                        {% if person.marital_status == 'Married' %}
                            {% assign addArray = person.last_name | split: '$' | sort: person.last_name %}
                            {% assign lastNameArray = lastNameArray | concat: addArray | sort: person.last_name %}
                        {% endif %}
                    {% endif %}
                {% endfor %}
                <!-- Filter for unique last names -->
                {% assign lastNameArray = lastNameArray | uniq %}


                <!-- Generate addressee string using included people -->

                {% assign nameArray = '' | split: '$' | sort: person.last_name %}
                {% assign nameString = '' | split: '$' | sort: person.last_name %}

                <!-- Children -->
                {% if includedAdults == 0 %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id == person.id %}
                            {% capture addArray %}{{ primary_contact.last_name }}{% endcapture %}
                            {% assign addArray = addArray | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id != person.id %}
                            {% capture addArray %} {{ primary_contact.last_name }}{% endcapture %}
                            {% assign addArray = addArray | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% assign nameString = household.primary_contact.last_name %}


                    <!-- Married couple, same name -->
                {% elsif lastNameArray.size == 1 marriedAdults == 2 %}
                    {% assign personID = person.id | downcase %}
                    {% if inclusionArray contains personID and household.primary_contact.id == person.id %}
                        {% capture addArray %} {{ primary_contact.last_name }}{% endcapture %}
                        {% assign addArray = addArray | split: '$' %}
                        {% assign nameArray = nameArray | concat: addArray %}
                    {% endif %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id != person.id %}
                            {% capture addArray %} {{ primary_contact.last_name }}{% endcapture %}
                            {% assign addArray = addArray | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% assign nameString = household.primary_contact.last_name %}

                    <!-- Adult couple, different names -->
                {% elsif lastNameArray.size > 1 marriedAdults < 3 %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id == person.id %}
                            {% capture addArray %} {{ person.last_name }}{% endcapture %}
                            {% assign addArray = addArray | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id != person.id %}
                            {% capture addArray %} {{ person.last_name }}{% endcapture %}
                            {% assign addArray =  person.last_name | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                        {% assign nameString = nameArray | join: ', ' | sort: person.last_name %}
                    {% endfor %}

                    <!-- Single adults -->
                {% elsif marriedAdults < 2 %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id == person.id %}
                            {% capture addArray %} {{ person.last_name }}{% endcapture %}
                            {% assign addArray = addArray | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% for person in household.adults %}
                        {% assign personID = person.id | downcase %}
                        {% if inclusionArray contains personID and household.primary_contact.id != person.id %}
                            {% capture addArray %} {{ person.last_name }}{% endcapture %}
                            {% assign addArray = person.name_prefix | append: person.last_name | split: '$' %}
                            {% assign nameArray = nameArray | concat: addArray %}
                        {% endif %}
                    {% endfor %}
                    {% assign nameString = nameArray | join: ', ' %}



                    <!-- All other cases -->
                {% else %}
                    {% assign nameString = household.name %}

                {% endif %}

                <!-- Prints All People -->

                <td>

                    <strong>{{ nameString }} </strong>
                    <br/>
                    {{ household.primary_address.postal_address }}<br>
                               
                  {% for phone_number in household.primary_contact.phone_numbers %}
                  			 <br>
                        {% if phone_number.location == 'Home' %} Home Phone: {{ phone_number.number }}
                            <br>{% endif %}

                    {% endfor %}
                  
                  {% for household_person in household.adults %}
                        {% if household_person.id == household.primary_contact.id %}
                 {% for address in household_person.addresses %}
                                    {% if address.location == 'Other' %}
                                        {{ address.location }}: {{ address.street_line_1 }},
                  {{ address.street_line_2 }}<br>
                    {{ address.city }}, {{ address.state }} {{ address.zip }}  <br>
                  
                                        <br>{% endif %}
                     {% endfor %}
                  {% endif %}
                                 {% endfor %}
                   
                    <br>
                    <em>Church Mailbox:</em> {{ household.primary_contact.church_mailbox.mailbox# }}<br>


                    <br>



                </td>
                <td>


                    {% for household_person in household.adults %}
                        {% if household_person.id == household.primary_contact.id %}
                            {% unless household_person.child %}
                                {% if household_person.membership == 'Participating Member' %}
                                    <strong>*{{ household_person.first_name }} {{ household_person.last_name }}
                                        {{ household_person.name_suffix }}</strong><br>
                                {% else %}
                                    <strong>{{ household_person.first_name }} {{ household_person.last_name }}
                                        {{ household_person.name_suffix }}</strong><br>
                                {% endif %}

                                {% for phone_number in household_person.phone_numbers %}
                                    {% unless phone_number.location == 'Home' %}
                                        {{ phone_number.location }}: {{ phone_number.number }}
                                        <br>{% endunless %}{% endfor %}
                                {% for email in household_person.emails %}
                                    <em>Email:</em> {{ email.address }}<br>{% endfor %}
                                    <br>
                 
                            {% endunless %}
                        {% endif %}
                    {% endfor %}



                    {% for household_person in household.people %}
                        {% unless household_person.id == household.primary_contact.id %}
                            {% unless household_person.child %}

                                {% if household_person.membership == 'Participating Member' %}
                                    <strong>*{{ household_person.first_name }} {{ household_person.last_name }}
                                        {{ household_person.name_suffix }}</strong><br>
                                {% else %}
                                    <strong>{{ household_person.first_name }} {{ household_person.last_name }}
                                        {{ household_person.name_suffix }}</strong><br>
                                {% endif %}

                                 {% for phone_number in household_person.phone_numbers %}
                                    {% unless phone_number.location == 'Home' %}
                                        {{ phone_number.location }}: {{ phone_number.number }}
                                        <br>{% endunless %}{% endfor %}


                                {% for email in household_person.emails %}
                                    <em>Email:</em> {{ email.address }}<br>
                  

                                {% endfor %}
                            {% endunless %}
                        {% endunless %}
                    {% endfor %}
    </td>

    <td>{% for household_person in household.people %}
        {% if household_person.child %}
        {% if household_person.active %}
       

        <div class="media-left">
            {% if household_person.membership == 'Participating Member' %}
                *{{ household_person.first_name }}  {{ household_person.last_name }}
                {{ household_person.name_suffix }}<br>
            {% else %}
                {{ household_person.first_name }} {{ household_person.last_name }}
                {{ household_person.name_suffix }}<br>
            {% endif %}

            {% endif %}
           {% endif %}
          
            {% endfor %}
        </div>
    </td>

    </tr>


    {% endfor %}

    </tbody>
</table>
</table>
</div>


</body>
</html>