Project Milestone Dashboard
No milestones defined. Go to "Manage Milestones" to add one.
';
return;
}
grid.innerHTML = milestonesData.map(milestone => {
const progress = milestone.progress;
const cappedProgress = Math.max(0, Math.min(progress, 100));
return `
${milestone.name}
Completed
${formatPercent(progress)}
`;
}).join('');
}
function renderMilestonesTable() {
const table = document.getElementById('milestones-table');
const headers = ['Milestone Name', 'Progress (%)'];
table.innerHTML = `
${headers.map(h => `| ${h} | `).join('')}Actions |
${milestonesData.map(m => `
|
|
|
`).join('')}
`;
}
window.pmd2_updateMilestone = (id, key, value) => {
const milestone = milestonesData.find(m => m.id === id);
if(milestone) milestone[key] = (key === 'progress') ? parseInt(value) || 0 : value;
renderAll();
};
window.pmd2_addMilestone = () => {
milestonesData.push({ id: Date.now(), name: 'New Milestone', progress: 0 });
renderAll();
};
window.pmd2_removeMilestone = (id) => {
milestonesData = milestonesData.filter(m => m.id !== id);
renderAll();
};
function initialize() {
milestonesData = [
{ id: 1, name: 'Project Charter Approved', progress: 100 },
{ id: 2, name: 'Phase 1: Research Complete', progress: 100 },
{ id: 3, name: 'Prototype Development', progress: 75 },
{ id: 4, name: 'Phase 2: User Testing', progress: 20 },
{ id: 5, name: 'Final Launch Readiness', progress: 0 }
];
renderAll();
}
document.getElementById('pmd2-download-pdf-btn').addEventListener('click', () => {
const overviewTab = document.getElementById('pmd2-tab-0');
html2canvas(overviewTab, { scale: 2, backgroundColor: '#f8fafc' }).then(canvas => {
const { jsPDF } = window.jspdf;
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = pdf.internal.pageSize.getHeight();
const ratio = canvas.width / canvas.height;
let imgWidth = pdfWidth - 20; let imgHeight = imgWidth / ratio;
if(imgHeight > pdfHeight - 20) { imgHeight = pdfHeight - 20; imgWidth = imgHeight * ratio; }
const x = (pdfWidth - imgWidth) / 2; const y = 10;
pdf.addImage(imgData, 'PNG', x, y, imgWidth, imgHeight);
pdf.save('Project-Milestone-Progress.pdf');
});
});
initialize();
});