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

365 lines
19 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete {{ object.name }} - Analytics Reports{% endblock %}
{% block content %}
<!-- BEGIN breadcrumb -->
<ol class="breadcrumb float-xl-end">
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{% url 'analytics:dashboard' %}">Analytics</a></li>
<li class="breadcrumb-item"><a href="{% url 'analytics:report_list' %}">Reports</a></li>
<li class="breadcrumb-item active">Delete Confirmation</li>
</ol>
<!-- END breadcrumb -->
<!-- BEGIN page-header -->
<h1 class="page-header">
Delete Report
<small>Confirmation Required</small>
</h1>
<!-- END page-header -->
<div class="row justify-content-center">
<div class="col-xl-8">
<!-- BEGIN panel -->
<div class="panel panel-inverse">
<div class="panel-heading">
<h4 class="panel-title">
<i class="fa fa-exclamation-triangle text-warning me-2"></i>
Confirm Report Deletion
</h4>
</div>
<div class="panel-body">
<!-- Warning Alert -->
<div class="alert alert-warning d-flex align-items-center mb-4">
<i class="fa fa-exclamation-triangle fa-2x me-3"></i>
<div>
<h6 class="alert-heading mb-1">Warning: Permanent Deletion</h6>
<p class="mb-0">You are about to permanently delete an analytics report. This action cannot be undone and will affect all associated data and schedules.</p>
</div>
</div>
<!-- Report Information -->
<div class="row mb-4">
<div class="col-md-6">
<h6 class="mb-3">Report Details</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="140">Name:</td>
<td>{{ object.name }}</td>
</tr>
<tr>
<td class="fw-bold">Description:</td>
<td>{{ object.description|default:"No description" }}</td>
</tr>
<tr>
<td class="fw-bold">Category:</td>
<td>
<span class="badge bg-primary">{{ object.get_category_display }}</span>
</td>
</tr>
<tr>
<td class="fw-bold">Type:</td>
<td>{{ object.get_type_display }}</td>
</tr>
<tr>
<td class="fw-bold">Status:</td>
<td>
<span class="badge bg-{% if object.status == 'ACTIVE' %}success{% elif object.status == 'DRAFT' %}warning{% else %}secondary{% endif %}">
{{ object.get_status_display }}
</span>
</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6 class="mb-3">Report Statistics</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="140">Created:</td>
<td>{{ object.created_at|date:"M d, Y" }}</td>
</tr>
<tr>
<td class="fw-bold">Created By:</td>
<td>{{ object.created_by.get_full_name|default:"System" }}</td>
</tr>
<tr>
<td class="fw-bold">Last Generated:</td>
<td>{{ object.last_generated|date:"M d, Y H:i"|default:"Never" }}</td>
</tr>
<tr>
<td class="fw-bold">Total Executions:</td>
<td>{{ object.execution_count }}</td>
</tr>
<tr>
<td class="fw-bold">Success Rate:</td>
<td>{{ object.success_rate }}%</td>
</tr>
</table>
</div>
</div>
<!-- Impact Assessment -->
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-info-circle me-2"></i>Impact Assessment
</h6>
<ul class="mb-0">
<li><strong>Report Definition:</strong> The report configuration and SQL query will be permanently deleted</li>
<li><strong>Execution History:</strong> All {{ object.execution_count }} execution records will be removed</li>
<li><strong>Generated Files:</strong> All previously generated report files will be deleted</li>
{% if object.type == 'SCHEDULED' %}
<li><strong>Scheduled Jobs:</strong> Any scheduled executions will be cancelled</li>
{% endif %}
<li><strong>Dependencies:</strong> Any dashboards or systems referencing this report may be affected</li>
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance purposes</li>
</ul>
</div>
<!-- Schedule Information -->
{% if object.type == 'SCHEDULED' and object.schedule %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-clock me-2"></i>Scheduled Report Warning
</h6>
<p class="mb-2">This is a scheduled report with the following configuration:</p>
<ul class="mb-0">
<li><strong>Frequency:</strong> {{ object.schedule.get_frequency_display }}</li>
<li><strong>Time:</strong> {{ object.schedule.time|time:"H:i" }}</li>
{% if object.schedule.day_of_week %}
<li><strong>Day of Week:</strong> {{ object.schedule.get_day_of_week_display }}</li>
{% endif %}
{% if object.schedule.day_of_month %}
<li><strong>Day of Month:</strong> {{ object.schedule.day_of_month }}</li>
{% endif %}
<li><strong>Next Run:</strong> {{ object.next_run|date:"M d, Y H:i"|default:"Not scheduled" }}</li>
</ul>
</div>
{% endif %}
<!-- Related Data Summary -->
<div class="row mb-4">
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-primary">{{ object.execution_count }}</div>
<div class="small text-muted">Executions</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-info">{{ object.file_count }}</div>
<div class="small text-muted">Generated Files</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-warning">{{ object.total_file_size_formatted }}</div>
<div class="small text-muted">Total File Size</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-secondary">{{ object.dependency_count }}</div>
<div class="small text-muted">Dependencies</div>
</div>
</div>
</div>
<!-- Alternative Actions -->
<div class="card border-secondary mb-4">
<div class="card-header bg-light">
<h6 class="card-title mb-0">
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
</h6>
</div>
<div class="card-body">
<p class="card-text">Consider these alternatives instead of deletion:</p>
<div class="row">
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-archive text-warning me-2"></i>
<a href="{% url 'analytics:report_archive' object.pk %}" class="text-decoration-none">
Archive the report
</a>
</li>
<li class="mb-2">
<i class="fa fa-pause text-info me-2"></i>
<a href="{% url 'analytics:report_deactivate' object.pk %}" class="text-decoration-none">
Deactivate the report
</a>
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-edit text-primary me-2"></i>
<a href="{% url 'analytics:report_update' object.pk %}" class="text-decoration-none">
Edit report configuration
</a>
</li>
<li class="mb-2">
<i class="fa fa-download text-success me-2"></i>
Export report definition
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Dependencies Warning -->
{% if object.dependency_count > 0 %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-exclamation-triangle me-2"></i>Dependencies Found
</h6>
<p class="mb-2">This report has {{ object.dependency_count }} dependencies that may be affected:</p>
<ul class="mb-0">
{% for dependency in object.dependencies.all %}
<li>{{ dependency.name }} ({{ dependency.type }})</li>
{% endfor %}
</ul>
</div>
{% endif %}
<!-- Deletion Form -->
<form method="post" id="delete-form">
{% csrf_token %}
<div class="card border-danger">
<div class="card-header bg-danger text-white">
<h6 class="card-title mb-0">
<i class="fa fa-trash me-2"></i>Deletion Confirmation
</h6>
</div>
<div class="card-body">
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-understanding" required>
<label class="form-check-label" for="confirm-understanding">
I understand that this action will permanently delete the report and cannot be undone
</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-impact" required>
<label class="form-check-label" for="confirm-impact">
I acknowledge the impact on execution history, files, and dependencies
</label>
</div>
{% if object.type == 'SCHEDULED' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-schedule" required>
<label class="form-check-label" for="confirm-schedule">
I understand that scheduled executions will be cancelled
</label>
</div>
{% endif %}
{% if object.dependency_count > 0 %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-dependencies" required>
<label class="form-check-label" for="confirm-dependencies">
I acknowledge that {{ object.dependency_count }} dependencies may be affected
</label>
</div>
{% endif %}
<div class="mb-3">
<label class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
<select class="form-select" name="deletion_reason" required>
<option value="">Select reason...</option>
<option value="OBSOLETE">Report is obsolete</option>
<option value="DUPLICATE">Duplicate report</option>
<option value="INCORRECT">Incorrect configuration</option>
<option value="SECURITY">Security concern</option>
<option value="COMPLIANCE">Compliance requirement</option>
<option value="CLEANUP">Data cleanup</option>
<option value="OTHER">Other</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Additional Notes</label>
<textarea class="form-control" name="deletion_notes" rows="3"
placeholder="Provide additional details about why this report is being deleted..."></textarea>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="backup_before_delete" id="backup-checkbox">
<label class="form-check-label" for="backup-checkbox">
Create backup of report definition before deletion
</label>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="d-flex justify-content-between mt-4">
<div>
<a href="{% url 'analytics:report_detail' object.pk %}" class="btn btn-secondary">
<i class="fa fa-arrow-left me-2"></i>Cancel
</a>
<a href="{% url 'analytics:report_archive' object.pk %}" class="btn btn-warning ms-2">
<i class="fa fa-archive me-2"></i>Archive Instead
</a>
</div>
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
<i class="fa fa-trash me-2"></i>Permanently Delete Report
</button>
</div>
</form>
</div>
</div>
<!-- END panel -->
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
// Enable/disable delete button based on checkboxes
function updateDeleteButton() {
var allChecked = true;
$('input[type="checkbox"][required]').each(function() {
if (!$(this).is(':checked')) {
allChecked = false;
return false;
}
});
var reasonSelected = $('select[name="deletion_reason"]').val() !== '';
$('#delete-btn').prop('disabled', !(allChecked && reasonSelected));
}
// Check on checkbox change
$('input[type="checkbox"], select[name="deletion_reason"]').on('change', updateDeleteButton);
// Form submission confirmation
$('#delete-form').on('submit', function(e) {
var confirmText = 'Are you absolutely sure you want to permanently delete "{{ object.name }}"?';
{% if object.type == 'SCHEDULED' %}
confirmText += '\n\nThis will cancel all scheduled executions!';
{% endif %}
{% if object.dependency_count > 0 %}
confirmText += '\n\nThis will affect {{ object.dependency_count }} dependencies!';
{% endif %}
confirmText += '\n\nThis action cannot be undone.';
if (!confirm(confirmText)) {
e.preventDefault();
}
});
// Auto-focus on first checkbox
$('#confirm-understanding').focus();
});
</script>
{% endblock %}