I am using Free Marker for an Netsuite custom form. I am attempting to iterate through each item in the record object and create a row for the respective entry.
I have separated the entries out by Billing Class, the works just fine. But the page break logic is not working as excepted. The page is NOT breaking from the <pbr></pbr>
tag.
Here is the code for this section
<table style="width: 100%; border: 0px;">
<tr>
<td align="center">
<p><strong style="font-size: 10;">foo bar, LLC</strong></p>
<p><strong style="font-size: 12;">Time by Job Detail</strong></p>
<p><strong style="font-size: 12;">${record.job}</strong></p>
<hr class="thick-hr" />
<table>
<tr>
<td class="underline-container"><span class="underline">Date</span></td>
<td class="underline-container"><span class="underline">Name</span></td>
<td class="underline-container"><span class="underline">Billing Status</span></td>
<td class="underline-container"><span class="underline">Duration</span></td>
</tr>
<!-- Grouping by Billing Class -->
<#assign billingClasses = [] />
<!-- Get distinct billing classes -->
<#list record.item as timeEntry>
<#if !billingClasses?seq_contains(timeEntry.item)>
<#assign billingClasses += [timeEntry.item] />
</#if>
</#list>
<#assign rowsPerPage = 30 />
<#assign rowCount = 0 />
<#assign totalDuration = 0 />
<!-- Iterate through each billing class -->
<#list billingClasses as billingClass>
<tr>
<td colspan="4" style="font-weight: bold; text-align: left;">${billingClass}</td>
</tr>
<!-- Iterate through items that belong to the current billing class -->
<#list record.item?filter(it -> it.item == billingClass) as timeEntry>
<#if rowCount != rowsPerPage>
<tr>
<td>${timeEntry.billeddate}</td>
<td>${timeEntry.employeefullname}</td>
<td>${timeEntry.item}</td>
<td>${timeEntry.quantity}</td>
</tr>
<#assign totalDuration += timeEntry.quantity />
<#assign rowCount = rowCount + 1 />
<#else>
<!-- Page Break when reaching the rowsPerPage limit -->
</table><pbr></pbr><table>
<tr>
<td colspan="4" style="font-weight: bold; text-align: left;">${billingClass}</td>
</tr>
<tr>
<td>${timeEntry.billeddate}</td>
<td>${timeEntry.employeefullname}</td>
<td>${timeEntry.item}</td>
<td>${timeEntry.quantity}</td>
</tr>
<#assign totalDuration += timeEntry.quantity />
<#assign rowCount = 1 /> <!-- Reset rowCount after page break -->
</#if>
</#list>
</#list>
<tr>
<td> </td>
<td> </td>
<td style="text-align: right; font-weight: bold;">Total:</td>
<td style="font-weight: bold;">${totalDuration}</td>
</tr>
</table>
</td>
</tr>
</table>
Any guidance is appreciated!
I am trying to create a page break after a certain number of rows is reached in Free Marker.
I ended up breaking the tables out so they were no longer nested. This seemed to have fixed the issue.
<!-- First Table: Header Information -->
<table style="width: 100%; border: 0px;">
<tr>
<td align="center">
<p><strong style="font-size: 10;">foo bar, LLC</strong></p>
<p><strong style="font-size: 12;">Time by Job Detail</strong></p>
<p><strong style="font-size: 12;">${record.job}</strong></p>
<hr class="thick-hr" />
</td>
</tr>
</table>
<!-- Second Table: Data Rows -->
<table align="center">
<tr>
<td class="underline-container"><span class="underline">Date</span></td>
<td class="underline-container"><span class="underline">Name</span></td>
<td class="underline-container"><span class="underline">Billing Status</span></td>
<td class="underline-container"><span class="underline">Duration</span></td>
</tr>
<!-- Grouping by Billing Class -->
<#assign billingClasses = [] />
<!-- Get distinct billing classes -->
<#list record.item as timeEntry>
<#if !billingClasses?seq_contains(timeEntry.item)>
<#assign billingClasses += [timeEntry.item] />
</#if>
</#list>
<#assign totalDuration = 0 />
<!-- Iterate through each billing class -->
<#list billingClasses as billingClass>
<tr>
<td colspan="4" style="font-weight: bold; text-align: left;">${billingClass}</td>
</tr>
<!-- Iterate through items that belong to the current billing class -->
<#list record.item?filter(it -> it.item == billingClass) as timeEntry>
<tr>
<td>${timeEntry.billeddate}</td>
<td>${timeEntry.employeefullname}</td>
<td>${timeEntry.item}</td>
<td>${timeEntry.quantity}</td>
</tr>
<#assign totalDuration += timeEntry.quantity />
</#list>
</#list>
<tr>
<td> </td>
<td> </td>
<td style="text-align: right; font-weight: bold;">Total:</td>
<td style="font-weight: bold;">${totalDuration}</td>
</tr>
</table>