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

215 lines
11 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block title %}Report Templates{% 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">Report Templates</h1>
<a href="{% url 'radiology:report_template_create' %}" class="btn btn-primary">
<i class="fas fa-plus"></i> Add New Template
</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-4">
<input type="text" name="search" class="form-control"
placeholder="Search templates..." value="{{ search_query }}">
</div>
<div class="col-md-3">
<select name="modality" class="form-control">
<option value="">All Modalities</option>
{% for value, label in modalities %}
<option value="{{ value }}" {% if request.GET.modality == value %}selected{% endif %}>
{{ label }}
</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<div class="form-check">
<input type="checkbox" name="active_only" class="form-check-input"
{% if request.GET.active_only %}checked{% endif %}>
<label class="form-check-label">Active Only</label>
</div>
</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 'radiology:report_template_list' %}" class="btn btn-outline-secondary">
<i class="fas fa-times"></i> Clear
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Templates Table -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
{% if report_templates %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Template Name</th>
<th>Modality</th>
<th>Body Part</th>
<th>Status</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for template in report_templates %}
<tr>
<td>
<a href="{% url 'radiology:report_template_detail' template.pk %}">
<strong>{{ template.template_name }}</strong>
</a>
{% if template.template_content %}
<br><small class="text-muted">{{ template.template_content|truncatechars:50 }}</small>
{% endif %}
</td>
<td>
<span class="badge badge-info">{{ template.get_modality_display }}</span>
</td>
<td>{{ template.body_part|default:"All" }}</td>
<td>
{% if template.is_active %}
<span class="badge badge-success">Active</span>
{% else %}
<span class="badge badge-secondary">Inactive</span>
{% endif %}
</td>
<td>{{ template.created_at|date:"M d, Y" }}</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="{% url 'radiology:report_template_detail' template.pk %}"
class="btn btn-outline-info" title="View Details">
<i class="fas fa-eye"></i>
</a>
<a href="{% url 'radiology:report_template_update' template.pk %}"
class="btn btn-outline-primary" title="Edit">
<i class="fas fa-edit"></i>
</a>
{% if template.is_active %}
<a href="{% url 'radiology:report_template_delete' template.pk %}"
class="btn btn-outline-danger" title="Deactivate">
<i class="fas fa-ban"></i>
</a>
{% 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-file-alt fa-3x text-muted mb-3"></i>
<h5 class="text-muted">No report templates found</h5>
<p class="text-muted">Start by creating your first report template.</p>
<a href="{% url 'radiology:report_template_create' %}" class="btn btn-primary">
<i class="fas fa-plus"></i> Create First Template
</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<!-- Template Preview Modal -->
<div class="modal fade" id="templatePreviewModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Template Preview</h5>
<button type="button" class="close" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<div id="templatePreviewContent">
<!-- Content will be loaded via AJAX -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
// Template preview functionality
$('.template-preview').on('click', function(e) {
e.preventDefault();
var templateId = $(this).data('template-id');
var templateName = $(this).data('template-name');
$('#templatePreviewModal .modal-title').text('Template Preview: ' + templateName);
// Load template content via AJAX
$.get('/radiology/templates/' + templateId + '/preview/', function(data) {
$('#templatePreviewContent').html(data);
$('#templatePreviewModal').modal('show');
});
});
});
</script>
{% endblock %}