Skip to content

Commit

Permalink
Merge pull request #169 from vshn/fix-empl-report
Browse files Browse the repository at this point in the history
Add missing colorization to employee report
  • Loading branch information
ccremer authored Jan 16, 2023
2 parents d861351 + d794fb7 commit 742012d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 36 deletions.
5 changes: 4 additions & 1 deletion pkg/web/controller/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ func (v BaseView) FormatDailySummary(daily *timesheet.DailySummary) Values {

func (v BaseView) OvertimeClassname(duration time.Duration) string {
overtimeClassname := ""
if duration == 0 {
return overtimeClassname
}
if duration.Minutes() > 15 {
overtimeClassname = "Overtime"
}
if duration.Minutes() < 15 {
if duration.Minutes() < -15 {
overtimeClassname = "Undertime"
}
return overtimeClassname
Expand Down
4 changes: 4 additions & 0 deletions pkg/web/employeereport/employeereport_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ func (v *reportView) getValuesForReport(report timesheet.Report, previousPayslip
"WorkedHours": v.FormatDurationInHours(report.Summary.TotalWorkedTime),
"OutOfOfficeHours": v.FormatDurationInHours(report.Summary.TotalOutOfOfficeTime),
"OvertimeHours": v.FormatDurationInHours(report.Summary.TotalOvertime),
"OvertimeClassName": v.OvertimeClassname(report.Summary.TotalOvertime),
"PreviousBalance": previousBalanceCellText,
"NextBalance": nextBalanceCellText,
"NextBalanceClassName": v.OvertimeClassname(nextBalance),
"ProposedBalance": proposedBalanceCellText,
"ProposedBalanceClassName": v.OvertimeClassname(proposedBalance),
"ProposedBalanceExceedsThreshold": proposedBalance.Hours() > 75 || proposedBalance.Hours() < -75,
"OvertimeBalanceEditEnabled": nextPayslip != nil,
"OvertimeBalanceEditPreviewValue": overtimeBalanceEditPreview,
"ValidationError": validationErrorList.Error(),
Expand Down
1 change: 1 addition & 0 deletions pkg/web/overtimereport/monthlyreport_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (v *monthlyReportView) formatMonthlySummary(report timesheet.BalanceReport)
val["CurrentPayslipBalance"] = ""
if report.DefinitiveBalance != nil {
val["CurrentPayslipBalance"] = v.FormatDurationInHours(*report.DefinitiveBalance)
val["CurrentPayslipBalanceClassName"] = v.OvertimeClassname(*report.DefinitiveBalance)
}
return val
}
9 changes: 5 additions & 4 deletions templates/createreport.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<h1>This week at a glance</h1>
<style>
.Overtime {
color:#005AB5;
color: #005AB5;
}

.Undertime {
color: #DC3220;
}
Expand All @@ -36,8 +37,8 @@ <h1>This week at a glance</h1>
<tr>
<td>{{ .Weekday }}</td>
<td>{{ .LeaveType }}</td>
<td class="text-end font-monospace ">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace ">{{ .WorkedHours }}</td>
<td class="text-end font-monospace">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace">{{ .WorkedHours }}</td>
<td class="text-end font-monospace fw-bold {{ .OvertimeClassname }}">{{ .OvertimeHours }}</td>
</tr>
{{ end }}
Expand All @@ -54,7 +55,7 @@ <h1>This week at a glance</h1>
<td></td>
<td></td>
<td></td>
<td class="text-end font-monospace ">{{ .Summary.TotalWorked }}</td>
<td class="text-end font-monospace">{{ .Summary.TotalWorked }}</td>
<td class="text-end font-monospace fw-bold {{ .Summary.OvertimeClassname }}">{{ .Summary.TotalOvertime }}</td>
</tr>
{{ if .IsSignedIn }}
Expand Down
44 changes: 30 additions & 14 deletions templates/employeereport.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
top: 0;
z-index: 1;
}

.Overtime {
color: #005AB5;
}

.Undertime {
color: #DC3220;
}
@media (min-width: 2000px) {
.container {
max-width: 2000px;
}
.table {
table-layout: fixed;
}
}
</style>
<h1>Attendances for {{ .Month }} {{ .Year }}</h1>
<div id="alerts">
Expand All @@ -73,13 +89,13 @@ <h1>Attendances for {{ .Month }} {{ .Year }}</h1>
<tr class="table-secondary">
<th scope="col">Name</th>
<th scope="col">Leaves</th>
<th scope="col">Excused hours</th>
<th scope="col">Worked hours</th>
<th scope="col">(Out of office hours, real)</th>
<th scope="col">{{ .LastMonth }} Payslip</th>
<th scope="col">Overtime delta</th>
<th scope="col">Proposed balance</th>
<th scope="col">{{ .Month }} Payslip</th>
<th scope="col" class="text-end">Excused hours</th>
<th scope="col" class="text-end">Worked hours</th>
<th scope="col" class="text-end">(Out of office hours, real)</th>
<th scope="col" class="text-end">{{ .LastMonth }} Payslip</th>
<th scope="col" class="text-end">Overtime delta</th>
<th scope="col" class="text-end">Proposed balance</th>
<th scope="col" class="text-end">{{ .Month }} Payslip</th>
<th scope="col">Save in {{ .Month }} Payslip</th>
</tr>
</thead>
Expand All @@ -91,13 +107,13 @@ <h1>Attendances for {{ .Month }} {{ .Year }}</h1>
{{- with .ValidationError }}<br>⚠️ {{ . }}{{ end -}}
</td>
<td>{{ .Leaves }}d</td>
<td>{{ .ExcusedHours }}</td>
<td>{{ .WorkedHours }}</td>
<td>{{ .OutOfOfficeHours }}</td>
<td>{{ .PreviousBalance }}</td>
<td>{{ .OvertimeHours }}</td>
<td>{{ .ProposedBalance }}</td>
<td id="td-nextbalance-{{ .EmployeeID }}">{{ .NextBalance }}</td>
<td class="text-end font-monospace">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace">{{ .WorkedHours }}</td>
<td class="text-end font-monospace">{{ .OutOfOfficeHours }}</td>
<td class="text-end font-monospace">{{ .PreviousBalance }}</td>
<td class="text-end font-monospace {{ .OvertimeClassName }}">{{ .OvertimeHours }}</td>
<td class="text-end font-monospace {{ .ProposedBalanceClassName }}">{{ if .ProposedBalanceExceedsThreshold }}⚠️ {{ end }}{{ .ProposedBalance }}</td>
<td class="text-end font-monospace {{ .NextBalanceClassName }}" id="td-nextbalance-{{ .EmployeeID }}">{{ .NextBalance }}</td>
<td>
{{- if .OvertimeBalanceEditEnabled }}
<div class="mb-3">
Expand Down
13 changes: 6 additions & 7 deletions templates/overtimereport-monthly.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "main" }}
<h1>Attendance for {{ .Username }}<small class="text-muted"> {{ .MonthDisplayName }}, {{ .TimezoneDisplayName }}</small></h1>
<div class="float" id="alerts"></div>
<div >
<div>
{{ with .Error }}
<div class="alert alert-danger" role="alert">{{ . }}</div>
{{ end }}
Expand All @@ -19,13 +19,12 @@ <h1>Attendance for {{ .Username }}<small class="text-muted"> {{ .MonthDisplayNam
</p>
<style>
.Overtime {
color:#005AB5;
color: #005AB5;
}

.Undertime {
color: #DC3220;
}


</style>
<table class="table table-hover table-sm" style="">
<thead>
Expand All @@ -47,8 +46,8 @@ <h1>Attendance for {{ .Username }}<small class="text-muted"> {{ .MonthDisplayNam
<td>{{ .Workload }}%</td>
<td>{{ .LeaveType }}</td>
<td class="text-end font-monospace">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace" >{{ .WorkedHours }}</td>
<td class="text-end font-monospace fw-bold {{ .OvertimeClassname }}" >{{ .OvertimeHours }}</td>
<td class="text-end font-monospace">{{ .WorkedHours }}</td>
<td class="text-end font-monospace fw-bold {{ .OvertimeClassname }}">{{ .OvertimeHours }}</td>
</tr>
{{ end }}
</tbody>
Expand Down Expand Up @@ -87,7 +86,7 @@ <h1>Attendance for {{ .Username }}<small class="text-muted"> {{ .MonthDisplayNam
<td></td>
<td class="text-end font-monospace fw-bold {{ .Summary.PreviousBalanceClassname }}">{{ .Summary.PreviousBalance }}</td>
<td class="text-end font-monospace fw-bold {{ .Summary.NewBalanceClassname }}">{{ .Summary.NewOvertimeBalance }}</td>
<td class="text-end font-monospace ">{{ .Summary.CurrentPayslipBalance }}</td>
<td class="text-end font-monospace fw-bold {{ .Summary.CurrentPayslipBalanceClassName }}">{{ .Summary.CurrentPayslipBalance }}</td>
</tr>
</tfoot>
</table>
Expand Down
21 changes: 11 additions & 10 deletions templates/overtimereport-yearly.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ <h1>Attendance for {{ .Username }}</h1>
<a href="{{ .Nav.NextYearLink }}" class="btn btn-secondary">Next</a>
</p>
<style>
.Overtime {
color:#005AB5;
.Overtime {
color: #005AB5;
}

.Undertime {
color: #DC3220;
}
Expand All @@ -32,10 +33,10 @@ <h1>Attendance for {{ .Username }}</h1>
<tr>
<td><a href="{{ .DetailViewLink }}">{{ .Name }}</a>{{- with .ValidationError }} ⚠️{{- end }}</td>
<td>{{ .LeaveDays }}d</td>
<td class="text-end font-monospace ">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace " >{{ .WorkedHours }}</td>
<td class="text-end font-monospace {{ .OvertimeClassname }} ">{{ .OvertimeHours }}</td>
<td class="text-end font-monospace ">{{ .DefinitiveBalance }}</td>
<td class="text-end font-monospace">{{ .ExcusedHours }}</td>
<td class="text-end font-monospace">{{ .WorkedHours }}</td>
<td class="text-end font-monospace {{ .OvertimeClassname }}">{{ .OvertimeHours }}</td>
<td class="text-end font-monospace">{{ .DefinitiveBalance }}</td>
</tr>
{{ end }}
</tbody>
Expand All @@ -51,10 +52,10 @@ <h1>Attendance for {{ .Username }}</h1>
<tr>
<td></td>
<td>{{ .Summary.TotalLeaves }}d</td>
<td class="text-end font-monospace ">{{ .Summary.TotalExcused }}</td>
<td class="text-end font-monospace ">{{ .Summary.TotalWorked }}</td>
<td class="text-end font-monospace {{ .Summary.OvertimeClassname }}">{{ .Summary.TotalOvertime }}</td>
<td class="text-end font-monospace "></td>
<td class="text-end font-monospace">{{ .Summary.TotalExcused }}</td>
<td class="text-end font-monospace">{{ .Summary.TotalWorked }}</td>
<td class="text-end font-monospace {{ .Summary.OvertimeClassname }}">{{ .Summary.TotalOvertime }}</td>
<td class="text-end font-monospace"></td>
</tr>
</tfoot>
</table>
Expand Down

0 comments on commit 742012d

Please sign in to comment.