    [% META title="FluidX XTR-96 Plate Reader Data Import" %]
    [% skip_wrappers = 1 # format for printing %]
<!-- BEGIN [% template.name %] -->
    [% # INCLUDE dumper.tt dump = data %]

    <h2 class="header">FluidX XTR-96 Rack Data Import Result</h2>
    [%
        requests = data.requests; # INCLUDE dumper.tt dump = requests;
        success  = data.success;  # INCLUDE dumper.tt dump = success;
    %]

    [% IF data.exists('failed'); failures = data.failed; # INCLUDE dumper.tt dump = failures; %]
        <div class="error">Failed: [% failures.size %]</div>
        [% FOREACH f IN failures %]
            <div class="indent error">[% f.key %]: [% f.value.vialId %]</div>
        [% END %]
    [% END %]

    [% # INCLUDE dumper.tt dump = data.success;
        USE format; concat = format('%s%02d');
        USE date(format = '%d.%m.%Y');
        # set table dimensions depending on vial number (48/96 wells):
        total_num = success.size + failures.size; # total_num ;
        alpha_min = 'A'; numbr_min = 1;
        alpha_max = total_num == 48 ? 'F' : 'H';
        numbr_max = total_num == 48 ?  8  :  12;

    %]
    <table>
        <tr>
            <th colspan="[% numbr_max %]">
                Plate ID: [% data.plateId %] |---===---|
                [% action %]: [% date.format %]
                [% IF data.storage_location %] |---===---|
                    storage location: [% data.storage_location %]
                [% END %]
            </th>
        </tr>
        [% FOREACH row IN [ alpha_min .. alpha_max ] %]
            <tr>
                [% FOREACH col IN [numbr_min .. numbr_max]; # INCLUDE dumper.tt dump = [row, col];
                    cell = concat(row,col);  # ie format('%s%02d')
                    class = success.${cell} ? 'xtr-96-vial' : 'grey';
                 %]
                    <td>
                        <div class="xtr-96-cell">[% cell %]</div>
                        <div class="[% class %]">
                            [% success.${cell}.vialId || data.scan_data.${cell}
                                || 'FAILED' %]
                        </div>
                        <div class="xtr-96-cell">
                            [% IF success.${cell}.vialId; # lab number:
                                  request_id = success.${cell}.request_id;
                                  request = requests.${request_id};
                                  request.request_number; '/';
                                    request.year - 2000 | format('%02d');
                                END;
                            %]
                        </div>
                    </td>
                [% END %]
            </tr>
        [% END %]
    </table>
    <p class="">[% site.html.back_button %]</p>
<!-- END [% template.name %] -->
