stage
This commit is contained in:
+59
-49
@@ -54,8 +54,12 @@ function generateExtra() {
|
||||
whole_weekends_worked = 0;
|
||||
|
||||
for (var i = 1; i <= weeks; i++) {
|
||||
if ($(tr).find(`[data-week='${i}'][data-day='Sat']`).attr("data-shift") != "" || $(tr).find(`[data-week='${i}'][data-day='Sun']`).attr("data-shift") != "") { weekends_worked = weekends_worked + 1; }
|
||||
if ($(tr).find(`[data-week='${i}'][data-day='Sat']`).attr("data-shift") != "" && $(tr).find(`[data-week='${i}'][data-day='Sun']`).attr("data-shift") != "") { whole_weekends_worked = whole_weekends_worked + 1; }
|
||||
if ($(tr).find(`[data-week='${i}'][data-day='Sat']`).attr("data-shift") != "" || $(tr).find(`[data-week='${i}'][data-day='Sun']`).attr("data-shift") != "") {
|
||||
weekends_worked = weekends_worked + 1;
|
||||
}
|
||||
if ($(tr).find(`[data-week='${i}'][data-day='Sat']`).attr("data-shift") != "" && $(tr).find(`[data-week='${i}'][data-day='Sun']`).attr("data-shift") != "") {
|
||||
whole_weekends_worked = whole_weekends_worked + 1;
|
||||
}
|
||||
}
|
||||
|
||||
shift_counts = {};
|
||||
@@ -133,73 +137,79 @@ function generateExtra() {
|
||||
bank_holidays = shift_tds.filter(".bank-holiday").filter(function (i) {
|
||||
return $(this).attr('data-shift') != "";
|
||||
});
|
||||
console.log("BH", bank_holidays.length)
|
||||
console.log("BH", bank_holidays.length)
|
||||
|
||||
bank_holidays_worked = bank_holidays.length;
|
||||
bank_holidays_worked = bank_holidays.length;
|
||||
|
||||
worker_td.after(`<div class='worker-summary auto-generated'><span>Total shifts: ${total_shifts}, </span><span>Weekends: ${weekends_worked}, </span><span>Bank holidays: ${bank_holidays_worked}, </span></div>`)
|
||||
worker_td.after(`<div class='worker-summary auto-generated'><span>Total shifts: ${total_shifts}, </span><span>Weekends: ${weekends_worked}, </span><span>Bank holidays: ${bank_holidays_worked}, </span></div>`)
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
sites = {};
|
||||
sites_days_lost = {}
|
||||
for (const worker in workers) {
|
||||
//console.log(worker, workers[worker]);
|
||||
w = workers[worker];
|
||||
if (w.fte == 100) {
|
||||
//console.log(w.shift_types);
|
||||
for (let shift of w.shift_types) {
|
||||
//console.log(shift);
|
||||
if (!(w.site in sites)) {
|
||||
sites[w.site] = {};
|
||||
sites = {};
|
||||
sites_days_lost = {}
|
||||
for (const worker in workers) {
|
||||
//console.log(worker, workers[worker]);
|
||||
w = workers[worker];
|
||||
if (w.fte == 100) {
|
||||
//console.log(w.shift_types);
|
||||
for (let shift of w.shift_types) {
|
||||
//console.log(shift);
|
||||
if (!(w.site in sites)) {
|
||||
sites[w.site] = {};
|
||||
|
||||
}
|
||||
if (!(shift in sites[w.site])) {
|
||||
sites[w.site][shift] = [w.shift_counts[shift]];
|
||||
} else {
|
||||
sites[w.site][shift].push(w.shift_counts[shift]);
|
||||
}
|
||||
}
|
||||
if (!(shift in sites[w.site])) {
|
||||
sites[w.site][shift] = [w.shift_counts[shift]];
|
||||
if (!(w.site in sites_days_lost)) {
|
||||
sites_days_lost[w.site] = [w.days_lost];
|
||||
|
||||
} else {
|
||||
sites[w.site][shift].push(w.shift_counts[shift]);
|
||||
sites_days_lost[w.site].push(w.days_lost);
|
||||
}
|
||||
}
|
||||
if (!(w.site in sites_days_lost)) {
|
||||
sites_days_lost[w.site] = [w.days_lost];
|
||||
|
||||
} else {
|
||||
sites_days_lost[w.site].push(w.days_lost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate site shift summaries
|
||||
// $(table).append("<div class='site-summary auto-generated'>Average shifts for a 100% FTE trainee</div>");
|
||||
// Calculate site shift summaries
|
||||
// $(table).append("<div class='site-summary auto-generated'>Average shifts for a 100% FTE trainee</div>");
|
||||
|
||||
// for(const site in sites) {
|
||||
// $(table).find(".site-summary").append(`<div class='site site-${site}'><span class='site-name'>${site}</span></div>`);
|
||||
// for(const site in sites) {
|
||||
// $(table).find(".site-summary").append(`<div class='site site-${site}'><span class='site-name'>${site}</span></div>`);
|
||||
|
||||
// for(const shift in sites[site]) {
|
||||
// average = mean(sites[site][shift])
|
||||
// $(table).find(`.site-${site}`).append(`<div>${shift}: ${average.toFixed(2)}</div>`);
|
||||
// }
|
||||
// for(const shift in sites[site]) {
|
||||
// average = mean(sites[site][shift])
|
||||
// $(table).find(`.site-${site}`).append(`<div>${shift}: ${average.toFixed(2)}</div>`);
|
||||
// }
|
||||
|
||||
// days_lost_avg = mean(sites_days_lost[site]);
|
||||
// $(table).find(`.site-${site}`).append(`<div class='training-days-lost'>Training days lost: ${days_lost_avg.toFixed(2)}</div>`);
|
||||
// }
|
||||
|
||||
summary_button = $("<button class='auto-generated'>Toggle Summary</button>").click(() => {
|
||||
$(table).find(".rota-day").toggleClass("hidden");
|
||||
$(table).find(".worker-summary").toggle();
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(table).before(summary_button);
|
||||
|
||||
// days_lost_avg = mean(sites_days_lost[site]);
|
||||
// $(table).find(`.site-${site}`).append(`<div class='training-days-lost'>Training days lost: ${days_lost_avg.toFixed(2)}</div>`);
|
||||
// }
|
||||
|
||||
summary_button = $("<button class='auto-generated'>Toggle Summary</button>").click(() => {
|
||||
$(table).find(".rota-day").toggleClass("hidden");
|
||||
$(table).find(".worker-summary").toggle();
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(table).before(summary_button);
|
||||
|
||||
|
||||
|
||||
});
|
||||
return global_shifts
|
||||
return global_shifts
|
||||
}
|
||||
|
||||
shifts = generateExtra();
|
||||
console.log(shifts)
|
||||
|
||||
if (shifts.size < 1) {
|
||||
shifts = $("#shifts-container").data("shifts");
|
||||
}
|
||||
console.log(shifts)
|
||||
|
||||
oshifts = Array.from(shifts).sort()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user