Add support for extra column(s) in timesheet view table

This commit is contained in:
Lance Edgar 2018-01-25 17:02:53 -06:00
parent b2b3a633d0
commit 1453d33123
3 changed files with 14 additions and 3 deletions

View file

@ -30,7 +30,7 @@ import datetime
from decimal import Decimal
from rattail.time import localtime, make_utc
from rattail.util import pretty_quantity
from rattail.util import pretty_quantity, pretty_hours
from webhelpers2.html import *
from webhelpers2.html.tags import *

View file

@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
import six
import json
import datetime
import rattail
from rattail.db import model
@ -84,6 +85,7 @@ def before_render(event):
renderer_globals['enum'] = request.rattail_config.get_enum()
renderer_globals['six'] = six
renderer_globals['json'] = json
renderer_globals['datetime'] = datetime
def add_inbox_count(event):

View file

@ -218,10 +218,10 @@
</div><!-- timesheet-wrapper -->
</%def>
<%def name="timesheet(render_day=None)">
<%def name="timesheet(render_day=None, extra_columns=0)">
<style type="text/css">
.timesheet thead th {
width: ${'{:0.2f}'.format(100.0 / 9)}%;
width: ${'{:0.2f}'.format(100.0 / (9 + extra_columns))}%;
}
</style>
@ -233,6 +233,7 @@
<th>${day.strftime('%A')}<br />${day.strftime('%b %d')}</th>
% endfor
<th>Total<br />Hours</th>
${self.render_extra_headers()}
</tr>
</thead>
<tbody>
@ -254,6 +255,7 @@
<td class="total">
${self.render_employee_total(emp)}
</td>
${self.render_extra_cells(employee)}
</tr>
% endfor
% if employee is Undefined:
@ -275,6 +277,7 @@
<td>
${self.render_employee_total(employee)}
</td>
${self.render_extra_totals(employee)}
</tr>
% endif
</tbody>
@ -291,5 +294,11 @@
<%def name="render_employee_day_total(day)"></%def>
<%def name="render_extra_headers()"></%def>
<%def name="render_extra_cells(employee)"></%def>
<%def name="render_extra_totals(employee)"></%def>
${self.timesheet_wrapper()}