<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Root Cause Analysis Document</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 2rem;
background: #f9f9f9;
color: #333;
}
.header {
text-align: center;
margin-bottom: 2rem;
}
.logo-upload {
margin-bottom: 1rem;
}
.logo-upload input {
display: none;
}
.logo-upload label {
display: inline-block;
padding: 0.5rem 1rem;
background: #004080;
color: white;
cursor: pointer;
border-radius: 4px;
}
.logo-preview {
max-width: 200px;
max-height: 100px;
margin: 0 auto;
display: block;
}
h1, h2 {
color: #004080;
}
.container {
max-width: 900px;
margin: auto;
background: white;
padding: 2rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
section {
margin-bottom: 2rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
.form-group input,
.form-group textarea,
.form-group select {
width: 100%;
padding: 0.5rem;
border: 1px solid #ddd;
border-radius: 4px;
font-family: Arial, sans-serif;
}
.form-group textarea {
min-height: 100px;
resize: vertical;
}
.timeline {
border-left: 3px solid #004080;
padding-left: 1rem;
margin-top: 1rem;
}
.timeline-item {
margin-bottom: 1rem;
position: relative;
}
.timeline-item::before {
content: '';
position: absolute;
left: -10px;
top: 5px;
width: 10px;
height: 10px;
background: #004080;
border-radius: 50%;
}
button {
background-color: #004080;
color: white;
border: none;
padding: 0.75rem 1.5rem;
font-size: 1rem;
cursor: pointer;
border-radius: 4px;
margin-right: 0.5rem;
}
button:hover {
background-color: #003060;
}
.button-group {
text-align: center;
margin-top: 2rem;
}
#timeline-container {
margin-top: 1rem;
}
.add-timeline-item {
background-color: #28a745;
}
.add-timeline-item:hover {
background-color: #218838;
}
.remove-timeline-item {
background-color: #dc3545;
}
.remove-timeline-item:hover {
background-color: #c82333;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<div class="logo-upload">
<label for="logo-upload">Upload Company Logo</label>
<input type="file" id="logo-upload" accept="image/*" />
<img id="logo-preview" class="logo-preview" src="" alt="Company Logo" style="display: none;" />
</div>
<h1 id="document-title">Root Cause Analysis Document</h1>
</div>
<form id="rca-form">
<section>
<h2>Event Summary</h2>
<div class="form-group">
<textarea id="event-summary" placeholder="Describe the event..."></textarea>
</div>
</section>
<section>
<h2>Resolution Summary</h2>
<div class="form-group">
<textarea id="resolution-summary" placeholder="Describe how the issue was resolved..."></textarea>
</div>
</section>
<section>
<h2>Duration</h2>
<div class="form-group">
<label for="start-time">Start Time:</label>
<input type="datetime-local" id="start-time" />
</div>
<div class="form-group">
<label for="end-time">End Time:</label>
<input type="datetime-local" id="end-time" />
</div>
<div class="form-group">
<label for="total-downtime">Total Downtime:</label>
<input type="text" id="total-downtime" placeholder="e.g., 3 hours" />
</div>
</section>
<section>
<h2>Event Timeline</h2>
<div id="timeline-container">
<!-- Timeline items will be added here dynamically -->
</div>
<button type="button" class="add-timeline-item" id="add-timeline-item">Add Timeline Item</button>
</section>
<section>
<h2>Root Cause</h2>
<div class="form-group">
<textarea id="root-cause" placeholder="Describe the root cause..."></textarea>
</div>
</section>
<section>
<h2>Remediation Actions Taken</h2>
<div class="form-group">
<textarea id="remediation-actions" placeholder="List remediation actions..."></textarea>
</div>
</section>
<div class="button-group">
<button type="button" id="download-pdf">Download as PDF</button>
</div>
</form>
</div>
<!-- Include html2pdf.js from CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<script>
// Handle logo upload
document.getElementById('logo-upload').addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(event) {
const logoPreview = document.getElementById('logo-preview');
logoPreview.src = event.target.result;
logoPreview.style.display = 'block';
};
reader.readAsDataURL(file);
}
});
// Add timeline items
document.getElementById('add-timeline-item').addEventListener('click', function() {
const container = document.getElementById('timeline-container');
const itemCount = container.querySelectorAll('.timeline-item').length + 1;
const timelineItem = document.createElement('div');
timelineItem.className = 'timeline-item';
timelineItem.innerHTML = `
<div class="form-group">
<label for="timeline-time-${itemCount}">Time:</label>
<input type="text" id="timeline-time-${itemCount}" placeholder="e.g., 10:00 AM" />
</div>
<div class="form-group">
<label for="timeline-description-${itemCount}">Description:</label>
<textarea id="timeline-description-${itemCount}" placeholder="Describe the event..."></textarea>
</div>
<button type="button" class="remove-timeline-item" onclick="this.parentNode.remove()">Remove</button>
`;
container.appendChild(timelineItem);
});
// Download as PDF
document.getElementById('download-pdf').addEventListener('click', function() {
// Create a clone of the form to modify for PDF
const form = document.getElementById('rca-form');
const formClone = form.cloneNode(true);
// Replace form elements with their values
const textAreas = formClone.querySelectorAll('textarea');
textAreas.forEach(textarea => {
const value = textarea.value || textarea.placeholder;
const p = document.createElement('p');
p.innerHTML = value.replace(/\n/g, '<br>');
textarea.parentNode.replaceChild(p, textarea);
});
const inputs = formClone.querySelectorAll('input:not([type="file"])');
inputs.forEach(input => {
const value = input.value || input.placeholder;
const p = document.createElement('p');
p.textContent = value;
input.parentNode.replaceChild(p, input);
});
// Remove buttons and file input
const buttons = formClone.querySelectorAll('button');
buttons.forEach(button => button.remove());
const fileInputs = formClone.querySelectorAll('input[type="file"]');
fileInputs.forEach(input => input.remove());
// Create a temporary container for the PDF
const tempContainer = document.createElement('div');
tempContainer.style.position = 'absolute';
tempContainer.style.left = '-9999px';
tempContainer.appendChild(formClone);
document.body.appendChild(tempContainer);
// Generate PDF
const opt = {
margin: 0.5,
filename: 'Root_Cause_Analysis_Document.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
html2pdf().set(opt).from(tempContainer).save().then(() => {
document.body.removeChild(tempContainer);
});
});
</script>
</body>
</html>