Umstellung auf h min format
This commit is contained in:
@@ -134,7 +134,7 @@ function getWeekStart(dateStr) {
|
|||||||
|
|
||||||
// Helper: Dezimalstunden in Anzeige "X h Y min" (z. B. 8.25 -> "8 h 15 min", -1.5 -> "-1 h 30 min")
|
// Helper: Dezimalstunden in Anzeige "X h Y min" (z. B. 8.25 -> "8 h 15 min", -1.5 -> "-1 h 30 min")
|
||||||
function formatHoursMin(decimalHours) {
|
function formatHoursMin(decimalHours) {
|
||||||
if (decimalHours == null || !Number.isFinite(Number(decimalHours))) return '0 h 0 min';
|
if (decimalHours == null || !Number.isFinite(Number(decimalHours))) return '0h 0min';
|
||||||
const n = Number(decimalHours);
|
const n = Number(decimalHours);
|
||||||
const sign = n < 0 ? -1 : 1;
|
const sign = n < 0 ? -1 : 1;
|
||||||
const absVal = Math.abs(n);
|
const absVal = Math.abs(n);
|
||||||
@@ -145,7 +145,7 @@ function formatHoursMin(decimalHours) {
|
|||||||
min = 0;
|
min = 0;
|
||||||
}
|
}
|
||||||
const prefix = sign < 0 ? '-' : '';
|
const prefix = sign < 0 ? '-' : '';
|
||||||
return prefix + h + ' h ' + min + ' min';
|
return prefix + h + 'h ' + min + 'min';
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Wird global als window.formatHoursMin bereitgestellt.
|
// Wird global als window.formatHoursMin bereitgestellt.
|
||||||
(function () {
|
(function () {
|
||||||
function formatHoursMin(decimalHours) {
|
function formatHoursMin(decimalHours) {
|
||||||
if (decimalHours == null || !Number.isFinite(Number(decimalHours))) return '0 h 0 min';
|
if (decimalHours == null || !Number.isFinite(Number(decimalHours))) return '0h 0min';
|
||||||
var n = Number(decimalHours);
|
var n = Number(decimalHours);
|
||||||
var sign = n < 0 ? -1 : 1;
|
var sign = n < 0 ? -1 : 1;
|
||||||
var absVal = Math.abs(n);
|
var absVal = Math.abs(n);
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
min = 0;
|
min = 0;
|
||||||
}
|
}
|
||||||
var prefix = sign < 0 ? '-' : '';
|
var prefix = sign < 0 ? '-' : '';
|
||||||
return prefix + h + ' h ' + min + ' min';
|
return prefix + h + 'h ' + min + 'min';
|
||||||
}
|
}
|
||||||
window.formatHoursMin = formatHoursMin;
|
window.formatHoursMin = formatHoursMin;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ function generatePDF(timesheetId, req, res) {
|
|||||||
// Feiertag am Wochenende: keine Tagesarbeitsstunden anzeigen
|
// Feiertag am Wochenende: keine Tagesarbeitsstunden anzeigen
|
||||||
const holidayDay = new Date(row.date + 'T12:00:00').getDay();
|
const holidayDay = new Date(row.date + 'T12:00:00').getDay();
|
||||||
const isWeekendHoliday = (holidayDay === 0 || holidayDay === 6);
|
const isWeekendHoliday = (holidayDay === 0 || holidayDay === 6);
|
||||||
const holidayHoursStr = isWeekendHoliday ? '0 h 0 min (Feiertag)' : formatHoursMin(fullDayHours) + ' (Feiertag)';
|
const holidayHoursStr = isWeekendHoliday ? '0h 0min (Feiertag)' : formatHoursMin(fullDayHours) + ' (Feiertag)';
|
||||||
const rowData = [formatDate(row.date), '-', '-', '-', holidayHoursStr];
|
const rowData = [formatDate(row.date), '-', '-', '-', holidayHoursStr];
|
||||||
rowData.forEach((data, i) => {
|
rowData.forEach((data, i) => {
|
||||||
doc.text(data, x, y, { width: colWidths[i], align: 'left' });
|
doc.text(data, x, y, { width: colWidths[i], align: 'left' });
|
||||||
@@ -462,7 +462,7 @@ function generatePDFToBuffer(timesheetId, req) {
|
|||||||
// Feiertag am Wochenende: keine Tagesarbeitsstunden anzeigen
|
// Feiertag am Wochenende: keine Tagesarbeitsstunden anzeigen
|
||||||
const holidayDay = new Date(row.date + 'T12:00:00').getDay();
|
const holidayDay = new Date(row.date + 'T12:00:00').getDay();
|
||||||
const isWeekendHoliday = (holidayDay === 0 || holidayDay === 6);
|
const isWeekendHoliday = (holidayDay === 0 || holidayDay === 6);
|
||||||
const holidayHoursStr = isWeekendHoliday ? '0 h 0 min (Feiertag)' : formatHoursMin(fullDayHoursBuf) + ' (Feiertag)';
|
const holidayHoursStr = isWeekendHoliday ? '0h 0min (Feiertag)' : formatHoursMin(fullDayHoursBuf) + ' (Feiertag)';
|
||||||
const rowDataBuf = [formatDate(row.date), '-', '-', '-', holidayHoursStr];
|
const rowDataBuf = [formatDate(row.date), '-', '-', '-', holidayHoursStr];
|
||||||
rowDataBuf.forEach((data, i) => {
|
rowDataBuf.forEach((data, i) => {
|
||||||
doc.text(data, x, y, { width: colWidths[i], align: 'left' });
|
doc.text(data, x, y, { width: colWidths[i], align: 'left' });
|
||||||
|
|||||||
@@ -52,11 +52,11 @@
|
|||||||
<div class="summary">
|
<div class="summary">
|
||||||
<div class="summary-item">
|
<div class="summary-item">
|
||||||
<strong>Gesamtstunden diese Woche:</strong>
|
<strong>Gesamtstunden diese Woche:</strong>
|
||||||
<span id="totalHours">0 h 0 min</span>
|
<span id="totalHours">0h 0min</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-item" id="overtimeSummaryItem" style="display: none;">
|
<div class="summary-item" id="overtimeSummaryItem" style="display: none;">
|
||||||
<strong>Überstunden diese Woche:</strong>
|
<strong>Überstunden diese Woche:</strong>
|
||||||
<span id="overtimeHours">0 h 0 min</span>
|
<span id="overtimeHours">0h 0min</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="employee-details" style="margin-top: 10px;">
|
<div class="employee-details" style="margin-top: 10px;">
|
||||||
<div style="display: inline-block; margin-right: 20px;">
|
<div style="display: inline-block; margin-right: 20px;">
|
||||||
<strong>Aktuelle Überstunden:</strong> <span class="current-overtime-value" data-user-id="<%= employee.user.id %>">-</span> Stunden
|
<strong>Aktuelle Überstunden:</strong> <span class="current-overtime-value" data-user-id="<%= employee.user.id %>">-</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: inline-block; margin-right: 20px;">
|
<div style="display: inline-block; margin-right: 20px;">
|
||||||
<strong>Verbleibender Urlaub:</strong> <span class="remaining-vacation-value" data-user-id="<%= employee.user.id %>">-</span> Tage
|
<strong>Verbleibender Urlaub:</strong> <span class="remaining-vacation-value" data-user-id="<%= employee.user.id %>">-</span> Tage
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
el.textContent = '-';
|
el.textContent = '-';
|
||||||
el.style.color = '';
|
el.style.color = '';
|
||||||
} else {
|
} else {
|
||||||
el.textContent = value >= 0 ? '+' + value.toFixed(2) : value.toFixed(2);
|
el.textContent = (value >= 0 ? '+' : '') + formatHoursMin(value);
|
||||||
el.style.color = value >= 0 ? '#27ae60' : '#e74c3c';
|
el.style.color = value >= 0 ? '#27ae60' : '#e74c3c';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user