Skip to content

Commit

Permalink
Pass some more useful data into the timesheet template. Use it.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Jul 29, 2015
1 parent dbe934e commit 0bd6896
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions bin/timesheet
Expand Up @@ -41,9 +41,11 @@ my $t = Template->new({

$t->process(
'timesheet.tt',
{ weeks => \@weeks },
{ weeks => \@weeks,
month => $first_of_month,
contract => $contract, },
"$fname.html",
{ binmode => ':utf8' }
{ binmode => ':utf8' }
) or die $t->error;

system('wkhtmltopdf', "$fname.html", "$Bin/../timesheet/$fname.pdf");
10 changes: 5 additions & 5 deletions tt_lib/timesheet.tt
Expand Up @@ -2,17 +2,17 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf8" />
<title>Timesheet - Magnum Solutions [% weeks.0.days.0.day_date.strftime('%B %Y') %]</title>
<title>Timesheet - Magnum Solutions [% month.strftime('%B %Y') %]</title>
<link rel="stylesheet" type="text/css" href="css/timesheet.css" />
</head>

<body>
<h1>Consultant Timesheet</h1>
<table class="head">
<tr><th>Consultant Name</th><td>[% weeks.0.contract.employee.name %]</td></tr>
<tr><th>Month</th><td>[% weeks.0.days.last.day_date.strftime('%B %Y') %]</td></tr>
<tr><th>Client Reference</th><td>[% inv.cust_ref || inv.contract.cust_ref %]</td></tr>
<tr><th>Rate (hourly or daily)</th><td>£[% weeks.0.contract.rate %]/[% weeks.0.contract.rate_unit %]</td></tr>
<tr><th>Consultant Name</th><td>[% contract.employee.name %]</td></tr>
<tr><th>Month</th><td>[% month.strftime('%B %Y') %]</td></tr>
<tr><th>Client Reference</th><td>[% inv.cust_ref || contract.cust_ref || 'N/A' %]</td></tr>
<tr><th>Rate (hourly or daily)</th><td>£[% contract.rate %]/[% contract.rate_unit %]</td></tr>
</table>
[% day_names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday' ] -%]
Expand Down

0 comments on commit 0bd6896

Please sign in to comment.