<%
    const funeralDirectorLotOccupantType = "Funeral Director";
    const funeralDirectorOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, funeralDirectorLotOccupantType);

    const deceasedLotOccupantType = "Deceased";
    const deceasedOccupants = lotOccupancyFunctions.filterOccupantsByLotOccupantType(lotOccupancy, deceasedLotOccupantType);

    const deathDateOccupantTypeField = "Death Date";
    const deathPlaceOccupantTypeField = "Death Place";
%>
<html>
    <head>
        <style>
            <%- include('style.css'); %>
        </style>
    </head>
    <body style="margin:100px 80px">
        <p class="mb-2 has-text-centered is-capitalized">Province of Ontario</p>
        <p class="has-text-centered is-italic">Vital Statistics Act</p>
        <h1 class="has-text-centered is-capitalized mt-4 mb-4">Burial Permit</h1>

        <p>
            Under the <span class="is-italic">Vital Statistics Act</span>
            and the regulations,
            subject to the limitations thereof,
            this permit is granted to:<br />
        </p>

        <p class="has-text-centered">
            <% if (funeralDirectorOccupants.length > 0) { %>
                <% const funeralDirector = funeralDirectorOccupants[0]; %>
                <strong><%= funeralDirector.occupantName %></strong><br />
                <%= funeralDirector.occupantAddress1 %><br />
                <% if (funeralDirector.occupantAddress2) { %><%= funeralDirector.occupantAddress2 %><br /><% } %>
                <%= funeralDirector.occupantCity %>, <%= funeralDirector.occupantProvince %><br />
                <%= funeralDirector.occupantPostalCode %>
            <% } %>
        </p>

        <p class="mt-4">
            for the purpose of the burial or other disposition of the body of:
        </p>

        <p class="has-text-centered">
            <% if (deceasedOccupants.length > 0) { %>
                <% const deceased = deceasedOccupants[0]; %>
                <strong><%= deceased.occupantName %></strong>
            <% } %>
        </p>

        <p>
            who died at
            <span class="field has-text-centered" style="width:300px">
                &nbsp;
                <%= lotOccupancyFunctions.getFieldValueByOccupancyTypeField(lotOccupancy, deathPlaceOccupantTypeField); %>
                &nbsp;
            </span>
            in Ontario on
            <span class="field has-text-centered" style="width:150px">
                &nbsp;
                <%= lotOccupancyFunctions.getFieldValueByOccupancyTypeField(lotOccupancy, deathDateOccupantTypeField); %>
                &nbsp;
            </span>
            .
        </p>

        <p class="has-text-right mt-6">
            <span class="field mb-1" style="width:300px">&nbsp;</span><br />
            <span class="is-8pt">(Signature of Division Registrar)</span>
        </p>

        <p class="has-text-right">
            Sault Ste. Marie
            &nbsp;
            &nbsp;
            &nbsp;
            5724
        </p>

        <p class="has-text-right mt-4">
            <span class="field mb-1" style="width:150px">&nbsp;</span><br />
            <span class="is-8pt">(Year Month Day)</span>
        </p>
    </body>
</html>