[% # INCLUDE dumper.tt dump = data.packs;
USE today = DateTime(today = 1); # INCLUDE dumper.tt dump = today;
%]
<p>
[% data.packs.size %] most recent pack[% 's' IF data.packs.size > 1; %]:
</p>
<table class="table table-striped table-condensed table-hover">
<tr>
<th>Pack</th>
<th>Received</th>
<th>Lab number</th>
<th>Action</th>
<th>Pack sent</th>
</tr>
[% FOREACH entry IN data.packs.reverse; # because data collected in reverse order
NEXT IF entry.option.match('dead'); # oops
%]
<tr class="[% loop.last ? 'text-success bold' : 'normal' %]">
<td>#[% loop.count %]</td>
<td>[% entry.registered.strftime('%d.%b.%Y') %]</td>
<td>[% entry.request_number %]/[% use String(entry.year - 2000);
String.format('%02d') %]</td>
<td>
[%
IF entry.option.match('month'); 'next pack ';
UNLESS entry.label.match('immediate'); 'in '; END;
END;
entry.outcome;
%]
</td>
<td>
[% # INCLUDE dumper.tt name = loop.count dump = entry.pack_due >= date;
IF entry.option.match('clinic_return'); '[not required]';
ELSIF entry.pack_due AND entry.pack_due >= today;
'[ due '; entry.pack_due.strftime('%d.%b.%Y'); ' ]';
ELSIF entry.pack_sent;
entry.pack_sent.strftime('%d.%b.%Y');
END;
%]
</td>
</tr>
[% END %]
</table>