  [% META title = 'Admin &raquo; View Cron Log' -%]

<!-- BEGIN [% template.name %] -->
    [% # PROCESS dumper.tt dump = data %]
    
    [%
        limit = c.query.param('limit') || 200;
        show_reports = c.query.param('show_reports') ? 1 : 0;
    %]
    
    [% # PROCESS dumper.tt dump = limit %]
    [% # PROCESS dumper.tt dump = show_reports %]
 
	<h2>Cron Log</h2>
   
    <form action="[% app_url %]/resources/view_cron_log" method="post"
        name="cron_log" id="cron_log">
        <p class="indent">View most recent
            <input type="text" size="2" name="limit" value="[% limit %]" />
        </p>
        <p class="indent">
            Show reports: <input type="checkbox" name="show_reports"
                value="1" [% 'checked' IF show_reports %] />
            [% site.html.submit %]
        </p>
    </form>

    [%
        USE date(format = '%Y-%m-%d', locale = 'en_GB');
        count = 0; 
    %]

    <table class="indent">
        <tr>
            <td class="borderless"></td>
            <th scope="col">Message</th>
        </tr>

        [% FOREACH entry IN data.reverse;
            NEXT IF entry.match('mail_reports.pl') AND NOT show_reports;
            LAST IF count == limit;
            count = count + 1;
            
            IF entry.match(err_flag); # highlight & delete error flag: 
                class = 'red'; entry = entry.replace(err_flag, '');
            ELSE; class = entry.match(date.format) ? 'bold' : 'normal'; END;
        %]
            <tr>
                <td>[% count %]</td>
                <td class="[% class %]">[% entry %]</td>
            </tr>
        [% END %]
    </table>
<!-- BEGIN [% template.name %] -->
