<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
	"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
    <title></title>
    <style type="text/css">
        <!--/* <![CDATA[ */
            table { border-collapse: collapse; margin-left: 1em }
            td,th { border: solid 1px #00f; padding: 2px; font-size: small; }
            th { background: #c0c0c0 }
            /* .monospace { font-family: monospace } */
            p.empty { margin-left: 1em; }
        /* ]]> */-->
    </style>
</head>

[% headers = [ 'LastName' 'FirstName' 'DoB' 'NHSNumber' 'UnitNumber' 'Source'
    'Referrer' 'Department' 'Date' ] %]

[% BLOCK results %]
    <table>
        <tr>
            [% FOREACH h IN headers %]
                <th>[% h %]</th>
            [% END %]
        </tr>
        [% FOREACH req IN data %]
        <tr>
            <td>[% req.last_name.upper %]</td>
            <td>[% req.first_name.ucfirst %]</td>
            <td>[% req.dob.dmy %]</td>
            <td>[% req.nhs_number %]</td>
            <td>[% req.unit_number %]</td>
            <td>[% req.location %]</td>
            <td>[% req.referrer %]</td>
            <td>[% req.department %]</td>
            <td align="right">
                [% IF action == 'authorised';
                    req.authorised.day_abbr _ ' ' _ req.authorised.dmy;
                   ELSE;
                    req.registered.day_abbr _ ' ' _ req.registered.dmy;
                   END;
                %]
        </tr>
        [% END %]
    </table>
[% END %]

    <body>
        <h4>REQUESTS REGISTERED [[% registered.size || 0 %]]</h4>
        [% IF registered.size;
                action = 'registered';
                data   = registered;
                PROCESS results;
            ELSE %]
            <p class="empty">No requests registered during previous week</p>
        [% END %]

        <h4>REPORTS AUTHORISED [[% authorised.size || 0 %]]</h4>
        [% IF authorised.size;
            action = 'authorised';
            data   = authorised;
            PROCESS results;
            ELSE %]
            <p class="empty">No reports authorised during previous week</p>
        [% END %]
    </body>
</html>
