ATS/templates/jobs/job_applications_list.html
2026-02-01 13:38:06 +03:00

347 lines
22 KiB
HTML

{% extends "base.html" %}
{% load static i18n %}
{% block title %}{{ job.title }} - {% trans "Applications" %}{% endblock %}
{% block customCSS %}
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
body { font-family: 'Inter', sans-serif; }
</style>
{% endblock %}
{% block content %}
<div class="container mx-auto px-3 sm:px-4 lg:px-8 py-6">
<!-- Breadcrumb -->
<nav class="mb-6" aria-label="breadcrumb">
<ol class="flex items-center gap-2 text-sm flex-wrap">
<li><a href="{% url 'dashboard' %}" class="text-gray-500 hover:text-temple-red transition flex items-center gap-1">
<i data-lucide="home" class="w-4 h-4"></i> {% trans "Dashboard" %}
</a></li>
<li class="text-gray-400">/</li>
<li><a href="{% url 'job_list' %}" class="text-gray-500 hover:text-temple-red transition">{% trans "Jobs" %}</a></li>
<li class="text-gray-400">/</li>
<li><a href="{% url 'job_detail' job.slug %}" class="text-gray-500 hover:text-temple-red transition">{{ job.title }}</a></li>
<li class="text-gray-400">/</li>
<li class="text-temple-red font-semibold">{% trans "Applications" %}</li>
</ol>
</nav>
<!-- Header -->
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-4 mb-6">
<div class="text-gray-900">
<h1 class="text-2xl font-bold mb-1 flex items-center gap-3">
<a href="{% url 'job_detail' job.slug %}" class="text-temple-red hover:text-[#7a1a29] transition">
<i data-lucide="arrow-left" class="w-6 h-6"></i>
</a>
<span>{% trans "Applicants for" %} "{{ job.title }}"</span>
</h1>
</div>
<a href="{% url 'application_create_for_job' job.slug %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-4 py-2.5 rounded-xl text-sm transition shadow-sm hover:shadow-md whitespace-nowrap">
<i data-lucide="user-plus" class="w-4 h-4"></i>
{% trans "Add New Applicant" %}
</a>
</div>
<!-- Job Info Card -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 mb-6 overflow-hidden">
<div class="p-6">
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-4">
<div class="flex-1">
<h3 class="text-lg font-bold text-temple-red mb-3">{{ job.title }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
<div class="flex items-center gap-2 text-gray-600">
<i data-lucide="building-2" class="w-4 h-4 text-temple-red"></i>
<span><strong>{% trans "Department:" %}</strong> {{ job.department|default:"N/A" }}</span>
</div>
<div class="flex items-center gap-2 text-gray-600">
<i data-lucide="map-pin" class="w-4 h-4 text-temple-red"></i>
<span><strong>{% trans "Location:" %}</strong> {{ job.get_location_display }}</span>
</div>
<div class="flex items-center gap-2 text-gray-600">
<i data-lucide="briefcase" class="w-4 h-4 text-temple-red"></i>
<span><strong>{% trans "Job Type:" %}</strong> {{ job.get_job_type_display }}</span>
</div>
<div class="flex items-center gap-2 text-gray-600">
<i data-lucide="globe" class="w-4 h-4 text-temple-red"></i>
<span><strong>{% trans "Workplace:" %}</strong> {{ job.get_workplace_type_display }}</span>
</div>
</div>
</div>
<div class="md:border-l md:pl-4 text-center md:text-end">
<span class="inline-flex items-center px-3 py-1.5 rounded-full text-xs font-bold uppercase tracking-wide
{% if job.status == 'ACTIVE' %}bg-emerald-500 text-white
{% elif job.status == 'DRAFT' or job.status == 'ARCHIVED' %}bg-gray-500 text-white
{% elif job.status == 'CLOSED' %}bg-amber-500 text-white
{% else %}bg-red-500 text-white{% endif %}">
{{ job.get_status_display }}
</span>
{% if candidates %}
<div class="mt-3">
<p class="text-xs text-gray-500 mb-1">{% trans "Total Applicants" %}:</p>
<h3 class="text-3xl font-bold text-temple-red">{{ candidates.count }}</h3>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Filter Section -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-6 mb-6">
<form method="get">
<div class="flex flex-col md:flex-row gap-4">
<div class="flex-1">
<label for="search" class="block text-sm font-semibold text-gray-700 mb-2">{% trans "Search Applicants" %}</label>
<div class="relative">
<i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"></i>
<input type="text" class="w-full pl-10 pr-4 py-2.5 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition"
id="search" name="search"
placeholder="{% trans 'Search by name, email, phone, or stage...' %}"
value="{{ search_query }}">
</div>
</div>
<div class="flex items-end gap-3">
<button type="submit" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-6 py-2.5 rounded-xl text-sm transition shadow-sm hover:shadow-md">
<i data-lucide="filter" class="w-4 h-4"></i>
{% trans "Filter Results" %}
</button>
<a href="{% url 'job_applications_list' job.slug %}" class="inline-flex items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium px-6 py-2.5 rounded-xl text-sm transition">
<i data-lucide="x" class="w-4 h-4"></i>
{% trans "Clear Filters" %}
</a>
</div>
</div>
</form>
</div>
{% if candidates %}
<div id="job-candidates-list">
<!-- Table View (Default) -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="flex flex-col md:flex-row md:items-center md:justify-between p-4 border-b border-gray-200 gap-3">
<h5 class="text-base font-bold text-gray-900">{% trans "Applicants" %} ({{ candidates.count }})</h5>
<div class="flex items-center gap-3">
<select class="px-3 py-2 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition"
onchange="window.location.href='?stage='+this.value+'&search={{ search_query }}'">
<option value="">{% trans "All Stages" %}</option>
<option value="Applied" {% if request.GET.stage == 'Applied' %}selected{% endif %}>{% trans "Applied" %}</option>
<option value="Exam" {% if request.GET.stage == 'Exam' %}selected{% endif %}>{% trans "Exam" %}</option>
<option value="Interview" {% if request.GET.stage == 'Interview' %}selected{% endif %}>{% trans "Interview" %}</option>
<option value="Offer" {% if request.GET.stage == 'Offer' %}selected{% endif %}>{% trans "Offer" %}</option>
</select>
</div>
</div>
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
<input type="checkbox" id="selectAll" class="rounded border-gray-300">
</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Name" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Email" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Phone" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Stage" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Applied Date" %}</th>
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-600 uppercase tracking-wider">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{% for candidate in candidates %}
<tr class="hover:bg-gray-50 transition">
<td class="px-4 py-3">
<input type="checkbox" class="candidate-checkbox rounded border-gray-300" value="{{ candidate.slug }}">
</td>
<td class="px-4 py-3">
<strong class="text-temple-red">{{ candidate.first_name }} {{ candidate.last_name }}</strong>
</td>
<td class="px-4 py-3 text-sm text-gray-600">{{ candidate.email }}</td>
<td class="px-4 py-3 text-sm text-gray-600">{{ candidate.phone|default:"-" }}</td>
<td class="px-4 py-3">
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold uppercase tracking-wide
{% if candidate.stage == 'Applied' %}bg-temple-red text-white
{% elif candidate.stage == 'Exam' %}bg-cyan-500 text-white
{% elif candidate.stage == 'Interview' %}bg-amber-500 text-white
{% elif candidate.stage == 'Offer' %}bg-emerald-500 text-white
{% else %}bg-gray-500 text-white{% endif %}">
{{ candidate.stage }}
</span>
</td>
<td class="px-4 py-3 text-sm text-gray-500">{{ candidate.created_at|date:"M d, Y" }}</td>
<td class="px-4 py-3 text-center">
<div class="flex items-center justify-center gap-2">
<a href="{% url 'application_detail' candidate.slug %}" class="p-2 text-gray-400 hover:text-temple-red transition" title="{% trans 'View' %}">
<i data-lucide="eye" class="w-4 h-4"></i>
</a>
{% if user.is_staff %}
<a href="{% url 'application_update' candidate.slug %}" class="p-2 text-gray-400 hover:text-temple-red transition" title="{% trans 'Edit' %}">
<i data-lucide="edit-2" class="w-4 h-4"></i>
</a>
<button type="button" class="p-2 text-gray-400 hover:text-red-500 transition" title="{% trans 'Delete' %}"
onclick="showDeleteModal('{% url 'application_delete' candidate.slug %}', '{{ candidate.first_name }} {{ candidate.last_name }}')">
<i data-lucide="trash-2" class="w-4 h-4"></i>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Footer with bulk actions and pagination -->
<div class="flex flex-col md:flex-row md:items-center md:justify-between p-4 border-t border-gray-200 bg-gray-50 gap-4">
<div class="flex items-center gap-3">
<span class="text-sm text-gray-600">{% trans "Selected" %}: <strong id="selectedCount">0</strong></span>
<button class="inline-flex items-center gap-2 bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium px-3 py-2 rounded-lg text-sm transition
{% if not user.is_staff %}opacity-50 cursor-not-allowed{% endif %}"
onclick="bulkAction('Interview')" {% if not user.is_staff %}disabled{% endif %}>
<i data-lucide="message-square" class="w-4 h-4"></i>
{% trans "Mark Interview" %}
</button>
<button class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-3 py-2 rounded-lg text-sm transition shadow-sm
{% if not user.is_staff %}opacity-50 cursor-not-allowed{% endif %}"
onclick="bulkAction('Offer')" {% if not user.is_staff %}disabled{% endif %}>
<i data-lucide="handshake" class="w-4 h-4"></i>
{% trans "Mark Offer" %}
</button>
</div>
{% if is_paginated %}
<nav aria-label="Page navigation">
<ul class="flex items-center gap-1">
{% if page_obj.has_previous %}
<li>
<a class="px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-temple-red hover:text-white hover:border-temple-red transition"
href="?page={{ page_obj.previous_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}" aria-label="Previous">
<i data-lucide="chevron-left" class="w-4 h-4"></i>
</a>
</li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<li>
<span class="px-3 py-2 bg-temple-red text-white border border-temple-red rounded-lg text-sm">{{ num }}</span>
</li>
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
<li>
<a class="px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-temple-red hover:text-white hover:border-temple-red transition"
href="?page={{ num }}{% if search_query %}&search={{ search_query }}{% endif %}">{{ num }}</a>
</li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li>
<a class="px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-temple-red hover:text-white hover:border-temple-red transition"
href="?page={{ page_obj.next_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}" aria-label="Next">
<i data-lucide="chevron-right" class="w-4 h-4"></i>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
</div>
</div>
{% else %}
<!-- No Results -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-12 text-center">
<i data-lucide="user-x" class="w-16 h-16 text-gray-300 mx-auto mb-4"></i>
<h3 class="text-xl font-bold text-gray-900 mb-2">{% trans "No applicants found" %}</h3>
<p class="text-gray-500 mb-6">{% trans "There are no candidates who have applied for this position yet." %}</p>
<a href="{% url 'application_create_for_job' job.slug %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-6 py-3 rounded-xl text-sm transition shadow-sm hover:shadow-md">
<i data-lucide="user-plus" class="w-5 h-5"></i>
{% trans "Add First Applicant" %}
</a>
</div>
{% endif %}
<!-- Delete Modal -->
<div id="deleteModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 hidden flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-xl max-w-md w-full">
<div class="p-6 text-center">
<div class="bg-red-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i data-lucide="alert-triangle" class="w-8 h-8 text-red-600"></i>
</div>
<h3 class="text-lg font-bold text-gray-900 mb-2" id="modalTitle">{% trans "Delete Applicant" %}</h3>
<p class="text-gray-600 mb-6" id="modalBody">{% trans "Are you sure you want to delete this applicant?" %}</p>
<div class="flex gap-3">
<button type="button" onclick="document.getElementById('deleteModal').classList.add('hidden')"
class="flex-1 inline-flex items-center justify-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium px-4 py-2.5 rounded-xl text-sm transition">
{% trans "Cancel" %}
</button>
<form id="deleteForm" method="post">
{% csrf_token %}
<button type="submit" class="flex-1 inline-flex items-center justify-center gap-2 bg-red-500 hover:bg-red-600 text-white font-medium px-4 py-2.5 rounded-xl text-sm transition shadow-sm">
<i data-lucide="trash-2" class="w-4 h-4"></i>
{% trans "Delete" %}
</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block customJS %}
<script>
lucide.createIcons();
// Select all checkbox functionality
const selectAll = document.getElementById('selectAll');
if (selectAll) {
selectAll.addEventListener('change', function() {
const checkboxes = document.querySelectorAll('.candidate-checkbox');
checkboxes.forEach(checkbox => {
checkbox.checked = this.checked;
});
updateSelectedCount();
});
}
// Individual checkbox change
document.querySelectorAll('.candidate-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', updateSelectedCount);
});
function updateSelectedCount() {
const checkedBoxes = document.querySelectorAll('.candidate-checkbox:checked');
document.getElementById('selectedCount').textContent = checkedBoxes.length;
}
function bulkAction(stage) {
const selectedCandidates = Array.from(document.querySelectorAll('.candidate-checkbox:checked'))
.map(cb => cb.value);
if (selectedCandidates.length === 0) {
alert('{% trans "Please select at least one candidate." %}');
return;
}
if (confirm(`Mark ${selectedCandidates.length} candidate(s) as ${stage}?`)) {
console.log('Updating candidates:', selectedCandidates, 'to stage:', stage);
alert(`Bulk update functionality would mark ${selectedCandidates.length} candidates as ${stage}`);
}
}
function showDeleteModal(deleteUrl, itemName) {
const modal = document.getElementById('deleteModal');
const modalTitle = document.getElementById('modalTitle');
const modalBody = document.getElementById('modalBody');
const deleteForm = document.getElementById('deleteForm');
modalTitle.textContent = `{% trans "Delete" %} ${itemName}`;
modalBody.innerHTML = `{% trans "Are you sure you want to permanently delete applicant" %} <strong>${itemName}</strong>? {% trans "This action cannot be undone." %}`;
deleteForm.action = deleteUrl;
modal.classList.remove('hidden');
}
</script>
{% endblock %}