cityssm/lottery-licence-manager

View on GitHub
reports/licence-print-agco.ejs

Summary

Maintainability
Test Coverage
<%
  const licenceType = configFunctions.getLicenceType(licence.licenceTypeKey);
  const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");

  let extraSpace = 40;

%><html>
<head>
  <meta charset="utf-8" />
  <style>
    /* base styles */

    * {
      box-sizing: border-box;
      font-size: 10pt;
    }

    html {
      font-family: Arial, sans-serif;
    }

    .page {
      margin: 20px 30px 0 30px;
    }

    table {
      width: 100%;
    }

    table td {
      padding: 0;
      margin: 0;
    }

    .container {
      padding: 5px 10px;
    }

    .field {
      padding: 5px 10px;
      border: 1px solid #333;
      min-height: 30px;
      width: 100%;
      background-color: #fff;
    }

    /* bulma-like styles */

    .has-padding-left-20 {
      padding-left: 20px;
    }

    .has-padding-right-10 {
      padding-right: 10px;
    }

    .has-padding-bottom-5 {
      padding-bottom: 5px;
    }

    .has-margin-top-10 {
      margin-top: 10px;
    }

    .has-margin-bottom-0 {
      margin-bottom: 0;
    }

    .has-margin-bottom-10 {
      margin-bottom: 10px;
    }


    .is-6pt {
      font-size: 6pt;
    }

    .is-9pt {
      font-size: 9pt;
    }

    .is-12pt {
      font-size: 12pt;
    }

    .is-15pt {
      font-size: 15pt;
    }

    .is-18pt {
      font-size: 18pt;
    }

    .is-21pt {
      font-size: 21pt;
    }

    .is-24pt {
      font-size: 24pt;
    }


    .has-newline-chars {
      white-space: pre-wrap;
    }

    .has-text-weight-bold {
      font-weight: bold;
    }

    .has-text-nowrap {
      white-space: nowrap;
    }

    .has-text-centered {
      text-align: center;
    }

    .has-text-right {
      text-align: right;
    }

    .has-text-red {
      color: #f33;
    }

    .is-fullwidth {
      width: 100%;
    }

    .is-half {
      width: 50%;
    }

    .is-one-sixth {
      width: 16.66%;
    }

    .is-one-third {
      width: 33.33%;
    }

    .is-two-thirds {
      width: 66.66%;
    }


    .has-vertical-align-top {
      vertical-align: top;
    }


    .has-background-blue {
      background-color: #eff;
    }


    .data-table {
      text-align: left;
    }

    .data-table th,
    .data-table td {
      padding: 2px 5px;
    }

  </style>
</head>
<body>
  <div class="page">
    <table>
      <tbody>
        <tr>
          <td class="has-padding-right-10">
            <img src="http://localhost:<%= configFunctions.getProperty("application.httpPort") %><%= urlPrefix %>/images/ontarioCoatOfArms.svg" alt="" style="height:60px" />
          </td>
          <td class="has-padding-right-10 is-9pt">
            Alcohol and<br />
            Gaming Commission<br />
            of Ontario
          </td>
          <td class="has-padding-right-10 is-9pt">
            Commission des<br />
            alcools et des jeux de<br />
            l'Ontario
          </td>
          <td class="has-padding-right-10 has-text-weight-bold" style="font-size:22pt">
            Lottery Licence<br />
            Licence de loterie
          </td>
          <td class="has-text-right">
            <span class="has-text-weight-bold is-21pt">M</span>
            <span class="has-text-red is-24pt"><%= licence.externalLicenceNumber %></span>
          </td>
        </tr>
      </tbody>
    </table>

    <div class="container has-background-blue has-margin-bottom-10">
      <div class="has-text-weight-bold">
        Licensee/Titulaire de licence<br />
        Address (no. of street, name of street, suite no., city/town, province, postal code)<br />
        Adresse (n° de rue, nom de rue, bureau, ville, province, code postal)
      </div>
      <%
        let addressMinHeight = 70;
        if (organization.organizationAddress2 !== "") {
          addressMinHeight += 20;
          extraSpace -= 20;
        }
      %>
      <div class="field" style="min-height:<%= addressMinHeight %>px">
        <%= organization.organizationName %><br />
        <%= organization.organizationAddress1 %><br />
        <%= organization.organizationAddress2 %>
        <%- (organization.organizationAddress2 === "" ? "" : "<br />") %>
        <%= organization.organizationCity %>, <%= organization.organizationProvince %> &nbsp;<%= organization.organizationPostalCode %>
      </div>
    </div>

    <div class="container has-background-blue has-margin-bottom-10">
      <table>
        <tbody>
          <tr>
            <td class="has-text-nowrap has-padding-right-10">
              Type of Lottery Scheme<br />
              Genre de loterie
            </td>
            <td class="is-fullwidth">
              <div class="field">
                <%= licenceType.licenceType || licence.licenceTypeKey  %>
              </div>
            </td>
          </tr>
          <tr>
            <td class="has-text-nowrap has-padding-right-10">
              Location/Lieu
            </td>
            <td class="is-fullwidth">
              <div class="field"><%= licence.locationDisplayName %></div>
            </td>
          </tr>
          <tr>
            <td class="has-text-nowrap has-padding-right-10">
              Municipality/Municipalité
            </td>
            <td class="is-fullwidth">
              <div class="field"><%= licence.municipality %></div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <%
      const hideTimes = licenceType && licenceType.printSettings && licenceType.printSettings.agco_hideTimes;
    %>

    <div class="container has-background-blue has-margin-bottom-10">
      <table class="is-fullwidth">
        <tbody>
          <tr>
            <td class="has-padding-right-10 is-two-thirds" <% if (!hideTimes) { %>rowspan="2"<% } %>>
              Specific date(s) of the lottery event(s) (yyyy/mm/dd)<br />
              Date(s) spécifique(s) de la loterie (aaaa/mm/jj)
            </td>
            <% if (!hideTimes) { %>
              <td class="has-text-nowrap" colspan="2">
                Specific time(s) of the lottery event(s)<br />
                Heure(s) spécifique(s) de la loterie
              </td>
            <% } %>
          </tr>
          <% if (!hideTimes) { %>
            <tr>
              <td class="is-one-sixth">From/de (HH:MM)</td>
              <td class="is-one-sixth">To/à (HH/MM)</td>
            </tr>
          <% } %>
          <tr>
            <td class="has-padding-right-10 is-two-thirds">
              <div class="field" style="min-height:80px">
                <% if (licenceType && licenceType.printSettings && licenceType.printSettings.agco_useLicenceDatesAsEventDates) { %>
                  <%= licence.startDateString.replace(/-/g, "/") %> to <%= licence.endDateString.replace(/-/g, "/") %>
                <% } else { %>
                  <% for (let eventIndex = 0; eventIndex < licence.events.length; eventIndex += 1) { %>
                    <%= (eventIndex === 0 ? "" : ", ") + licence.events[eventIndex].eventDateString.replace(/-/g, "/"); %>
                  <% } %>
                <% } %>
              </div>
            </td>
            <% if (!hideTimes) { %>
              <td class="has-vertical-align-top is-one-sixth has-padding-right-10">
                <div class="field" style="min-height:80px"><%= licence.startTimeString %></div>
              </td>
              <td class="has-vertical-align-top is-one-sixth">
                <div class="field" style="min-height:80px"><%= licence.endTimeString %></div>
              </td>
            <% } %>
          </tr>
        </tbody>
      </table>
    </div>

    <table class="has-margin-top-10 has-margin-bottom-10">
      <tbody>
        <%
          let showPrizeValue = true;
          if (licenceType && licenceType.printSettings && licenceType.printSettings.hasOwnProperty("agco_hideTotalPrizeValue") && licenceType.printSettings.agco_hideTotalPrizeValue) {
            showPrizeValue = false;
          }
        %>
        <% if (showPrizeValue) { %>
          <tr>
            <td class="has-padding-bottom-5 has-padding-right-10">
              Total value of all prizes in any lottery conducted under this<br />
              licence not to exceed $ <%= licence.totalPrizeValue.toFixed(2) %> in cash,<br />
              or merchandise or articles at equivalent market value.
            </td>
            <td class="has-padding-bottom-5">
              La valeur totale des prix d'une loterie organisée en vertu de<br />
              la présente licence ne doit pas excéder <%= licence.totalPrizeValue.toFixed(2) %> $<br />
              en espèces ou valeur équivalente en nature.
            </td>
          </tr>
        <% } %>
        <tr>
          <td class="is-half">
            The licensee must observe all terms and conditions of<br />
            this licence as agreed to in its application.<br />
            The conduct of this lottery scheme is restricted to the<br />
            dates, hours and limits specified on this licence.
          </td>
          <td>
            L'organisme autorisé doit se conformer à toutes les<br />
            modalités dont il a convenu dans la demande de<br />
            licence. On doit conduire la loterie selon les dates,<br />
            heures et limites qui y sont indiquées.
          </td>
        </tr>
      </tbody>
    </table>

    <div class="container has-background-blue has-margin-bottom-10">
      <div class="has-text-weight-bold">
        Licence Details/Détails de la licence
      </div>
      <%
        let detailsFieldMinHeight = 70;
        if ((licenceType && licenceType.printSettings && licenceType.printSettings.hasOwnProperty("agco_additionalLicenceDetailsHTMLFn")) || licenceTicketTypeSummary.length > 0) {
          detailsFieldMinHeight += extraSpace;
          extraSpace = 0;
        }
      %>
      <div class="field has-margin-bottom-10" style="min-height:<%= detailsFieldMinHeight %>px">
        <% if (licence.licenceDetails !== "") { %>
          <div class="has-newline-chars has-margin-bottom-10"><%= licence.licenceDetails %></div>
        <% } %>
        <% if (licenceType && licenceType.printSettings && licenceType.printSettings.hasOwnProperty("agco_additionalLicenceDetailsHTMLFn")) { %>
          <div class="has-margin-bottom-10">
            <%- licenceType.printSettings.agco_additionalLicenceDetailsHTMLFn(licence) %>
          </div>
        <% } %>
        <% if (licenceTicketTypeSummary.length > 0) { %>
          <table class="data-table">
            <thead>
              <tr>
                <th>Type</th>
                <th class="has-text-right">Value</th>
                <th class="has-text-right">Prizes</th>
                <th class="has-text-right">Units</th>
                <th class="has-text-right">Fee</th>
                <th>Distributor</th>
                <th>Manufacturer</th>
              </tr>
            </thead>
            <tbody>
              <% for (let index = 0; index < licenceTicketTypeSummary.length; index += 1) { %>
                <%
                const record = licenceTicketTypeSummary[index];
                const ticketTypeConfig = licenceType.ticketTypes.find(function(possibleConfig) {
                  return possibleConfig.ticketType === record.ticketType;
                });
                %>
                <tr>
                  <td class="is-9pt"><%= record.ticketType %></td>
                  <td class="is-9pt has-text-right">
                    <%= (ticketTypeConfig ? "$" + (ticketTypeConfig.ticketPrice * ticketTypeConfig.ticketCount).toFixed(2) : "") %>
                  </td>
                  <td class="is-9pt has-text-right">
                    <%= (ticketTypeConfig ? "$" + ticketTypeConfig.prizesPerDeal.toFixed(2) : "") %>
                  </td>
                  <td class="is-9pt has-text-right"><%= record.unitCountSum %></td>
                  <td class="is-9pt has-text-right">$<%= record.licenceFeeSum.toFixed(2) %></td>
                  <td class="is-9pt"><%= record.distributorLocationDisplayName %></td>
                  <td class="is-9pt"><%= record.manufacturerLocationDisplayName %></td>
                </tr>
              <% } %>
            </tbody>
          </table>
        <% } %>
      </div>
      <div class="has-text-weight-bold">
        Special Terms and Conditions/Modalités spéciales
      </div>
      <div class="field" style="min-height:<%= 70 + extraSpace %>px">
        <div class="has-newline-chars"><%= licence.termsConditions %></div>
      </div>
    </div>

    <table class="is-fullwidth">
      <tbody>
        <tr>
          <td class="is-half">
            <div class="container has-background-blue">
              Date of Issue (yyyy/mm/dd)<br />
              Date de délivrance de la licence (aaaa/mm/jj)
              <div class="field">
                <%= licence.issueDateString.replace(/-/g, "/") %>
                <%
                  let hasVisibleAmendments = false;
                  let maxVisibleAmendmentDate = "";

                  for (let index = licence.licenceAmendments.length - 1; index >= 0; index -= 1) {

                    if (!licence.licenceAmendments[index].isHidden) {
                      hasVisibleAmendments = true;
                      maxVisibleAmendmentDate = licence.licenceAmendments[index].amendmentDateString.replace(/-/g, "/");
                      break;
                    }
                  }

                  if (hasVisibleAmendments) {
                %>
                  <em class="has-padding-left-20">Amended <%= maxVisibleAmendmentDate %></em>
                <%
                  }
                %>
              </div>
            </div>
          </td>
          <td>
            <div class="container has-background-blue">
              Licence Fees<br />
              Droits - licence
              <div class="field">
                <table class="is-fullwidth">
                  <tbody>
                    <tr>
                      <td>$</td>
                      <td class="is-fullwidth"><%= licence.licenceTransactionTotal.toFixed(2) %></td>
                      <td>$</td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <td>
            Registrar of Alcohol and Gaming<br />
            Registrateur des alcools et des jeux
          </td>
          <td>
            <div class="container has-background-blue">
              Licensing Officer/Agent de délivrance des licences
              <div class="field has-min-height-50"></div>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
    <table class="is-fullwidth has-margin-bottom-0">
      <tbody>
        <tr>
          <td class="is-one-third is-6pt has-text-nowrap has-margin-bottom-0">
            6006 (2012/01) &copy; Queen's Printer for Ontario, 2012
          </td>
          <td class="is-one-third is-12pt has-text-nowrap has-text-centered has-text-weight-bold has-margin-bottom-0">
            Not Transferable/Non cessible
          </td>
          <td>&nbsp;</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>