.
This commit is contained in:
@@ -6,8 +6,8 @@ Object.defineProperties(Array.prototype, {
|
||||
Uses the javascript == notion of equality.
|
||||
*/
|
||||
var count = 0;
|
||||
for(let i = 0; i < this.length; i++)
|
||||
if(this[i] == query)
|
||||
for (let i = 0; i < this.length; i++)
|
||||
if (this[i] == query)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ 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; }
|
||||
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; }
|
||||
}
|
||||
|
||||
shift_counts = {};
|
||||
@@ -67,15 +67,14 @@ function generateExtra() {
|
||||
total_shifts = total_shifts + shifts.count(el);
|
||||
|
||||
// why like this?
|
||||
if(el == "night_weekend") {
|
||||
if (el == "night_weekend") {
|
||||
whole_weekends_worked = whole_weekends_worked - shifts.count(el) / 3
|
||||
}
|
||||
|
||||
if($("#global-settings").length == 1) {
|
||||
if ($("#global-settings").length == 1) {
|
||||
|
||||
n = $(`#${el}-tdl`).val();
|
||||
// console.log("SHIT", `${el}-tdl`, n)
|
||||
if(!isNaN(n)) {
|
||||
if (!isNaN(n)) {
|
||||
days_lost = days_lost + shifts.count(el) * n;
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ function generateExtra() {
|
||||
|
||||
console.log(nwds);
|
||||
|
||||
if(nwds != "None") {
|
||||
if (nwds != "None") {
|
||||
nwds.split(", ").forEach((nwd) => {
|
||||
console.log(worker, nwd, shift_tds);
|
||||
$(shift_tds).filter(`.${nwd}`).addClass("nwd");
|
||||
@@ -130,74 +129,80 @@ function generateExtra() {
|
||||
|
||||
sc = JSON.stringify(shift_counts);
|
||||
|
||||
worker_td.after(`<div class='worker-summary auto-generated'><span>Total shifts: ${total_shifts}, </span><span>Weekends: ${weekends_worked}, </span></div>`)
|
||||
|
||||
})
|
||||
bank_holidays = shift_tds.filter(".bank-holiday").filter(function (i) {
|
||||
return $(this).attr('data-shift') != "";
|
||||
});
|
||||
console.log("BH", bank_holidays.length)
|
||||
|
||||
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] = {};
|
||||
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>`)
|
||||
|
||||
})
|
||||
|
||||
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(!(w.site in sites_days_lost)) {
|
||||
sites_days_lost[w.site] = [w.days_lost];
|
||||
|
||||
if (!(shift in sites[w.site])) {
|
||||
sites[w.site][shift] = [w.shift_counts[shift]];
|
||||
} else {
|
||||
sites_days_lost[w.site].push(w.days_lost);
|
||||
sites[w.site][shift].push(w.shift_counts[shift]);
|
||||
}
|
||||
}
|
||||
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>`);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
// 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();
|
||||
|
||||
});
|
||||
return global_shifts
|
||||
|
||||
|
||||
$(table).before(summary_button);
|
||||
|
||||
|
||||
|
||||
});
|
||||
return global_shifts
|
||||
}
|
||||
|
||||
shifts = generateExtra();
|
||||
|
||||
oshifts = Array.from(shifts).sort()
|
||||
|
||||
console.log(shifts)
|
||||
|
||||
$("body").append("<div><table class='tsummary'></table></div>")
|
||||
|
||||
$("table.tsummary").append("<tr class='header'></tr>");
|
||||
@@ -217,7 +222,6 @@ oshifts.forEach((s) => {
|
||||
|
||||
$(".table-div .worker-row .worker").each((n, tr) => {
|
||||
//worker_td = $(tr).find("td").first();
|
||||
console.log(tr);
|
||||
jtr = $(tr);
|
||||
row = $("<tr></tr>");
|
||||
row.append(`<td>${jtr.data("worker")}</td>`)
|
||||
@@ -225,14 +229,12 @@ $(".table-div .worker-row .worker").each((n, tr) => {
|
||||
row.append(`<td>${jtr.data("fte")}</td>`)
|
||||
row.append(`<td>${parseFloat(jtr.data("fte_adj")).toFixed(2)}</td>`)
|
||||
|
||||
console.log(jtr.data("shift-counts"))
|
||||
shift_counts = jtr.data("shift-counts")
|
||||
shift_targets = jtr.data("worker-targets")
|
||||
|
||||
oshifts.forEach((s) => {
|
||||
console.log(s)
|
||||
if(s in shift_targets && shift_targets[s] > 0) {
|
||||
if(s in shift_counts) {
|
||||
if (s in shift_targets && shift_targets[s] > 0) {
|
||||
if (s in shift_counts) {
|
||||
c = shift_counts[s];
|
||||
} else {
|
||||
c = 0;
|
||||
@@ -243,7 +245,6 @@ $(".table-div .worker-row .worker").each((n, tr) => {
|
||||
row.append(`<td>-</td>`)
|
||||
}
|
||||
})
|
||||
console.log(shift_counts);
|
||||
|
||||
$("table.tsummary").append(row)
|
||||
})
|
||||
@@ -284,4 +285,25 @@ $(".table-div + pre").each((n, pre) => {
|
||||
$(pre).toggle();
|
||||
}));
|
||||
|
||||
})
|
||||
|
||||
$("td").hover((e) => {
|
||||
//start hover
|
||||
pair = $(e.target).closest('tr').find('td:first')[0].dataset.pair;
|
||||
index = $(e.target).index() - 1;
|
||||
if (pair > 0) {
|
||||
$(`td[data-pair=${pair}]`).each((n, el) => {
|
||||
$($(el).closest('tr').find('td').get(index)).addClass("pair-match")
|
||||
})
|
||||
}
|
||||
if (e.target.dataset.shift != undefined && e.target.dataset.shift.length > 0) {
|
||||
$(`td[data-shift=${e.target.dataset.shift}]`).addClass("shift-highlight")
|
||||
}
|
||||
|
||||
}, (e) => {
|
||||
|
||||
//end hover
|
||||
$("td.pair-match").removeClass("pair-match")
|
||||
$("td.shift-highlight").removeClass("shift-highlight")
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user