diff --git a/output/timetable.js b/output/timetable.js index 9437a36..28ebb21 100644 --- a/output/timetable.js +++ b/output/timetable.js @@ -78,11 +78,11 @@ function generateExtra() { shift_counts = {}; - total_shifts = 0; + //total_shifts = 0; days_lost = 0; shifts_unique.forEach(el => { shift_counts[el] = shifts.count(el); - total_shifts = total_shifts + shifts.count(el); + //total_shifts = total_shifts + shifts.count(el); // why like this? if (el == "night_weekend") { @@ -518,6 +518,16 @@ $(".table-div .worker-row .worker").each((n, tr) => { locum_shift_counts = jtr.data("locum-shift-counts") shift_targets = jtr.data("worker-targets") + // Compute total shifts from shift_counts (sum of assigned counts) + let total_shifts = 0; + try { + if (shift_counts && typeof shift_counts === 'object') { + total_shifts = Object.values(shift_counts).reduce((a, b) => a + (parseFloat(b) || 0), 0); + } + } catch (e) { + total_shifts = 0; + } + oshifts.forEach((s) => { if (s in shift_targets && shift_targets[s] > 0) {