repeat last month option added in tue UI
This commit is contained in:
@ -60,6 +60,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
var autoFill = common.parseBool(req.query.autoFill);
|
||||
var forDay = common.parseBool(req.query.forDay);
|
||||
var type = parseInt(req.query.type) || 0;
|
||||
var repeat = common.parseBool(req.query.repeat);
|
||||
if (type == 2) {
|
||||
// var result = await GenerateOptimalSchedule(axios, date, copyFromPreviousMonth, autoFill, forDay, type);
|
||||
var result = await GenerateScheduleNew(axios, date, copyFromPreviousMonth, autoFill, forDay, type);
|
||||
@ -76,7 +77,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
originalConsoleLog.apply(console, arguments);
|
||||
};
|
||||
|
||||
var result = await GenerateSchedule(axios, date, copyFromPreviousMonth, autoFill, forDay, type);
|
||||
var result = await GenerateSchedule(axios, date, copyFromPreviousMonth, autoFill, forDay, type, undefined, repeat);
|
||||
|
||||
// Restore the original console.log
|
||||
console.log = originalConsoleLog;
|
||||
@ -183,7 +184,7 @@ function updatePublishersWithCurrentCounts(publishers) {
|
||||
}
|
||||
|
||||
|
||||
async function GenerateSchedule(axios, date, copyFromPreviousMonth = false, autoFill = false, forDay, algType = 0, until) {
|
||||
async function GenerateSchedule(axios, date, copyFromPreviousMonth = false, autoFill = false, forDay, algType = 0, until, doRepeatLast = true) {
|
||||
|
||||
let missingPublishers = [];
|
||||
let publishersWithChangedPref = [];
|
||||
@ -287,25 +288,27 @@ async function GenerateSchedule(axios, date, copyFromPreviousMonth = false, auto
|
||||
|
||||
//---------------------------------------------------
|
||||
// // COMMENT TO DISABLE COPY FROM LAST MONTH
|
||||
// if (availability && copyFromPreviousMonth && !publishersThisWeek.includes(publisher.id)) {
|
||||
// const transportCount = shiftAssignments.filter(a => a.isWithTransport).length;
|
||||
// const isWithTransport = availability.isWithTransportIn || availability.isWithTransportOut;
|
||||
if (doRepeatLast) {
|
||||
if (availability && copyFromPreviousMonth && !publishersThisWeek.includes(publisher.id)) {
|
||||
const transportCount = shiftAssignments.filter(a => a.isWithTransport).length;
|
||||
const isWithTransport = availability.isWithTransportIn || availability.isWithTransportOut;
|
||||
|
||||
// if (!isWithTransport || transportCount < 2) {
|
||||
// shiftAssignments.push({
|
||||
// publisherId: publisher.id,
|
||||
// isConfirmed: true,
|
||||
// isBySystem: true,
|
||||
// isWithTransport: isWithTransport
|
||||
// });
|
||||
// publishersThisWeek.push(publisher.id);
|
||||
// updateRegistry(publisher.id, day, weekNr);
|
||||
// publisher.currentMonthAssignments += 1;
|
||||
// }
|
||||
// else {
|
||||
// console.log(" " + publisher.firstName + " " + publisher.lastName + " skipped (transport already assigned)");
|
||||
// }
|
||||
// }
|
||||
if (!isWithTransport || transportCount < 2) {
|
||||
shiftAssignments.push({
|
||||
publisherId: publisher.id,
|
||||
isConfirmed: true,
|
||||
isBySystem: true,
|
||||
isWithTransport: isWithTransport
|
||||
});
|
||||
publishersThisWeek.push(publisher.id);
|
||||
updateRegistry(publisher.id, day, weekNr);
|
||||
publisher.currentMonthAssignments += 1;
|
||||
}
|
||||
else {
|
||||
console.log(" " + publisher.firstName + " " + publisher.lastName + " skipped (transport already assigned)");
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user