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

379 lines
20 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete Time Entry - 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:time_entry_list' %}">Time Entries</a></li>
<li class="breadcrumb-item active">Delete Confirmation</li>
</ol>
<!-- END breadcrumb -->
<!-- BEGIN page-header -->
<h1 class="page-header">
Delete Time Entry
<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 Time Entry 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 time entry. This action cannot be undone and will affect payroll calculations and attendance records.</p>
</div>
<div class="row mb-4">
<div class="col-md-6">
<h6>Time Entry 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">Date:</td>
<td>{{ object.date|date:"M d, Y" }}</td>
</tr>
<tr>
<td class="fw-bold">Day of Week:</td>
<td>{{ object.date|date:"l" }}</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6>Time Details:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="120">Clock In:</td>
<td>{{ object.clock_in|time:"H:i"|default:"Not recorded" }}</td>
</tr>
<tr>
<td class="fw-bold">Clock Out:</td>
<td>{{ object.clock_out|time:"H:i"|default:"Not recorded" }}</td>
</tr>
<tr>
<td class="fw-bold">Break Duration:</td>
<td>{{ object.break_duration|default:"0" }} minutes</td>
</tr>
<tr>
<td class="fw-bold">Total Hours:</td>
<td class="fw-bold text-primary">{{ object.total_hours|floatformat:2 }} hours</td>
</tr>
<tr>
<td class="fw-bold">Status:</td>
<td>
<span class="badge bg-{% if object.status == 'APPROVED' %}success{% elif object.status == 'PENDING' %}warning{% elif object.status == 'REJECTED' %}danger{% else %}secondary{% endif %}">
{{ object.get_status_display }}
</span>
</td>
</tr>
</table>
</div>
</div>
{% if object.notes %}
<div class="mb-4">
<h6>Entry Notes:</h6>
<div class="bg-light p-3 rounded">
{{ object.notes|linebreaks }}
</div>
</div>
{% endif %}
<!-- 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>Payroll:</strong> This time entry contributes {{ object.total_hours|floatformat:2 }} hours to payroll calculations</li>
<li><strong>Attendance:</strong> Employee's attendance record for {{ object.date|date:"M d, Y" }} will be affected</li>
<li><strong>Overtime:</strong> {% if object.is_overtime %}This entry includes {{ object.overtime_hours|floatformat:2 }} overtime hours{% else %}No overtime impact{% endif %}</li>
<li><strong>Reports:</strong> Time tracking reports and analytics will be updated</li>
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance purposes</li>
</ul>
</div>
<!-- Approved Entry Warning -->
{% if object.status == 'APPROVED' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-check-circle me-2"></i>Approved Entry Warning
</h6>
<p class="mb-2">This time entry has already been approved. Deleting it will:</p>
<ul class="mb-0">
<li>Remove approved hours from payroll calculations</li>
<li>Affect already processed or pending payroll</li>
<li>Require supervisor re-approval if recreated</li>
<li>Impact compliance and audit records</li>
</ul>
</div>
{% endif %}
<!-- Overtime Warning -->
{% if object.is_overtime %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-clock me-2"></i>Overtime Hours Warning
</h6>
<p class="mb-0">This entry includes {{ object.overtime_hours|floatformat:2 }} overtime hours. Deleting it will affect overtime calculations and may impact compliance with labor regulations.</p>
</div>
{% endif %}
<!-- Payroll Period Warning -->
{% if object.in_processed_payroll %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-money-bill me-2"></i>Payroll Period Warning
</h6>
<p class="mb-0">This time entry is part of a payroll period that has already been processed. Deleting it may require payroll adjustments and could affect tax calculations.</p>
</div>
{% endif %}
<!-- Time Entry Statistics -->
<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.total_hours|floatformat:2 }}</div>
<div class="small text-muted">Total Hours</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.regular_hours|floatformat:2 }}</div>
<div class="small text-muted">Regular Hours</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.overtime_hours|floatformat:2 }}</div>
<div class="small text-muted">Overtime Hours</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.calculated_pay|floatformat:2 }}</div>
<div class="small text-muted">Calculated Pay</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-edit text-primary me-2"></i>
<a href="{% url 'hr:time_entry_update' object.pk %}" class="text-decoration-none">
Edit the time entry
</a>
</li>
<li class="mb-2">
<i class="fa fa-times text-danger me-2"></i>
<a href="{% url 'hr:time_entry_reject' object.pk %}" class="text-decoration-none">
Reject the entry
</a>
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-undo text-warning me-2"></i>
<a href="{% url 'hr:time_entry_unapprove' object.pk %}" class="text-decoration-none">
Unapprove the entry
</a>
</li>
<li class="mb-2">
<i class="fa fa-comment text-info me-2"></i>
Add correction notes
</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 time entry and cannot be undone
</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-payroll-impact" required>
<label class="form-check-label" for="confirm-payroll-impact">
I acknowledge that deleting this entry will affect payroll calculations ({{ object.total_hours|floatformat:2 }} hours)
</label>
</div>
{% if object.status == 'APPROVED' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-approved" required>
<label class="form-check-label" for="confirm-approved">
I understand that this is an approved time entry and deleting it may affect processed payroll
</label>
</div>
{% endif %}
{% if object.is_overtime %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-overtime" required>
<label class="form-check-label" for="confirm-overtime">
I acknowledge that this entry includes {{ object.overtime_hours|floatformat:2 }} overtime hours
</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="DUPLICATE_ENTRY">Duplicate entry</option>
<option value="INCORRECT_TIME">Incorrect time recorded</option>
<option value="WRONG_DATE">Wrong date</option>
<option value="EMPLOYEE_ERROR">Employee input error</option>
<option value="SYSTEM_ERROR">System error</option>
<option value="PAYROLL_CORRECTION">Payroll correction</option>
<option value="SUPERVISOR_REQUEST">Supervisor request</option>
<option value="OTHER">Other</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Additional Notes <span class="text-danger">*</span></label>
<textarea class="form-control" name="deletion_notes" rows="3" required
placeholder="Provide detailed explanation for why this time entry is being deleted..."></textarea>
<div class="form-text">Required for audit and compliance purposes</div>
</div>
<div class="row">
<div class="col-md-6">
<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 time entry deletion
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="notify_supervisor" id="notify-supervisor" checked>
<label class="form-check-label" for="notify-supervisor">
Notify supervisor about deletion
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="d-flex justify-content-between mt-4">
<div>
<a href="{% url 'hr:time_entry_detail' object.pk %}" class="btn btn-secondary">
<i class="fa fa-arrow-left me-2"></i>Cancel
</a>
<a href="{% url 'hr:time_entry_update' object.pk %}" class="btn btn-primary ms-2">
<i class="fa fa-edit me-2"></i>Edit Instead
</a>
</div>
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
<i class="fa fa-trash me-2"></i>Delete Time Entry
</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() !== '';
var notesProvided = $('textarea[name="deletion_notes"]').val().trim() !== '';
$('#delete-btn').prop('disabled', !(allChecked && reasonSelected && notesProvided));
}
// Check on checkbox change
$('input[type="checkbox"], select[name="deletion_reason"], textarea[name="deletion_notes"]').on('change input', updateDeleteButton);
// Form submission confirmation
$('#delete-form').on('submit', function(e) {
var confirmText = 'Are you absolutely sure you want to delete this time entry?';
confirmText += '\n\nEmployee: {{ object.employee.get_full_name }}';
confirmText += '\nDate: {{ object.date|date:"M d, Y" }}';
confirmText += '\nHours: {{ object.total_hours|floatformat:2 }}';
{% if object.status == 'APPROVED' %}
confirmText += '\n\nThis is an APPROVED entry!';
{% endif %}
{% if object.is_overtime %}
confirmText += '\nIncludes {{ object.overtime_hours|floatformat:2 }} overtime hours!';
{% endif %}
confirmText += '\n\nThis action cannot be undone and will affect payroll calculations.';
if (!confirm(confirmText)) {
e.preventDefault();
}
});
});
</script>
{% endblock %}