280 lines
12 KiB
HTML
280 lines
12 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Donor - {{ donor.full_name }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- BEGIN breadcrumb -->
|
|
<ol class="breadcrumb float-xl-end">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Home</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'blood_bank:dashboard' %}">Blood Bank</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'blood_bank:donor_list' %}">Donors</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'blood_bank:donor_detail' donor.id %}">{{ donor.donor_id }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">Delete Donor <small>{{ donor.full_name }}</small></h1>
|
|
<!-- END page-header -->
|
|
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">
|
|
<i class="fa fa-exclamation-triangle text-danger"></i> Confirm Donor Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="alert alert-danger">
|
|
<h5><i class="fa fa-exclamation-triangle"></i> Warning</h5>
|
|
<p>You are about to permanently delete this donor record. This action cannot be undone.</p>
|
|
</div>
|
|
|
|
<!-- BEGIN donor info -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">Donor Information</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold">Donor ID:</td>
|
|
<td>{{ donor.donor_id }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Name:</td>
|
|
<td>{{ donor.full_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Blood Group:</td>
|
|
<td>
|
|
<span class="badge bg-primary">{{ donor.blood_group.display_name }}</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Phone:</td>
|
|
<td>{{ donor.phone }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Registration Date:</td>
|
|
<td>{{ donor.registration_date|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
<span class="badge bg-{% if donor.status == 'active' %}success{% else %}secondary{% endif %}">
|
|
{{ donor.get_status_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">Impact Assessment</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-info">
|
|
<h6><i class="fa fa-info-circle"></i> Related Records</h6>
|
|
<ul class="mb-0">
|
|
<li><strong>{{ donor.total_donations }}</strong> blood unit(s) collected</li>
|
|
<li><strong>{{ donor.blood_units.count }}</strong> blood unit record(s)</li>
|
|
{% if donor.blood_units.filter(status='available').exists %}
|
|
<li class="text-warning">
|
|
<i class="fa fa-exclamation-triangle"></i>
|
|
Has active blood units in inventory
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
|
|
{% if donor.blood_units.filter(status='available').exists %}
|
|
<div class="alert alert-warning">
|
|
<h6><i class="fa fa-exclamation-triangle"></i> Active Blood Units</h6>
|
|
<p class="mb-0">This donor has blood units currently available in inventory.
|
|
Deleting this donor will affect inventory tracking.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if donor.total_donations > 0 %}
|
|
<div class="alert alert-info">
|
|
<h6><i class="fa fa-history"></i> Donation History</h6>
|
|
<p class="mb-0">This donor has a donation history. Consider marking as
|
|
"inactive" instead of deleting to preserve historical data.</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END donor info -->
|
|
|
|
<!-- BEGIN deletion options -->
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">Deletion Options</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<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="duplicate_record">Duplicate Record</option>
|
|
<option value="data_error">Data Entry Error</option>
|
|
<option value="donor_request">Donor Request</option>
|
|
<option value="privacy_compliance">Privacy Compliance</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 the deletion..."></textarea>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="archive_data" id="archiveData" checked>
|
|
<label class="form-check-label" for="archiveData">
|
|
Archive donation history before deletion
|
|
</label>
|
|
<div class="form-text">Keep anonymized donation records for statistical purposes</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="confirm_deletion" id="confirmDeletion" required>
|
|
<label class="form-check-label" for="confirmDeletion">
|
|
<strong>I understand that this action cannot be undone</strong>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- BEGIN form actions -->
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<a href="{% url 'blood_bank:donor_detail' donor.id %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left"></i> Cancel
|
|
</a>
|
|
<a href="{% url 'blood_bank:donor_update' donor.id %}" class="btn btn-warning">
|
|
<i class="fa fa-pause"></i> Mark as Inactive Instead
|
|
</a>
|
|
</div>
|
|
<button type="submit" class="btn btn-danger" id="deleteBtn" disabled>
|
|
<i class="fa fa-trash"></i> Delete Donor Permanently
|
|
</button>
|
|
</div>
|
|
<!-- END form actions -->
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- END deletion options -->
|
|
|
|
<!-- BEGIN alternative actions -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">Alternative Actions</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted">Consider these alternatives to permanent deletion:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="d-grid">
|
|
<a href="{% url 'blood_bank:donor_update' donor.id %}" class="btn btn-outline-warning">
|
|
<i class="fa fa-pause"></i> Mark as Inactive
|
|
</a>
|
|
</div>
|
|
<small class="text-muted">Preserves historical data while preventing new donations</small>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="d-grid">
|
|
<a href="{% url 'blood_bank:donor_update' donor.id %}" class="btn btn-outline-info">
|
|
<i class="fa fa-edit"></i> Update Information
|
|
</a>
|
|
</div>
|
|
<small class="text-muted">Correct any data errors without deletion</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END alternative actions -->
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Enable delete button only when confirmation is checked
|
|
$('#confirmDeletion').on('change', function() {
|
|
$('#deleteBtn').prop('disabled', !this.checked);
|
|
});
|
|
|
|
// Form submission confirmation
|
|
$('form').on('submit', function(e) {
|
|
var reason = $('select[name="deletion_reason"]').val();
|
|
if (!reason) {
|
|
e.preventDefault();
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Missing Information',
|
|
text: 'Please select a reason for deletion.',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
return;
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
Swal.fire({
|
|
title: 'Final Confirmation',
|
|
html: `
|
|
<div class="text-start">
|
|
<p><strong>You are about to permanently delete:</strong></p>
|
|
<ul>
|
|
<li>Donor: {{ donor.full_name }} ({{ donor.donor_id }})</li>
|
|
<li>Reason: ${$('select[name="deletion_reason"] option:selected').text()}</li>
|
|
</ul>
|
|
<p class="text-danger"><strong>This action cannot be undone!</strong></p>
|
|
</div>
|
|
`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#3085d6',
|
|
confirmButtonText: 'Yes, Delete Permanently',
|
|
cancelButtonText: 'Cancel'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// Show loading
|
|
Swal.fire({
|
|
title: 'Deleting Donor...',
|
|
text: 'Please wait while we process the deletion.',
|
|
allowOutsideClick: false,
|
|
didOpen: () => {
|
|
Swal.showLoading();
|
|
}
|
|
});
|
|
|
|
// Submit the form
|
|
this.submit();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|