hospital-management/templates/quality/incident_report_list.html
2025-08-12 13:33:25 +03:00

247 lines
14 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block title %}Incident Reports{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 mb-0">Incident Reports</h1>
<a href="{% url 'quality:incident_report_create' %}" class="btn btn-danger">
<i class="fas fa-plus"></i> Report New Incident
</a>
</div>
</div>
</div>
<!-- Search and Filter Form -->
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-body">
<form method="get" class="row">
<div class="col-md-3">
<input type="text" name="search" class="form-control"
placeholder="Search incidents..." value="{{ request.GET.search }}">
</div>
<div class="col-md-2">
<select name="severity" class="form-control">
<option value="">All Severities</option>
{% for value, label in severities %}
<option value="{{ value }}" {% if request.GET.severity == value %}selected{% endif %}>
{{ label }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<select name="status" class="form-control">
<option value="">All Statuses</option>
{% for value, label in statuses %}
<option value="{{ value }}" {% if request.GET.status == value %}selected{% endif %}>
{{ label }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<select name="incident_type" class="form-control">
<option value="">All Types</option>
{% for value, label in incident_types %}
<option value="{{ value }}" {% if request.GET.incident_type == value %}selected{% endif %}>
{{ label }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-outline-primary">
<i class="fas fa-search"></i> Search
</button>
<a href="{% url 'quality:incident_report_list' %}" class="btn btn-outline-secondary">
<i class="fas fa-times"></i> Clear
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Incidents Table -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
{% if incident_reports %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Incident</th>
<th>Type</th>
<th>Severity</th>
<th>Location</th>
<th>Reported By</th>
<th>Date</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for incident in incident_reports %}
<tr>
<td>
<a href="{% url 'quality:incident_report_detail' incident.pk %}">
<strong>{{ incident.incident_title }}</strong>
</a>
<br><small class="text-muted">{{ incident.incident_description|truncatechars:50 }}</small>
</td>
<td>
<span class="badge badge-secondary">{{ incident.get_incident_type_display }}</span>
</td>
<td>
<span class="badge badge-{% if incident.severity == 'CRITICAL' %}danger{% elif incident.severity == 'HIGH' %}warning{% elif incident.severity == 'MEDIUM' %}info{% else %}secondary{% endif %}">
{{ incident.get_severity_display }}
</span>
</td>
<td>
{{ incident.location }}
{% if incident.department %}
<br><small class="text-muted">{{ incident.department }}</small>
{% endif %}
</td>
<td>
{{ incident.reported_by.first_name }} {{ incident.reported_by.last_name }}
<br><small class="text-muted">{{ incident.report_date|date:"M d, Y" }}</small>
</td>
<td>
{{ incident.incident_date|date:"M d, Y" }}
{% if incident.incident_time %}
<br><small class="text-muted">{{ incident.incident_time|time:"H:i" }}</small>
{% endif %}
</td>
<td>
<span class="badge badge-{% if incident.status == 'CLOSED' %}success{% elif incident.status == 'INVESTIGATING' %}warning{% elif incident.status == 'PENDING_REVIEW' %}info{% else %}secondary{% endif %}">
{{ incident.get_status_display }}
</span>
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="{% url 'quality:incident_report_detail' incident.pk %}"
class="btn btn-outline-info" title="View Details">
<i class="fas fa-eye"></i>
</a>
{% if incident.status != 'CLOSED' %}
<button type="button" class="btn btn-outline-success"
title="Close Incident" data-toggle="modal"
data-target="#closeIncidentModal{{ incident.pk }}">
<i class="fas fa-check"></i>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if is_paginated %}
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page=1{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}">First</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}">Previous</a>
</li>
{% endif %}
<li class="page-item active">
<span class="page-link">
Page {{ 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 }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}">Next</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}">Last</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<div class="text-center py-4">
<i class="fas fa-exclamation-triangle fa-3x text-muted mb-3"></i>
<h5 class="text-muted">No incident reports found</h5>
<p class="text-muted">Start by reporting your first incident.</p>
<a href="{% url 'quality:incident_report_create' %}" class="btn btn-danger">
<i class="fas fa-plus"></i> Report First Incident
</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<!-- Close Incident Modals -->
{% for incident in incident_reports %}
{% if incident.status != 'CLOSED' %}
<div class="modal fade" id="closeIncidentModal{{ incident.pk }}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Close Incident Report</h5>
<button type="button" class="close" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form method="post" action="{% url 'quality:close_incident' incident.pk %}">
{% csrf_token %}
<div class="modal-body">
<div class="form-group">
<label>Incident:</label>
<p><strong>{{ incident.incident_title }}</strong></p>
</div>
<div class="form-group">
<label>Current Status:</label>
<p>{{ incident.get_status_display }}</p>
</div>
<div class="form-group">
<label>Severity:</label>
<p>
<span class="badge badge-{% if incident.severity == 'CRITICAL' %}danger{% elif incident.severity == 'HIGH' %}warning{% elif incident.severity == 'MEDIUM' %}info{% else %}secondary{% endif %}">
{{ incident.get_severity_display }}
</span>
</p>
</div>
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
This will mark the incident as "Closed" and set the resolution date to today.
This action cannot be undone.
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-success">Close Incident</button>
</div>
</form>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endblock %}