342 lines
18 KiB
HTML
342 lines
18 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Schedule Assignment - HR{% 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 'hr:dashboard' %}">HR</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'hr:schedule_assignment_list' %}">Schedule Assignments</a></li>
|
|
<li class="breadcrumb-item active">Delete Confirmation</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Schedule Assignment
|
|
<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 Assignment Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">Warning</h6>
|
|
<p class="mb-0">You are about to delete this schedule assignment. This action cannot be undone and will affect time tracking and payroll calculations.</p>
|
|
</div>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<h6>Assignment Details:</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="120">Employee:</td>
|
|
<td>{{ object.employee.get_full_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Employee ID:</td>
|
|
<td>{{ object.employee.employee_id }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Department:</td>
|
|
<td>{{ object.employee.department.name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Schedule:</td>
|
|
<td>{{ object.schedule.name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Schedule Type:</td>
|
|
<td>
|
|
<span class="badge bg-primary">{{ object.schedule.get_schedule_type_display }}</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>Assignment Period:</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="120">Start Date:</td>
|
|
<td>{{ object.start_date|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">End Date:</td>
|
|
<td>{{ object.end_date|date:"M d, Y"|default:"Ongoing" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
<span class="badge bg-{% if object.status == 'ACTIVE' %}success{% elif object.status == 'PENDING' %}warning{% else %}secondary{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Days Active:</td>
|
|
<td>{{ object.days_active }} days</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Assigned By:</td>
|
|
<td>{{ object.assigned_by.get_full_name }}</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>Time Entries:</strong> {{ object.time_entries_count }} time entries will lose their schedule reference</li>
|
|
<li><strong>Payroll:</strong> Historical payroll calculations may be affected</li>
|
|
<li><strong>Attendance:</strong> Attendance tracking for this assignment will be lost</li>
|
|
<li><strong>Reports:</strong> Schedule-based reports may show incomplete data</li>
|
|
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance purposes</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Active Assignment Warning -->
|
|
{% if object.status == 'ACTIVE' %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Active Assignment Warning
|
|
</h6>
|
|
<p class="mb-2">This is an active schedule assignment. Deleting it will:</p>
|
|
<ul class="mb-0">
|
|
<li>Immediately remove the employee from this schedule</li>
|
|
<li>Affect ongoing time tracking and attendance monitoring</li>
|
|
<li>Potentially disrupt current work assignments</li>
|
|
<li>Impact payroll calculations for the current period</li>
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Time Entries Warning -->
|
|
{% if object.time_entries_count > 0 %}
|
|
<div class="alert alert-warning mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-clock me-2"></i>Time Entries Warning
|
|
</h6>
|
|
<p class="mb-0">This assignment has {{ object.time_entries_count }} associated time entries. These entries will remain but will lose their schedule reference, which may affect:</p>
|
|
<ul class="mb-0">
|
|
<li>Overtime calculations</li>
|
|
<li>Schedule compliance reporting</li>
|
|
<li>Performance metrics</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.time_entries_count }}</div>
|
|
<div class="small text-muted">Time Entries</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-success">{{ object.total_hours_worked }}</div>
|
|
<div class="small text-muted">Hours Worked</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.attendance_rate }}%</div>
|
|
<div class="small text-muted">Attendance Rate</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.overtime_hours }}</div>
|
|
<div class="small text-muted">Overtime Hours</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-pause text-warning me-2"></i>
|
|
<a href="{% url 'hr:schedule_assignment_suspend' object.pk %}" class="text-decoration-none">
|
|
Suspend the assignment
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-calendar text-info me-2"></i>
|
|
<a href="{% url 'hr:schedule_assignment_update' object.pk %}" class="text-decoration-none">
|
|
Set an end date
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fa fa-exchange-alt text-primary me-2"></i>
|
|
<a href="{% url 'hr:schedule_assignment_transfer' object.pk %}" class="text-decoration-none">
|
|
Transfer to different schedule
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-archive text-secondary me-2"></i>
|
|
Archive the assignment
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 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 schedule assignment and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
{% if object.status == 'ACTIVE' %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-active" required>
|
|
<label class="form-check-label" for="confirm-active">
|
|
I acknowledge that this is an active assignment and deleting it will immediately affect the employee's schedule
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.time_entries_count > 0 %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-time-entries" required>
|
|
<label class="form-check-label" for="confirm-time-entries">
|
|
I understand that {{ object.time_entries_count }} time entries will lose their schedule reference
|
|
</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="EMPLOYEE_TERMINATED">Employee terminated</option>
|
|
<option value="SCHEDULE_CHANGED">Schedule changed</option>
|
|
<option value="DEPARTMENT_TRANSFER">Department transfer</option>
|
|
<option value="DUPLICATE_ASSIGNMENT">Duplicate assignment</option>
|
|
<option value="ERROR">Created in error</option>
|
|
<option value="REORGANIZATION">Department reorganization</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 assignment is being deleted..."></textarea>
|
|
</div>
|
|
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="notify_employee" id="notify-employee" checked>
|
|
<label class="form-check-label" for="notify-employee">
|
|
Notify employee about schedule assignment removal
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between mt-4">
|
|
<div>
|
|
<a href="{% url 'hr:schedule_assignment_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
<a href="{% url 'hr:schedule_assignment_suspend' object.pk %}" class="btn btn-warning ms-2">
|
|
<i class="fa fa-pause me-2"></i>Suspend Instead
|
|
</a>
|
|
</div>
|
|
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
|
|
<i class="fa fa-trash me-2"></i>Delete Assignment
|
|
</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 delete this schedule assignment for {{ object.employee.get_full_name }}?';
|
|
{% if object.status == 'ACTIVE' %}
|
|
confirmText += '\n\nThis is an ACTIVE assignment and will immediately affect the employee!';
|
|
{% endif %}
|
|
{% if object.time_entries_count > 0 %}
|
|
confirmText += '\n\n{{ object.time_entries_count }} time entries will lose their schedule reference!';
|
|
{% endif %}
|
|
confirmText += '\n\nThis action cannot be undone.';
|
|
|
|
if (!confirm(confirmText)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|