<% if (allrecs.length > 0) {%>
    <table border="1">
        <tr>
            <th>Promotion ID</th>
            <th>Promotion Title</th>
            <th>Promotion Image</th>
            <th>Description</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Discount Rate</th>
        </tr>
        <% allrecs.forEach((recref, index) => { %>
            <tr>
                <td><%= recref.promotion_id %></td>
                <td><%= recref.promotitle %></td>
                <td><%= recref.promoimage %></td>
                <td><%= recref.description %></td>
                <% console.log(recref.startdate); console.log(recref.enddate); %>
                <td><%= new Date(recref.startdate).toLocaleDateString('en-US', { timeZone: 'UTC' }) %></td>
                <td><%= new Date(recref.enddate).toLocaleDateString('en-US', { timeZone: 'UTC' }) %></td>
                <td><%= recref.discountrate + "%" %></td>
                <td><a href='/promotion/<%= recref.promotion_id %>/show'>Details</a></td>
                <td><a href='/promotion/<%= recref.promotion_id%>/edit'>Edit</a></td>
                <td><a href='/promotion/<%= recref.promotion_id %>/delete' onclick="return confirm('Are you sure you want to delete this record?');">Delete</a></td>
            </tr>
        <% }); %>
    </table>
<% } else { %>
    <p>No Records Available</p>
<% } %>
<p> <a href='/promotion/addrecord'>Add New</a> </p>
    