Refactor timesheet logic, add initial/basic schedule view
Clearly need to be able to filter by store/department yet.
This commit is contained in:
parent
34482892f7
commit
b718336ac2
11 changed files with 449 additions and 243 deletions
111
tailbone/templates/shifts/base.mako
Normal file
111
tailbone/templates/shifts/base.mako
Normal file
|
@ -0,0 +1,111 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="head_tags()">
|
||||
${parent.head_tags()}
|
||||
${h.stylesheet_link(request.static_url('tailbone:static/css/timesheet.css'))}
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
|
||||
$('.week-picker #date').datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
showButtonPanel: true,
|
||||
onSelect: function(dateText, inst) {
|
||||
$(this).focus().select();
|
||||
}
|
||||
});
|
||||
|
||||
$('.week-picker form').submit(function() {
|
||||
location.href = '?date=' + $('.week-picker #date').val();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="timesheet(employees, employee_column=True)">
|
||||
<style type="text/css">
|
||||
.timesheet thead th {
|
||||
width: ${'{:0.2f}'.format(100.0 / float(9 if employee_column else 8))}%;
|
||||
}
|
||||
</style>
|
||||
<div class="timesheet-header">
|
||||
|
||||
## <div class="field-wrapper employee">
|
||||
## <label>Employee</label>
|
||||
## <div class="field">
|
||||
## ${employee}
|
||||
## </div>
|
||||
## </div>
|
||||
|
||||
<div class="field-wrapper week">
|
||||
<label>Week of</label>
|
||||
<div class="field">
|
||||
${week_of}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="week-picker">
|
||||
${h.form(request.current_route_url())}
|
||||
${h.link_to(u"« Previous", '?date=' + prev_sunday.strftime('%Y-%m-%d'), class_='button')}
|
||||
${h.link_to(u"Next »", '?date=' + next_sunday.strftime('%Y-%m-%d'), class_='button')}
|
||||
<label>Jump to week:</label>
|
||||
${h.text('date', value=sunday.strftime('%Y-%m-%d'))}
|
||||
${h.submit('go', "Go")}
|
||||
${h.end_form()}
|
||||
</div>
|
||||
|
||||
</div><!-- timesheet-header -->
|
||||
|
||||
<table class="timesheet">
|
||||
<thead>
|
||||
<tr>
|
||||
% if employee_column:
|
||||
<th>Employee</th>
|
||||
% endif
|
||||
% for day in weekdays:
|
||||
<th>${day.strftime('%A')}<br />${day.strftime('%b %d')}</th>
|
||||
% endfor
|
||||
<th>Total<br />Hours</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
% for employee in sorted(employees, key=unicode):
|
||||
<tr>
|
||||
% if employee_column:
|
||||
<td class="employee">${employee}</td>
|
||||
% endif
|
||||
% for day in employee.weekdays:
|
||||
<td>
|
||||
% for shift in day['shifts']:
|
||||
<p class="shift">${shift.get_display(request.rattail_config)}</p>
|
||||
% endfor
|
||||
</td>
|
||||
% endfor
|
||||
<td>${employee.hours_display}</td>
|
||||
</tr>
|
||||
% endfor
|
||||
% if employee_column:
|
||||
<tr class="total">
|
||||
<td class="employee">${len(employees)} employees</td>
|
||||
% for day in weekdays:
|
||||
<td></td>
|
||||
% endfor
|
||||
<td></td>
|
||||
</tr>
|
||||
% else:
|
||||
<tr>
|
||||
% for day in employee.weekdays:
|
||||
<td>${day['hours_display']}</td>
|
||||
% endfor
|
||||
<td>${employee.hours_display}</td>
|
||||
</tr>
|
||||
% endif
|
||||
</tbody>
|
||||
</table>
|
||||
</%def>
|
6
tailbone/templates/shifts/schedule.mako
Normal file
6
tailbone/templates/shifts/schedule.mako
Normal file
|
@ -0,0 +1,6 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/shifts/base.mako" />
|
||||
|
||||
<%def name="title()">Schedule: ${sunday}</%def>
|
||||
|
||||
${self.timesheet(employees)}
|
6
tailbone/templates/shifts/timesheet.mako
Normal file
6
tailbone/templates/shifts/timesheet.mako
Normal file
|
@ -0,0 +1,6 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/shifts/base.mako" />
|
||||
|
||||
<%def name="title()">Time Sheet: ${sunday}</%def>
|
||||
|
||||
${self.timesheet(employees, employee_column=False)}
|
|
@ -1,120 +0,0 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="title()">Time Sheet</%def>
|
||||
|
||||
<%def name="head_tags()">
|
||||
${parent.head_tags()}
|
||||
<style type="text/css">
|
||||
.timesheet-header {
|
||||
position: relative;
|
||||
}
|
||||
.timesheet-header .week-picker {
|
||||
bottom: 0.5em;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
}
|
||||
.timesheet-header .week-picker label {
|
||||
margin-left: 1em;
|
||||
}
|
||||
.timesheet {
|
||||
border-bottom: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
width: 100%;
|
||||
}
|
||||
.timesheet thead th {
|
||||
width: 12.5%;
|
||||
}
|
||||
.timesheet thead th,
|
||||
.timesheet tbody td {
|
||||
border-left: 1px solid black;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
.timesheet tbody td {
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.timesheet tbody p.shift {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
|
||||
$('.week-picker #date').datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
showButtonPanel: true,
|
||||
onSelect: function(dateText, inst) {
|
||||
$(this).focus().select();
|
||||
}
|
||||
});
|
||||
|
||||
$('.week-picker form').submit(function() {
|
||||
location.href = '${url('timesheet')}?date=' + $('.week-picker #date').val();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<div class="timesheet-header">
|
||||
|
||||
<div class="field-wrapper employee">
|
||||
<label>Employee</label>
|
||||
<div class="field">
|
||||
${employee}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper week">
|
||||
<label>Week of</label>
|
||||
<div class="field">
|
||||
${week_of}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="week-picker">
|
||||
${h.form(url('timesheet'))}
|
||||
${h.link_to(u"« Previous", '?date=' + prev_sunday.strftime('%Y-%m-%d'), class_='button')}
|
||||
${h.link_to(u"Next »", '?date=' + next_sunday.strftime('%Y-%m-%d'), class_='button')}
|
||||
<label>Jump to week:</label>
|
||||
${h.text('date', value=sunday.strftime('%Y-%m-%d'))}
|
||||
${h.submit('go', "Go")}
|
||||
${h.end_form()}
|
||||
</div>
|
||||
|
||||
</div><!-- timesheet-header -->
|
||||
|
||||
<table class="timesheet">
|
||||
<thead>
|
||||
<tr>
|
||||
% for day in weekdays:
|
||||
<th>${day.strftime('%A')}<br />${day.strftime('%b %d')}</th>
|
||||
% endfor
|
||||
<th>Total<br />Hours</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
% for day in employee.weekdays:
|
||||
<td>
|
||||
% for shift in day['shifts']:
|
||||
<p class="shift">${shift.get_display(request.rattail_config)}</p>
|
||||
% endfor
|
||||
</td>
|
||||
% endfor
|
||||
<td>${employee.hours_display}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
% for day in employee.weekdays:
|
||||
<td>${day['hours_display']}</td>
|
||||
% endfor
|
||||
<td>${employee.hours_display}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
Loading…
Add table
Add a link
Reference in a new issue