1278 lines
43 KiB
HTML
1278 lines
43 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Quality Findings Management{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<link href="{% static 'assets/plugins/datatables.net-bs5/css/dataTables.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'assets/plugins/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'assets/plugins/datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<style>
|
|
.page-header-section {
|
|
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
|
|
color: white;
|
|
border-radius: 0.5rem;
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
text-align: center;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 3px;
|
|
background: var(--card-color);
|
|
}
|
|
|
|
.stat-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 1rem;
|
|
color: white;
|
|
font-size: 1.25rem;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.stat-label {
|
|
color: #6c757d;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.filters-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.filter-row {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
align-items: end;
|
|
}
|
|
|
|
.findings-table-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.section-header {
|
|
background: #f8f9fa;
|
|
border-bottom: 1px solid #dee2e6;
|
|
padding: 1rem 1.5rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
}
|
|
|
|
.finding-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1rem;
|
|
transition: all 0.2s;
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.finding-card:hover {
|
|
border-color: #dc3545;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.finding-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 4px;
|
|
background: var(--severity-color);
|
|
border-radius: 0.5rem 0 0 0.5rem;
|
|
}
|
|
|
|
.finding-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: start;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.finding-title {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.finding-id {
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.finding-badges {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.severity-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.severity-critical { background: #f8d7da; color: #721c24; }
|
|
.severity-high { background: #ffebee; color: #d32f2f; }
|
|
.severity-medium { background: #fff3e0; color: #f57c00; }
|
|
.severity-low { background: #e8f5e8; color: #2e7d32; }
|
|
|
|
.status-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.status-open { background: #ffebee; color: #d32f2f; }
|
|
.status-investigating { background: #fff3e0; color: #f57c00; }
|
|
.status-resolved { background: #e8f5e8; color: #2e7d32; }
|
|
.status-closed { background: #e9ecef; color: #6c757d; }
|
|
|
|
.finding-description {
|
|
color: #6c757d;
|
|
margin-bottom: 1rem;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.finding-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.meta-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.meta-icon {
|
|
color: #dc3545;
|
|
width: 16px;
|
|
}
|
|
|
|
.finding-progress {
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.progress-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.progress-label {
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
}
|
|
|
|
.progress-percentage {
|
|
font-size: 0.875rem;
|
|
color: #dc3545;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.progress-bar-container {
|
|
background: #e9ecef;
|
|
border-radius: 0.25rem;
|
|
height: 6px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.progress-bar {
|
|
background: linear-gradient(90deg, #dc3545, #c82333);
|
|
height: 100%;
|
|
transition: width 0.3s ease;
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
.finding-actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
justify-content: end;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn-action {
|
|
padding: 0.375rem 0.75rem;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.25rem;
|
|
background: white;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.btn-action:hover {
|
|
border-color: #dc3545;
|
|
color: #dc3545;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-primary-action {
|
|
background: #dc3545;
|
|
border-color: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary-action:hover {
|
|
background: #c82333;
|
|
border-color: #c82333;
|
|
color: white;
|
|
}
|
|
|
|
.quick-filters {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.quick-filter {
|
|
padding: 0.5rem 1rem;
|
|
border: 1px solid #dee2e6;
|
|
background: white;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.quick-filter:hover, .quick-filter.active {
|
|
background: #dc3545;
|
|
color: white;
|
|
border-color: #dc3545;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.category-badge {
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.category-clinical { background: #e3f2fd; color: #1976d2; }
|
|
.category-safety { background: #ffebee; color: #d32f2f; }
|
|
.category-compliance { background: #f3e5f5; color: #7b1fa2; }
|
|
.category-process { background: #e8f5e8; color: #2e7d32; }
|
|
.category-documentation { background: #fff3e0; color: #f57c00; }
|
|
|
|
.finding-timeline {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 1rem;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.timeline-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.25rem;
|
|
}
|
|
|
|
.timeline-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: #dee2e6;
|
|
}
|
|
|
|
.timeline-dot.active {
|
|
background: #dc3545;
|
|
}
|
|
|
|
.timeline-dot.completed {
|
|
background: #28a745;
|
|
}
|
|
|
|
.view-toggle {
|
|
display: flex;
|
|
gap: 0.25rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.25rem;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
.toggle-btn {
|
|
padding: 0.5rem 1rem;
|
|
border: none;
|
|
background: transparent;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.toggle-btn.active {
|
|
background: white;
|
|
color: #dc3545;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.bulk-actions {
|
|
background: #f8f9fa;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1rem;
|
|
margin-bottom: 1rem;
|
|
display: none;
|
|
}
|
|
|
|
.bulk-actions.show {
|
|
display: block;
|
|
}
|
|
|
|
.corrective-actions {
|
|
margin-top: 1rem;
|
|
padding: 1rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.375rem;
|
|
border-left: 4px solid #dc3545;
|
|
}
|
|
|
|
.corrective-actions h6 {
|
|
color: #495057;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.action-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.action-status {
|
|
width: 16px;
|
|
height: 16px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.action-pending { background: #ffc107; }
|
|
.action-progress { background: #17a2b8; }
|
|
.action-completed { background: #28a745; }
|
|
|
|
@media (max-width: 768px) {
|
|
.page-header-section {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.filter-row {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.finding-header {
|
|
flex-direction: column;
|
|
align-items: start;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.finding-meta {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.finding-actions {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.quick-filters {
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
@media print {
|
|
.filters-section, .bulk-actions, .finding-actions {
|
|
display: none !important;
|
|
}
|
|
|
|
.section-header {
|
|
background: none;
|
|
border-bottom: 2px solid #000;
|
|
color: #000;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<!-- Page Header -->
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:dashboard' %}">Quality</a></li>
|
|
<li class="breadcrumb-item active">Findings</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">
|
|
<i class="fas fa-search me-2"></i>Quality Findings
|
|
</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<button type="button" class="btn btn-outline-secondary me-2" onclick="exportFindings()">
|
|
<i class="fas fa-download me-1"></i>Export
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info me-2" onclick="importFindings()">
|
|
<i class="fas fa-upload me-1"></i>Import
|
|
</button>
|
|
<a href="{% url 'quality:finding_create' %}" class="btn btn-danger">
|
|
<i class="fas fa-plus me-1"></i>New Finding
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="stats-cards">
|
|
<div class="stat-card" style="--card-color: #dc3545;">
|
|
<div class="stat-icon" style="background: #dc3545;">
|
|
<i class="fas fa-search"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.total_findings|default:0 }}</div>
|
|
<div class="stat-label">Total Findings</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #dc3545;">
|
|
<div class="stat-icon" style="background: #dc3545;">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.open_findings|default:0 }}</div>
|
|
<div class="stat-label">Open</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #ffc107;">
|
|
<div class="stat-icon" style="background: #ffc107;">
|
|
<i class="fas fa-clock"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.overdue_findings|default:0 }}</div>
|
|
<div class="stat-label">Overdue</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #28a745;">
|
|
<div class="stat-icon" style="background: #28a745;">
|
|
<i class="fas fa-check-circle"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.resolved_findings|default:0 }}</div>
|
|
<div class="stat-label">Resolved</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #6f42c1;">
|
|
<div class="stat-icon" style="background: #6f42c1;">
|
|
<i class="fas fa-exclamation"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.critical_findings|default:0 }}</div>
|
|
<div class="stat-label">Critical</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Filters -->
|
|
<div class="quick-filters">
|
|
<a href="?status=all" class="quick-filter {% if not request.GET.status or request.GET.status == 'all' %}active{% endif %}">
|
|
<i class="fas fa-list me-1"></i>All Findings
|
|
</a>
|
|
<a href="?status=open" class="quick-filter {% if request.GET.status == 'open' %}active{% endif %}">
|
|
<i class="fas fa-exclamation-triangle me-1"></i>Open
|
|
</a>
|
|
<a href="?status=investigating" class="quick-filter {% if request.GET.status == 'investigating' %}active{% endif %}">
|
|
<i class="fas fa-search me-1"></i>Investigating
|
|
</a>
|
|
<a href="?status=resolved" class="quick-filter {% if request.GET.status == 'resolved' %}active{% endif %}">
|
|
<i class="fas fa-check me-1"></i>Resolved
|
|
</a>
|
|
<a href="?severity=critical" class="quick-filter {% if request.GET.severity == 'critical' %}active{% endif %}">
|
|
<i class="fas fa-exclamation-circle me-1"></i>Critical
|
|
</a>
|
|
<a href="?overdue=true" class="quick-filter {% if request.GET.overdue == 'true' %}active{% endif %}">
|
|
<i class="fas fa-clock me-1"></i>Overdue
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Filters Section -->
|
|
<div class="filters-section">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-filter me-2"></i>Advanced Filters
|
|
</h6>
|
|
|
|
<form method="get" id="filter-form">
|
|
<div class="filter-row">
|
|
<div>
|
|
<label class="form-label">Search Findings</label>
|
|
<input type="text" class="form-control" name="search"
|
|
value="{{ request.GET.search }}" placeholder="Search findings...">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Status</label>
|
|
<select class="form-select" name="status">
|
|
<option value="">All Statuses</option>
|
|
<option value="open" {% if request.GET.status == 'open' %}selected{% endif %}>Open</option>
|
|
<option value="investigating" {% if request.GET.status == 'investigating' %}selected{% endif %}>Investigating</option>
|
|
<option value="resolved" {% if request.GET.status == 'resolved' %}selected{% endif %}>Resolved</option>
|
|
<option value="closed" {% if request.GET.status == 'closed' %}selected{% endif %}>Closed</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Severity</label>
|
|
<select class="form-select" name="severity">
|
|
<option value="">All Severities</option>
|
|
<option value="low" {% if request.GET.severity == 'low' %}selected{% endif %}>Low</option>
|
|
<option value="medium" {% if request.GET.severity == 'medium' %}selected{% endif %}>Medium</option>
|
|
<option value="high" {% if request.GET.severity == 'high' %}selected{% endif %}>High</option>
|
|
<option value="critical" {% if request.GET.severity == 'critical' %}selected{% endif %}>Critical</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Category</label>
|
|
<select class="form-select" name="category">
|
|
<option value="">All Categories</option>
|
|
<option value="clinical" {% if request.GET.category == 'clinical' %}selected{% endif %}>Clinical</option>
|
|
<option value="safety" {% if request.GET.category == 'safety' %}selected{% endif %}>Safety</option>
|
|
<option value="compliance" {% if request.GET.category == 'compliance' %}selected{% endif %}>Compliance</option>
|
|
<option value="process" {% if request.GET.category == 'process' %}selected{% endif %}>Process</option>
|
|
<option value="documentation" {% if request.GET.category == 'documentation' %}selected{% endif %}>Documentation</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Department</label>
|
|
<select class="form-select" name="department">
|
|
<option value="">All Departments</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if request.GET.department == dept.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ dept.name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-search me-1"></i>Filter
|
|
</button>
|
|
<a href="{% url 'quality:finding_list' %}" class="btn btn-outline-secondary ms-2">
|
|
<i class="fas fa-times me-1"></i>Clear
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Bulk Actions -->
|
|
<div class="bulk-actions" id="bulk-actions">
|
|
<div class="d-flex align-items-center justify-content-between">
|
|
<div>
|
|
<span id="selected-count">0</span> findings selected
|
|
</div>
|
|
<div>
|
|
<button type="button" class="btn btn-outline-primary btn-sm me-2" onclick="bulkExport()">
|
|
<i class="fas fa-download me-1"></i>Export Selected
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info btn-sm me-2" onclick="bulkStatusUpdate()">
|
|
<i class="fas fa-edit me-1"></i>Update Status
|
|
</button>
|
|
<button type="button" class="btn btn-outline-success btn-sm me-2" onclick="bulkAssign()">
|
|
<i class="fas fa-user me-1"></i>Assign
|
|
</button>
|
|
<button type="button" class="btn btn-outline-danger btn-sm" onclick="bulkClose()">
|
|
<i class="fas fa-times me-1"></i>Close Selected
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Findings Section -->
|
|
<div class="findings-table-section">
|
|
<div class="section-header">
|
|
<div>
|
|
<i class="fas fa-search me-2"></i>Quality Findings ({{ findings|length }})
|
|
</div>
|
|
<div class="d-flex align-items-center gap-2">
|
|
<div class="view-toggle">
|
|
<button type="button" class="toggle-btn active" onclick="setView('cards')" data-view="cards">
|
|
<i class="fas fa-th-large"></i>
|
|
</button>
|
|
<button type="button" class="toggle-btn" onclick="setView('table')" data-view="table">
|
|
<i class="fas fa-table"></i>
|
|
</button>
|
|
</div>
|
|
<div class="form-check form-switch">
|
|
<input class="form-check-input" type="checkbox" id="select-all">
|
|
<label class="form-check-label" for="select-all">Select All</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-3" id="findings-container">
|
|
{% for finding in findings %}
|
|
<div class="finding-card" style="--severity-color: {% if finding.severity == 'critical' %}#dc3545{% elif finding.severity == 'high' %}#fd7e14{% elif finding.severity == 'medium' %}#ffc107{% else %}#28a745{% endif %};" onclick="viewFinding({{ finding.id }})">
|
|
<div class="form-check position-absolute" style="top: 1rem; left: 1rem;">
|
|
<input class="form-check-input finding-checkbox" type="checkbox" value="{{ finding.id }}" onclick="event.stopPropagation();">
|
|
</div>
|
|
|
|
<div class="finding-header">
|
|
<div>
|
|
<div class="finding-title">{{ finding.title }}</div>
|
|
<div class="finding-id">ID: {{ finding.finding_id|default:finding.id }}</div>
|
|
</div>
|
|
<div class="finding-badges">
|
|
<span class="severity-badge severity-{{ finding.severity|lower }}">
|
|
{{ finding.get_severity_display }}
|
|
</span>
|
|
<span class="status-badge status-{{ finding.status }}">
|
|
{{ finding.get_status_display }}
|
|
</span>
|
|
<span class="category-badge category-{{ finding.category|lower }}">
|
|
{{ finding.get_category_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="finding-description">
|
|
{{ finding.description|truncatechars:200 }}
|
|
</div>
|
|
|
|
<div class="finding-meta">
|
|
<div class="meta-item">
|
|
<i class="fas fa-user meta-icon"></i>
|
|
<span>{{ finding.reported_by.get_full_name|default:"Anonymous" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-building meta-icon"></i>
|
|
<span>{{ finding.department.name|default:"No Department" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-alt meta-icon"></i>
|
|
<span>{{ finding.date_identified|date:"M d, Y"|default:"Not set" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-check meta-icon"></i>
|
|
<span>{{ finding.due_date|date:"M d, Y"|default:"No due date" }}</span>
|
|
</div>
|
|
{% if finding.assigned_to %}
|
|
<div class="meta-item">
|
|
<i class="fas fa-user-check meta-icon"></i>
|
|
<span>{{ finding.assigned_to.get_full_name }}</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if finding.resolution_progress is not None %}
|
|
<div class="finding-progress">
|
|
<div class="progress-header">
|
|
<span class="progress-label">Resolution Progress</span>
|
|
<span class="progress-percentage">{{ finding.resolution_progress }}%</span>
|
|
</div>
|
|
<div class="progress-bar-container">
|
|
<div class="progress-bar" style="width: {{ finding.resolution_progress }}%;"></div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="finding-timeline">
|
|
<div class="timeline-item">
|
|
<div class="timeline-dot completed"></div>
|
|
<span>Identified</span>
|
|
</div>
|
|
<div class="timeline-item">
|
|
<div class="timeline-dot {% if finding.status != 'open' %}completed{% elif finding.status == 'investigating' %}active{% endif %}"></div>
|
|
<span>Investigation</span>
|
|
</div>
|
|
<div class="timeline-item">
|
|
<div class="timeline-dot {% if finding.status == 'resolved' %}completed{% elif finding.status == 'investigating' %}active{% endif %}"></div>
|
|
<span>Resolution</span>
|
|
</div>
|
|
<div class="timeline-item">
|
|
<div class="timeline-dot {% if finding.status == 'closed' %}completed{% endif %}"></div>
|
|
<span>Closure</span>
|
|
</div>
|
|
</div>
|
|
|
|
{% if finding.corrective_actions.exists %}
|
|
<div class="corrective-actions">
|
|
<h6><i class="fas fa-tools me-2"></i>Corrective Actions</h6>
|
|
{% for action in finding.corrective_actions.all|slice:":3" %}
|
|
<div class="action-item">
|
|
<div class="action-status action-{{ action.status }}"></div>
|
|
<span>{{ action.description|truncatechars:60 }}</span>
|
|
</div>
|
|
{% endfor %}
|
|
{% if finding.corrective_actions.count > 3 %}
|
|
<div class="text-muted">+{{ finding.corrective_actions.count|add:"-3" }} more actions</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="finding-actions">
|
|
<a href="{% url 'quality:finding_detail' finding.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-eye me-1"></i>View
|
|
</a>
|
|
{% if finding.can_edit %}
|
|
<a href="{% url 'quality:finding_edit' finding.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-edit me-1"></i>Edit
|
|
</a>
|
|
{% endif %}
|
|
{% if finding.status == 'open' %}
|
|
<button type="button" class="btn-primary-action" onclick="event.stopPropagation(); startInvestigation({{ finding.id }});">
|
|
<i class="fas fa-search me-1"></i>Investigate
|
|
</button>
|
|
{% elif finding.status == 'investigating' %}
|
|
<button type="button" class="btn-primary-action" onclick="event.stopPropagation(); resolveFinding({{ finding.id }});">
|
|
<i class="fas fa-check me-1"></i>Resolve
|
|
</button>
|
|
{% elif finding.status == 'resolved' %}
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); closeFinding({{ finding.id }});">
|
|
<i class="fas fa-times me-1"></i>Close
|
|
</button>
|
|
{% endif %}
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); generateReport({{ finding.id }});">
|
|
<i class="fas fa-file-alt me-1"></i>Report
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="text-center py-5">
|
|
<div class="text-muted">
|
|
<i class="fas fa-search fa-3x mb-3"></i>
|
|
<h5>No Quality Findings Found</h5>
|
|
<p>No findings match your current filters.</p>
|
|
<a href="{% url 'quality:finding_create' %}" class="btn btn-danger">
|
|
<i class="fas fa-plus me-1"></i>Report First Finding
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if is_paginated %}
|
|
<div class="d-flex justify-content-between align-items-center p-3">
|
|
<div class="text-muted">
|
|
Showing {{ findings|length }} of {{ total_findings }} findings
|
|
</div>
|
|
|
|
<nav aria-label="Findings pagination">
|
|
<ul class="pagination pagination-sm mb-0">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{{ request.GET.urlencode }}">First</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{{ request.GET.urlencode }}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
|
|
</li>
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{{ request.GET.urlencode }}">Next</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{{ request.GET.urlencode }}">Last</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Status Update Modal -->
|
|
<div class="modal fade" id="statusModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-edit me-2"></i>Update Finding Status
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">New Status</label>
|
|
<select class="form-select" id="new-status">
|
|
<option value="open">Open</option>
|
|
<option value="investigating">Investigating</option>
|
|
<option value="resolved">Resolved</option>
|
|
<option value="closed">Closed</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Status Change Reason</label>
|
|
<textarea class="form-control" id="status-reason" rows="3"
|
|
placeholder="Please provide a reason for this status change..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-primary" onclick="confirmStatusUpdate()">
|
|
<i class="fas fa-save me-1"></i>Update Status
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Assignment Modal -->
|
|
<div class="modal fade" id="assignModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-user me-2"></i>Assign Findings
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Assign To</label>
|
|
<select class="form-select" id="assign-to">
|
|
<option value="">Select User</option>
|
|
{% for user in assignable_users %}
|
|
<option value="{{ user.id }}">{{ user.get_full_name }} ({{ user.email }})</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Assignment Notes</label>
|
|
<textarea class="form-control" id="assignment-notes" rows="3"
|
|
placeholder="Add any notes for the assignee..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-primary" onclick="confirmAssignment()">
|
|
<i class="fas fa-user-check me-1"></i>Assign
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script src="{% static 'assets/plugins/datatables.net/js/jquery.dataTables.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-bs5/js/dataTables.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-responsive-bs5/js/responsive.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-buttons-bs5/js/buttons.bootstrap5.min.js' %}"></script>
|
|
|
|
<script>
|
|
let selectedFindings = [];
|
|
|
|
$(document).ready(function() {
|
|
// Handle select all checkbox
|
|
$('#select-all').change(function() {
|
|
$('.finding-checkbox').prop('checked', this.checked);
|
|
updateBulkActions();
|
|
});
|
|
|
|
// Handle individual checkboxes
|
|
$('.finding-checkbox').change(function() {
|
|
updateBulkActions();
|
|
|
|
// Update select all checkbox
|
|
const totalCheckboxes = $('.finding-checkbox').length;
|
|
const checkedCheckboxes = $('.finding-checkbox:checked').length;
|
|
$('#select-all').prop('checked', totalCheckboxes === checkedCheckboxes);
|
|
});
|
|
});
|
|
|
|
function updateBulkActions() {
|
|
const selectedCount = $('.finding-checkbox:checked').length;
|
|
$('#selected-count').text(selectedCount);
|
|
|
|
if (selectedCount > 0) {
|
|
$('#bulk-actions').addClass('show');
|
|
} else {
|
|
$('#bulk-actions').removeClass('show');
|
|
}
|
|
|
|
selectedFindings = $('.finding-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
}
|
|
|
|
function setView(viewType) {
|
|
$('.toggle-btn').removeClass('active');
|
|
$(`[data-view="${viewType}"]`).addClass('active');
|
|
|
|
// In a real implementation, this would switch between card and table views
|
|
if (viewType === 'table') {
|
|
// Convert to table view
|
|
showAlert('Table view activated', 'info');
|
|
} else {
|
|
// Convert to card view
|
|
showAlert('Card view activated', 'info');
|
|
}
|
|
}
|
|
|
|
function viewFinding(findingId) {
|
|
window.location.href = `/quality/findings/${findingId}/`;
|
|
}
|
|
|
|
function startInvestigation(findingId) {
|
|
if (confirm('Start investigation for this finding?')) {
|
|
fetch(`/quality/findings/${findingId}/start-investigation/`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert('Investigation started', 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error starting investigation', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error starting investigation', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function resolveFinding(findingId) {
|
|
if (confirm('Mark this finding as resolved?')) {
|
|
fetch(`/quality/findings/${findingId}/resolve/`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert('Finding resolved', 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error resolving finding', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error resolving finding', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function closeFinding(findingId) {
|
|
if (confirm('Close this finding? This action cannot be undone.')) {
|
|
fetch(`/quality/findings/${findingId}/close/`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert('Finding closed', 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error closing finding', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error closing finding', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function generateReport(findingId) {
|
|
window.open(`/quality/findings/${findingId}/report/`, '_blank');
|
|
}
|
|
|
|
function exportFindings() {
|
|
const selectedFindings = $('.finding-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
|
|
let url = '/quality/findings/export/';
|
|
if (selectedFindings.length > 0) {
|
|
url += '?findings=' + selectedFindings.join(',');
|
|
}
|
|
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function importFindings() {
|
|
// Create file input for importing findings
|
|
const input = document.createElement('input');
|
|
input.type = 'file';
|
|
input.accept = '.csv,.xlsx';
|
|
input.onchange = function(e) {
|
|
const file = e.target.files[0];
|
|
if (file) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
|
|
fetch('/quality/findings/import/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
},
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.imported_count} findings imported successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error importing findings: ' + (data.error || 'Unknown error'), 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error importing findings', 'danger');
|
|
});
|
|
}
|
|
};
|
|
input.click();
|
|
}
|
|
|
|
function bulkExport() {
|
|
if (selectedFindings.length === 0) {
|
|
showAlert('Please select findings to export', 'warning');
|
|
return;
|
|
}
|
|
|
|
const url = '/quality/findings/export/?findings=' + selectedFindings.join(',');
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function bulkStatusUpdate() {
|
|
if (selectedFindings.length === 0) {
|
|
showAlert('Please select findings to update', 'warning');
|
|
return;
|
|
}
|
|
|
|
new bootstrap.Modal(document.getElementById('statusModal')).show();
|
|
}
|
|
|
|
function confirmStatusUpdate() {
|
|
const newStatus = document.getElementById('new-status').value;
|
|
const reason = document.getElementById('status-reason').value;
|
|
|
|
if (!reason.trim()) {
|
|
showAlert('Please provide a reason for the status change', 'warning');
|
|
return;
|
|
}
|
|
|
|
fetch('/quality/findings/bulk-status-update/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
finding_ids: selectedFindings,
|
|
status: newStatus,
|
|
reason: reason
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.updated_count} findings updated successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error updating findings', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error updating findings', 'danger');
|
|
});
|
|
|
|
bootstrap.Modal.getInstance(document.getElementById('statusModal')).hide();
|
|
}
|
|
|
|
function bulkAssign() {
|
|
if (selectedFindings.length === 0) {
|
|
showAlert('Please select findings to assign', 'warning');
|
|
return;
|
|
}
|
|
|
|
new bootstrap.Modal(document.getElementById('assignModal')).show();
|
|
}
|
|
|
|
function confirmAssignment() {
|
|
const assignTo = document.getElementById('assign-to').value;
|
|
const notes = document.getElementById('assignment-notes').value;
|
|
|
|
if (!assignTo) {
|
|
showAlert('Please select a user to assign to', 'warning');
|
|
return;
|
|
}
|
|
|
|
fetch('/quality/findings/bulk-assign/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
finding_ids: selectedFindings,
|
|
assign_to: assignTo,
|
|
notes: notes
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.assigned_count} findings assigned successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error assigning findings', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error assigning findings', 'danger');
|
|
});
|
|
|
|
bootstrap.Modal.getInstance(document.getElementById('assignModal')).hide();
|
|
}
|
|
|
|
function bulkClose() {
|
|
if (selectedFindings.length === 0) {
|
|
showAlert('Please select findings to close', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (confirm(`Are you sure you want to close ${selectedFindings.length} selected findings? This action cannot be undone.`)) {
|
|
fetch('/quality/findings/bulk-close/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
finding_ids: selectedFindings
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.closed_count} findings closed successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error closing findings', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error closing findings', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function showAlert(message, type) {
|
|
const alertDiv = document.createElement('div');
|
|
alertDiv.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
|
|
alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 1060; min-width: 300px;';
|
|
alertDiv.innerHTML = `
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
`;
|
|
|
|
document.body.appendChild(alertDiv);
|
|
|
|
setTimeout(() => {
|
|
if (alertDiv.parentNode) {
|
|
alertDiv.remove();
|
|
}
|
|
}, 5000);
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|