App-TimeClock

 view release on metacpan or  search on metacpan

lib/App/TimeClock/Daily/HtmlPrinter.pm  view on Meta::CPAN

an embedded (css) style. A body tag will open and an h1 header with
todays day will be printed. The body and html tags will be closed in the
L</print_footer()> method.

=cut
sub print_header {
    my $self = shift;
    my $title = "Daily Report " . localtime();

    $self->_print(<< "EOD");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv='Content-Type' content='text/html;charset=utf-8'/><title>$title</title>
<style type='text/css'>
html, body { margin: 0; padding: 0; border: 0; }
body { background:#fff; color:#000; margin: 1em 0 0 1em; }
table { border-collapse: collapse; width: 80ex; }
th, td { margin:0; border:1px solid #000;padding:0.2em; }
caption { margin-top: 1em; }
tr, caption { text-align:left; }
.totals { border: 2px solid #000; background: #9cf; width: 40ex; padding: 0.5em;}

t/dailyreport-html.t  view on Meta::CPAN

    is($size, 1496, "Size of report");
    is($report[18], "<tr><th>Total Daily Hours</th><th class='N'> 8.14</th></tr>", "Total hours");
    is($report[19], "<tr><td>Afternoon                                                   </td><td class='N'> 3.05</td></tr>",
       "Afternoon hours");
}

{
    my ($size, @report) = daily_report("timelog.2days");
    is($#report, 28, "Number of lines in report");
    is($size, 1732, "Size of report");
    is($report[0], '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
       "First line");
    is($report[28], '</body></html>', "Last line");
}

done_testing();



( run in 0.512 second using v1.01-cache-2.11-cpan-49f99fa48dc )