Meeting Conflict Detection Tool

Meeting Conflict Detection Tool

Add New Meeting

Entered Meetings

  • No meetings added yet.

Input meetings on the first tab and click "Detect Conflicts & View Report".

"; mcdtOpenTab(null, 'mcdt-report'); mcdtUpdateNavButtons(); return; } let conflicts = []; // Stores pairs of conflicting meeting IDs: [[id1, id2], [id1, id3]] let meetingsInvolvedInConflict = new Set(); for (let i = 0; i < mcdtMeetings.length; i++) { for (let j = i + 1; j < mcdtMeetings.length; j++) { const m1 = mcdtMeetings[i]; const m2 = mcdtMeetings[j]; // Check for overlap: (StartA < EndB) and (EndA > StartB) if (m1.startDateTime < m2.endDateTime && m1.endDateTime > m2.startDateTime) { conflicts.push([m1.id, m2.id]); meetingsInvolvedInConflict.add(m1.id); meetingsInvolvedInConflict.add(m2.id); } } } // Group conflicts (simple graph traversal for connected components) let conflictGroups = []; let visited = new Set(); mcdtMeetings.forEach(meeting => { if (meetingsInvolvedInConflict.has(meeting.id) && !visited.has(meeting.id)) { let currentGroup = []; let queue = [meeting.id]; visited.add(meeting.id); while(queue.length > 0) { let currentMeetingId = queue.shift(); currentGroup.push(mcdtMeetings.find(m => m.id === currentMeetingId)); conflicts.forEach(pair => { let otherId = null; if (pair[0] === currentMeetingId) otherId = pair[1]; else if (pair[1] === currentMeetingId) otherId = pair[0]; if (otherId && !visited.has(otherId)) { visited.add(otherId); queue.push(otherId); } }); } if(currentGroup.length > 1) conflictGroups.push(currentGroup); } }); let reportHTML = '

Conflict Report

'; if (conflictGroups.length > 0) { reportHTML += `

${conflictGroups.length} conflict group(s) found:

`; conflictGroups.forEach((group, index) => { reportHTML += `

Conflict Group ${index + 1}

`; group.sort((a,b) => a.startDateTime - b.startDateTime).forEach(m => { // Sort meetings within group for display reportHTML += `
${mcdtFormatMeetingForDisplay(m)}
`; }); reportHTML += `
`; }); } else { reportHTML += `

No conflicts detected among the entered meetings.

`; } reportHTML += `

Non-Conflicting Meetings

`; const nonConflictingMeetings = mcdtMeetings.filter(m => !meetingsInvolvedInConflict.has(m.id)); if (nonConflictingMeetings.length > 0) { reportHTML += `
    `; nonConflictingMeetings.sort((a,b) => a.startDateTime - b.startDateTime).forEach(m => { reportHTML += `
  • ${mcdtFormatMeetingForDisplay(m)}
  • `; }); reportHTML += `
`; } else if (conflictGroups.length > 0 && meetingsInvolvedInConflict.size === mcdtMeetings.length) { // All meetings are in some conflict reportHTML += `

All entered meetings are involved in conflicts.

`; } else if (conflictGroups.length === 0 && mcdtMeetings.length > 0) { // This case is handled by "No conflicts detected" above. } else { reportHTML += `

No meetings to list or all were involved in conflicts.

`; } reportHTML += `
`; document.getElementById('mcdt-conflict-report-display').innerHTML = reportHTML; mcdtOpenTab(null, 'mcdt-report'); mcdtUpdateNavButtons(); } // PDF Download function mcdtDownloadPDF() { const reportDisplayElement = document.getElementById('mcdt-conflict-report-display'); if (!reportDisplayElement || reportDisplayElement.innerHTML.includes("Input meetings on the first tab")) { alert("Please detect conflicts first before downloading the report."); return; } let pdfHTML = `

Meeting Conflict Report

`; pdfHTML += `

All Entered Meetings (${mcdtMeetings.length})

`; if (mcdtMeetings.length > 0) { pdfHTML += ``; const sortedAllMeetings = [...mcdtMeetings].sort((a,b) => a.startDateTime - b.startDateTime); sortedAllMeetings.forEach(m => { pdfHTML += ``; }); pdfHTML += `
NameDateStart TimeEnd Time
${m.name}${m.date}${m.startTime}${m.endTime}
`; } else { pdfHTML += "

No meetings were entered.

"; } // Add the generated conflict report (which contains conflict groups and non-conflicting sections) pdfHTML += reportDisplayElement.innerHTML; const pdfContainer = document.getElementById('mcdt-report-content-for-pdf'); if(!pdfContainer) return; pdfContainer.innerHTML = pdfHTML; const opt = { margin: [0.5, 0.4, 0.5, 0.4], filename: 'Meeting_Conflict_Report.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfContainer).set(opt).save().then(() => { pdfContainer.innerHTML = ''; }).catch(err => { console.error("Error generating PDF:", err); pdfContainer.innerHTML = ''; alert("An error occurred while generating the PDF. Check console for details."); }); }
Scroll to Top