views/_organization-view_edit-licences.ejs
<div class="panel">
<div class="panel-heading">
<div class="level">
<div class="level-left">
<h2 class="has-text-weight-bold">Lottery Licences</h2>
</div>
<div class="level-right has-text-weight-normal is-hidden-print">
<div class="field is-grouped justify-flex-end">
<% if (user.userProperties.canCreate && organization.isEligibleForLicences) { %>
<div class="control">
<a class="button is-primary is-small" href="<%= urlPrefix %>/licences/new/<%= organization.organizationID %>">
<span class="icon is-small">
<i class="fas fa-certificate" aria-hidden="true"></i>
</span>
<span>Create a New Licence</span>
</a>
</div>
<% } %>
<div class="control">
<a class="button is-small" href="<%= urlPrefix %>/reports/licences-byOrganization?organizationID=<%= organization.organizationID %>" download>
<span class="icon is-small">
<i class="fas fa-file-download" aria-hidden="true"></i>
</span>
<span>Export Licences</span>
</a>
</div>
</div>
</div>
</div>
</div>
<%
let licenceTbodyHTML = "";
let rows_active = "";
let count_active = 0;
let count_past = 0;
const licenceTypes = configFunctions.getProperty("licenceTypes");
for (let licenceIndex = 0; licenceIndex < licences.length; licenceIndex += 1) {
const licence = licences[licenceIndex];
let licenceType = {};
for (let typeIndex = 0; typeIndex < licenceTypes.length; typeIndex += 1) {
if (licenceTypes[typeIndex].licenceTypeKey === licence.licenceTypeKey) {
licenceType = licenceTypes[typeIndex];
break;
}
}
let canEdit = licence.canUpdate;
let rowHTML = "<tr>" +
"<td>" +
"<a href=\"" + urlPrefix + "/licences/" + licence.licenceID + "\">" +
htmlFns.escapeHTML(licence.externalLicenceNumber) + "<br />" +
"<small>Licence #" + licence.licenceID + "</small>" +
"</a>" +
"</td>" +
"<td>" + (licenceType.licenceType || licence.licenceTypeKey) + "</td>" +
"<td class=\"has-newline-chars\">" + htmlFns.escapeHTML(licence.licenceDetails) + "</td>" +
"<td>" +
(licence.locationID
? "<a href=\"" + urlPrefix + "/locations/" + licence.locationID + "\">" +
htmlFns.escapeHTML(licence.locationDisplayName) +
"</a>" +
(licence.locationDisplayName === licence.locationAddress1 ? "" : "<br /><small>" + htmlFns.escapeHTML(licence.locationAddress1) + "</small>")
: "<span class=\"has-text-grey\">(No Location)</span>") +
"</td>" +
"<td class=\"is-nowrap\">" + licence.startDateString + "</td>" +
"<td class=\"is-nowrap\">" + licence.endDateString + "</td>" +
"<td class=\"is-nowrap has-text-right is-hidden-print\">" +
(canEdit ?
"<a class=\"button is-small\" href=\"" + urlPrefix + "/licences/" + licence.licenceID + "/edit\" data-tooltip=\"Edit Licence\"><span class=\"icon\"><i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></span><span>Edit</span></a> " :
"") +
(licence.issueDate ?
"<a class=\"button is-small\" href=\"" + urlPrefix + "/licences/" + licence.licenceID + "/print\" data-tooltip=\"Print Licence\" download>" +
"<i class=\"fas fa-print\" aria-hidden=\"true\"></i>" +
"<span class=\"sr-only\">Print Licence</span>" +
"</a>" :
"<span class=\"tag is-warning\">Unpaid</span>") +
"</td>" +
"</tr>";
licenceTbodyHTML += rowHTML;
if (licence.endDate < currentDateInteger) {
count_past += 1;
} else {
count_active += 1;
}
}
%>
<% if (licences.length === 0) { %>
<div class="panel-block is-block">
<div class="message is-info">
<div class="message-body">
<%= organization.organizationName %> has no licence records.
</div>
</div>
</div>
<% } else { %>
<table class="table is-fullwidth is-striped is-hoverable has-sticky-header">
<thead>
<tr>
<th class="has-width-150"><%= configFunctions.getProperty("licences.externalLicenceNumber.fieldLabel") %></th>
<th class="has-width-50 is-nowrap">Licence Type</th>
<th>Event Details</th>
<th>Location</th>
<th class="has-width-50">From</th>
<th class="has-width-50">To</th>
<th class="has-width-50 is-hidden-print"><span class="sr-only">Options</span></th>
</tr>
</thead>
<tbody><%- licenceTbodyHTML %></tbody>
</table>
<% } %>
</div>