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 decimal import Decimal
from rattail.time import localtime, make_utc 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 import *
from webhelpers2.html.tags import * from webhelpers2.html.tags import *

View file

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

View file

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