hospital-management/templates_for_deletion/employee_confirm_delete.html
Marwan Alwali 263292f6be update
2025-11-04 00:50:06 +03:00

426 lines
20 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}
Delete Employee | HR Management
{% endblock %}
{% block css %}
<style>
.delete-warning {
background-color: #f8d7da;
border-left: 5px solid #dc3545;
padding: 15px;
margin-bottom: 20px;
border-radius: 5px;
}
.employee-info {
background-color: #f8f9fa;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
}
.employee-info-title {
border-bottom: 1px solid #dee2e6;
padding-bottom: 10px;
margin-bottom: 20px;
}
.badge-status {
font-size: 85%;
}
.badge-active {
background-color: #198754;
}
.badge-inactive {
background-color: #dc3545;
}
.badge-on-leave {
background-color: #ffc107;
color: #000;
}
.alternative-action {
background-color: #e2f0fb;
border-left: 5px solid #0d6efd;
padding: 15px;
margin-bottom: 20px;
border-radius: 5px;
}
.dependency-list {
max-height: 200px;
overflow-y: auto;
}
</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:employee_list' %}">Employees</a></li>
<li class="breadcrumb-item"><a href="{% url 'hr:employee_detail' employee.id %}">{{ employee.get_full_name }}</a></li>
<li class="breadcrumb-item active">Delete</li>
</ol>
<!-- end breadcrumb -->
<!-- begin page-header -->
<h1 class="page-header">
Delete Employee
</h1>
<!-- end page-header -->
<!-- begin row -->
<div class="row">
<!-- begin col-8 -->
<div class="col-xl-8">
<!-- begin panel -->
<div class="panel panel-inverse">
<!-- begin panel-heading -->
<div class="panel-heading">
<h4 class="panel-title">Confirm 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"></i> Warning: This action cannot be undone</h5>
<p>You are about to permanently delete this employee record. This action cannot be reversed. Please review the information below carefully before proceeding.</p>
</div>
<!-- Employee Information -->
<div class="employee-info">
<h5 class="employee-info-title">Employee Information</h5>
<div class="row">
<div class="col-md-6 mb-3">
<strong>Name:</strong>
<div>{{ employee.get_full_name }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Employee ID:</strong>
<div>{{ employee.employee_id }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Department:</strong>
<div>{{ employee.department.name }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Job Title:</strong>
<div>{{ employee.job_title }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Status:</strong>
<div>
<span class="badge badge-{{ employee.status|lower }} badge-status">
{{ employee.get_status_display }}
</span>
</div>
</div>
<div class="col-md-6 mb-3">
<strong>Hire Date:</strong>
<div>{{ employee.hire_date|date:"M d, Y" }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Email:</strong>
<div>{{ employee.email }}</div>
</div>
<div class="col-md-6 mb-3">
<strong>Phone:</strong>
<div>{{ employee.phone_number|default:"Not provided" }}</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="mb-3">
<h6>The following will be permanently deleted:</h6>
<ul>
<li>Employee personal and professional information</li>
<li>Employment history and documentation</li>
<li>Contact information and emergency contacts</li>
{% if employee.profile_picture %}
<li>Profile picture and identification documents</li>
{% endif %}
{% if employee.address %}
<li>Address and location information</li>
{% endif %}
</ul>
</div>
<!-- Dependencies -->
<div class="mb-3">
<h6>The following related records will also be affected:</h6>
{% if schedules_count > 0 %}
<div class="mb-2">
<strong>Schedules:</strong> {{ schedules_count }} record(s)
<div class="dependency-list">
<ul class="list-group">
{% for schedule in schedules %}
<li class="list-group-item">
{{ schedule.title }} ({{ schedule.start_date|date:"M d, Y" }} - {{ schedule.end_date|date:"M d, Y" }})
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if time_entries_count > 0 %}
<div class="mb-2">
<strong>Time Entries:</strong> {{ time_entries_count }} record(s)
<div class="dependency-list">
<ul class="list-group">
{% for entry in time_entries %}
<li class="list-group-item">
{{ entry.date|date:"M d, Y" }} ({{ entry.hours }} hours)
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if performance_reviews_count > 0 %}
<div class="mb-2">
<strong>Performance Reviews:</strong> {{ performance_reviews_count }} record(s)
<div class="dependency-list">
<ul class="list-group">
{% for review in performance_reviews %}
<li class="list-group-item">
{{ review.review_period }} ({{ review.get_status_display }})
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if training_records_count > 0 %}
<div class="mb-2">
<strong>Training Records:</strong> {{ training_records_count }} record(s)
<div class="dependency-list">
<ul class="list-group">
{% for record in training_records %}
<li class="list-group-item">
{{ record.title }} ({{ record.get_status_display }})
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if leave_requests_count > 0 %}
<div class="mb-2">
<strong>Leave Requests:</strong> {{ leave_requests_count }} record(s)
</div>
{% endif %}
{% if documents_count > 0 %}
<div class="mb-2">
<strong>Documents:</strong> {{ documents_count }} record(s)
</div>
{% endif %}
</div>
{% if is_department_head %}
<div class="alert alert-danger">
<i class="fas fa-exclamation-circle"></i> <strong>Warning:</strong> This employee is currently assigned as a department head. Deleting this record will leave the department without a head.
</div>
{% endif %}
{% if has_active_assignments %}
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle"></i> <strong>Caution:</strong> This employee has active schedule assignments. Deleting this record will affect current scheduling.
</div>
{% endif %}
{% if has_pending_reviews %}
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle"></i> <strong>Caution:</strong> This employee has pending performance reviews. Deleting this record will remove these reviews.
</div>
{% endif %}
</div>
</div>
<!-- Alternative Actions -->
<div class="alternative-action">
<h5>Consider Alternative Actions</h5>
<p>Instead of deleting this employee record, you might want to consider:</p>
<div class="row">
<div class="col-md-6 mb-2">
<a href="{% url 'hr:employee_deactivate' employee.id %}" class="btn btn-warning btn-sm">
<i class="fas fa-user-slash"></i> Deactivate Employee
</a>
</div>
<div class="col-md-6 mb-2">
<a href="{% url 'hr:employee_archive' employee.id %}" class="btn btn-info btn-sm">
<i class="fas fa-archive"></i> Archive Employee
</a>
</div>
<div class="col-md-6 mb-2">
<a href="{% url 'hr:employee_update' employee.id %}" class="btn btn-primary btn-sm">
<i class="fas fa-edit"></i> Update Employee
</a>
</div>
<div class="col-md-6 mb-2">
<a href="{% url 'hr:employee_transfer' employee.id %}" class="btn btn-secondary btn-sm">
<i class="fas fa-exchange-alt"></i> Transfer Employee
</a>
</div>
</div>
</div>
<!-- Delete Form -->
<form method="post">
{% csrf_token %}
<div class="mb-3">
<label for="delete_reason" class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
<textarea class="form-control" id="delete_reason" name="delete_reason" rows="3" required></textarea>
<div class="form-text">Please provide a detailed reason for deleting this employee record.</div>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="confirm_dependencies" name="confirm_dependencies" required>
<label class="form-check-label" for="confirm_dependencies">
I understand that all related records (schedules, time entries, reviews, etc.) will also be deleted.
</label>
</div>
</div>
<div class="mb-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="confirm_delete" name="confirm_delete" required>
<label class="form-check-label" for="confirm_delete">
I understand that this action cannot be undone and all data associated with this employee will be permanently deleted.
</label>
</div>
</div>
<div class="d-flex justify-content-between">
<a href="{% url 'hr:employee_detail' employee.id %}" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Cancel
</a>
<button type="submit" class="btn btn-danger" id="delete_button" disabled>
<i class="fas fa-trash"></i> Delete Employee
</button>
</div>
</form>
</div>
<!-- end panel-body -->
</div>
<!-- end panel -->
</div>
<!-- end col-8 -->
<!-- begin col-4 -->
<div class="col-xl-4">
<!-- Employee Profile -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Employee Profile</h5>
</div>
<div class="card-body text-center">
{% if employee.profile_picture %}
<img src="{{ employee.profile_picture.url }}" alt="{{ employee.get_full_name }}" class="rounded-circle mb-3" width="100" height="100">
{% else %}
<div class="rounded-circle bg-secondary text-white d-flex align-items-center justify-content-center mx-auto mb-3" style="width: 100px; height: 100px; font-size: 2rem;">
{{ employee.get_initials }}
</div>
{% endif %}
<h5>{{ employee.get_full_name }}</h5>
<p class="text-muted">{{ employee.job_title }}</p>
<p class="mb-0">{{ employee.department.name }}</p>
</div>
</div>
<!-- Employment Statistics -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Employment Statistics</h5>
</div>
<div class="card-body">
<div class="mb-2">
<strong>Employment Duration:</strong>
<span class="float-end">{{ employment_duration }}</span>
</div>
<div class="mb-2">
<strong>Total Time Entries:</strong>
<span class="float-end">{{ time_entries_count }}</span>
</div>
<div class="mb-2">
<strong>Total Hours Worked:</strong>
<span class="float-end">{{ total_hours_worked }}</span>
</div>
<div class="mb-2">
<strong>Performance Reviews:</strong>
<span class="float-end">{{ performance_reviews_count }}</span>
</div>
<div class="mb-2">
<strong>Training Records:</strong>
<span class="float-end">{{ training_records_count }}</span>
</div>
<div class="mb-2">
<strong>Leave Requests:</strong>
<span class="float-end">{{ leave_requests_count }}</span>
</div>
<div class="alert alert-info mt-3 mb-0">
<i class="fas fa-info-circle"></i> All this data will be permanently lost if you delete this employee.
</div>
</div>
</div>
</div>
<!-- end col-4 -->
</div>
<!-- end row -->
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
// Enable delete button only when both checkboxes are checked
$('#confirm_dependencies, #confirm_delete').change(function() {
if ($('#confirm_dependencies').is(':checked') && $('#confirm_delete').is(':checked')) {
$('#delete_button').prop('disabled', false);
} else {
$('#delete_button').prop('disabled', true);
}
});
// Form validation
$('form').submit(function(e) {
var deleteReason = $('#delete_reason').val().trim();
if (!deleteReason) {
alert('Please provide a reason for deleting this employee record.');
e.preventDefault();
return false;
}
if (!$('#confirm_dependencies').is(':checked') || !$('#confirm_delete').is(':checked')) {
alert('Please confirm that you understand the consequences of this action.');
e.preventDefault();
return false;
}
return true;
});
});
</script>
{% endblock %}