No upcoming deadlines.
`;
}
}
function renderTasksTable() {
tasksTableBody.innerHTML = state.tasks.map(task => `
|
|
|
|
|
|
`).join('');
}
// --- NAVIGATION & TAB LOGIC ---
function switchTab(tabName) {
if (tabName === 'dashboard') {
render(); // Always refresh dashboard
}
tabNavigation.querySelectorAll('.tab-button').forEach(btn => btn.classList.toggle('active', btn.dataset.tab === tabName));
tabContents.querySelectorAll('.tab-content').forEach(content => content.classList.toggle('active', content.id === `${tabName}-tab`));
updateNavButtons();
}
function navigateTabs(direction) {
currentTabIndex = Math.max(0, Math.min(tabs.length - 1, currentTabIndex + direction));
switchTab(tabs[currentTabIndex]);
}
function updateNavButtons() {
prevBtn.style.visibility = currentTabIndex === 0 ? 'hidden' : 'visible';
nextBtn.style.visibility = currentTabIndex === tabs.length - 1 ? 'hidden' : 'visible';
}
// --- PDF GENERATION ---
function generatePDF() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'landscape' });
const metrics = calculateMetrics();
doc.setFontSize(20);
doc.setFont("helvetica", "bold");
doc.text("Corporate Governance Compliance Report", 148.5, 20, { align: 'center' });
doc.setFontSize(10);
doc.text(`Report Generated: ${new Date().toLocaleString('en-US')}`, 148.5, 26, {align: 'center'});
doc.autoTable({
startY: 35,
head: [['Total Tasks', 'Tasks Overdue', 'Tasks Due Soon', 'Overall Compliance Rate']],
body: [[metrics.totalTasks, metrics.overdue, metrics.dueSoon, `${metrics.complianceRate}%`]],
theme: 'grid',
headStyles: { fillColor: [51, 65, 85] }, // Slate-700
});
const body = state.tasks.map(task => [
task.name,
task.regulation,
new Date(task.dueDate).toLocaleDateString('en-US', { timeZone: 'UTC' }),
task.assignedTo,
task.status
]);
doc.autoTable({
startY: doc.autoTable.previous.finalY + 10,
head: [['Task / Description', 'Regulation', 'Due Date', 'Assigned To', 'Status']],
body: body,
theme: 'striped',
headStyles: { fillColor: [51, 65, 85] }, // Slate-700
});
doc.save('Corporate_Compliance_Report.pdf');
}
// --- START THE APP ---
init();
});