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

311 lines
16 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete Department: {{ department.name }}{% endblock %}
{% block css %}
<style>
.delete-warning {
background-color: #fff5f5;
border-left: 4px solid #dc3545;
padding: 1rem;
margin-bottom: 1.5rem;
}
.impact-assessment {
background-color: #f8f9fa;
border-radius: 5px;
padding: 1rem;
}
.impact-item {
margin-bottom: 0.5rem;
padding: 0.5rem;
border-radius: 5px;
}
.impact-item.warning {
background-color: rgba(255, 193, 7, 0.1);
}
.impact-item.danger {
background-color: rgba(220, 53, 69, 0.1);
}
.impact-item.success {
background-color: rgba(40, 167, 69, 0.1);
}
.confirmation-checkbox {
font-weight: bold;
}
</style>
{% 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 'hr:dashboard' %}">HR</a></li>
<li class="breadcrumb-item"><a href="{% url 'hr:department_list' %}">Departments</a></li>
<li class="breadcrumb-item"><a href="{% url 'hr:department_detail' department.id %}">{{ department.name }}</a></li>
<li class="breadcrumb-item active">Delete</li>
</ol>
<!-- end breadcrumb -->
<!-- begin page-header -->
<h1 class="page-header">Delete Department: {{ department.name }}</h1>
<!-- end page-header -->
<!-- begin row -->
<div class="row">
<!-- begin col-12 -->
<div class="col-xl-12">
<!-- begin panel -->
<div class="panel panel-inverse">
<!-- begin panel-heading -->
<div class="panel-heading">
<h4 class="panel-title">Confirm Department Deletion</h4>
<div class="panel-heading-btn">
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
<a href="javascript:;" class="btn btn-xs btn-icon btn-success" data-toggle="panel-reload"><i class="fa fa-redo"></i></a>
<a href="javascript:;" class="btn btn-xs btn-icon btn-warning" data-toggle="panel-collapse"><i class="fa fa-minus"></i></a>
</div>
</div>
<!-- end panel-heading -->
<!-- begin panel-body -->
<div class="panel-body">
<!-- Delete Warning -->
<div class="delete-warning">
<h5><i class="fas fa-exclamation-triangle text-danger"></i> Warning: This action cannot be undone</h5>
<p class="mb-0">You are about to permanently delete the department <strong>{{ department.name }}</strong>. This will affect all related data and cannot be reversed.</p>
</div>
<!-- Department Information -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Department Information</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<table class="table table-borderless">
<tbody>
<tr>
<th width="35%">Department Name:</th>
<td>{{ department.name }}</td>
</tr>
<tr>
<th>Department Code:</th>
<td>{{ department.department_code }}</td>
</tr>
<tr>
<th>Type:</th>
<td>{{ department.get_department_type_display }}</td>
</tr>
<tr>
<th>Status:</th>
<td>
{% if department.is_active %}
<span class="badge bg-success">Active</span>
{% else %}
<span class="badge bg-danger">Inactive</span>
{% endif %}
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-6">
<table class="table table-borderless">
<tbody>
<tr>
<th width="35%">Department Head:</th>
<td>
{% if department.department_head %}
{{ department.department_head.get_full_name }}
{% else %}
<span class="text-muted">Not assigned</span>
{% endif %}
</td>
</tr>
<tr>
<th>Parent Department:</th>
<td>
{% if department.parent_department %}
{{ department.parent_department.name }}
{% else %}
<span class="text-muted">None (Top Level)</span>
{% endif %}
</td>
</tr>
<tr>
<th>Location:</th>
<td>{{ department.location|default:"Not specified" }}</td>
</tr>
<tr>
<th>Created:</th>
<td>{{ department.created_at|date:"M d, Y" }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Impact Assessment -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Impact Assessment</h5>
</div>
<div class="card-body">
<div class="impact-assessment">
<!-- Employees Impact -->
<div class="impact-item {% if department.employees.count > 0 %}danger{% else %}success{% endif %}">
<h6>
<i class="fas fa-users me-2"></i> Employees
{% if department.employees.count > 0 %}
<span class="badge bg-danger ms-2">{{ department.employees.count }} affected</span>
{% else %}
<span class="badge bg-success ms-2">None affected</span>
{% endif %}
</h6>
{% if department.employees.count > 0 %}
<p class="mb-0">
<strong>Warning:</strong> {{ department.employees.count }} employee(s) are currently assigned to this department.
These employees will need to be reassigned before deletion or they will be left without a department.
</p>
{% else %}
<p class="mb-0">No employees are currently assigned to this department.</p>
{% endif %}
</div>
<!-- Sub-Departments Impact -->
<div class="impact-item {% if department.subdepartments.count > 0 %}danger{% else %}success{% endif %}">
<h6>
<i class="fas fa-sitemap me-2"></i> Sub-Departments
{% if department.subdepartments.count > 0 %}
<span class="badge bg-danger ms-2">{{ department.subdepartments.count }} affected</span>
{% else %}
<span class="badge bg-success ms-2">None affected</span>
{% endif %}
</h6>
{% if department.subdepartments.count > 0 %}
<p class="mb-0">
<strong>Warning:</strong> {{ department.subdepartments.count }} sub-department(s) are currently under this department.
These sub-departments will need to be reassigned or deleted before proceeding.
</p>
{% else %}
<p class="mb-0">No sub-departments exist under this department.</p>
{% endif %}
</div>
<!-- Schedules Impact -->
<div class="impact-item {% if schedules_count > 0 %}warning{% else %}success{% endif %}">
<h6>
<i class="fas fa-calendar-alt me-2"></i> Schedules
{% if schedules_count > 0 %}
<span class="badge bg-warning ms-2">{{ schedules_count }} affected</span>
{% else %}
<span class="badge bg-success ms-2">None affected</span>
{% endif %}
</h6>
{% if schedules_count > 0 %}
<p class="mb-0">
<strong>Note:</strong> {{ schedules_count }} schedule(s) are associated with this department.
These schedules will be orphaned if the department is deleted.
</p>
{% else %}
<p class="mb-0">No schedules are associated with this department.</p>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Alternative Actions -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Alternative Actions</h5>
</div>
<div class="card-body">
<p>Instead of deleting this department, consider these alternatives:</p>
<div class="row">
<div class="col-md-6">
<div class="card mb-3">
<div class="card-body">
<h6><i class="fas fa-toggle-off me-2"></i> Deactivate Department</h6>
<p class="mb-3">Mark the department as inactive instead of deleting it. This preserves historical data while preventing new assignments.</p>
<a href="{% url 'hr:department_update' department.id %}" class="btn btn-sm btn-outline-primary">
Edit Department
</a>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card mb-3">
<div class="card-body">
<h6><i class="fas fa-exchange-alt me-2"></i> Merge Department</h6>
<p class="mb-3">Transfer employees to another department and then deactivate this one to effectively merge departments.</p>
<a href="{% url 'hr:department_list' %}" class="btn btn-sm btn-outline-primary">
View All Departments
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Confirmation Form -->
<form method="post">
{% csrf_token %}
<div class="form-check mb-4 confirmation-checkbox">
<input class="form-check-input" type="checkbox" id="confirmDelete" required>
<label class="form-check-label" for="confirmDelete">
I understand that this action cannot be undone and all data related to this department will be permanently deleted.
</label>
</div>
<div class="d-flex justify-content-between">
<a href="{% url 'hr:department_detail' department.id %}" class="btn btn-secondary">
<i class="fas fa-times"></i> Cancel
</a>
<button type="submit" class="btn btn-danger" id="deleteBtn" disabled>
<i class="fas fa-trash"></i> Delete Department
</button>
</div>
</form>
</div>
<!-- end panel-body -->
</div>
<!-- end panel -->
</div>
<!-- end col-12 -->
</div>
<!-- end row -->
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
// Enable/disable delete button based on confirmation checkbox
$('#confirmDelete').change(function() {
if ($(this).is(':checked')) {
$('#deleteBtn').prop('disabled', false);
} else {
$('#deleteBtn').prop('disabled', true);
}
});
// Additional confirmation for departments with employees or sub-departments
$('form').submit(function(e) {
{% if department.employees.count > 0 or department.subdepartments.count > 0 %}
if (!confirm('WARNING: This department has {{ department.employees.count }} employee(s) and {{ department.subdepartments.count }} sub-department(s) that will be affected. Are you absolutely sure you want to proceed with deletion?')) {
e.preventDefault();
return false;
}
{% endif %}
});
});
</script>
{% endblock %}