Files
arrr-erp/app/modules/employees/templates/employees/portal_dashboard.html
T
2026-07-05 21:24:50 +05:30

115 lines
5.2 KiB
HTML

{% extends "ui/templates/base/layout.html" %}
{% block content %}
<div class="space-y-6" id="employee-portal-root">
<section class="overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-soft">
<div class="bg-gradient-to-r from-brand-700 via-brand-600 to-slate-900 px-6 py-6 text-white">
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
<div>
<p class="text-xs font-semibold uppercase tracking-[0.22em] text-brand-100">My Workspace</p>
<h2 class="mt-2 text-2xl font-semibold">Employee Portal</h2>
<p class="mt-2 max-w-3xl text-sm text-brand-100">Punch attendance, view priority work, track documents, leave, payslips and alerts from one staff workspace.</p>
</div>
<div class="flex flex-wrap gap-2">
{% if employee %}
<a href="/employee/attendance" class="rounded-xl bg-white px-4 py-2 text-sm font-semibold text-brand-700 hover:bg-brand-50">Punch / Attendance</a>
<a href="/employee/work" class="rounded-xl border border-white/40 px-4 py-2 text-sm font-semibold text-white hover:bg-white/10">Open Work Board</a>
{% else %}
<a href="/employee/register" class="rounded-xl bg-white px-4 py-2 text-sm font-semibold text-brand-700 hover:bg-brand-50">Request Employee Linkage</a>
{% endif %}
</div>
</div>
</div>
</section>
{% set tabs = [
('overview','Overview'),
('work','My Work Board'),
('due-today','Due Today'),
('overdue','Overdue'),
('client-pending','Client Pending'),
('returned','Returned / Blocked'),
('attendance','My Attendance'),
('profile','My Profile'),
('leave','My Leave'),
('documents','My Documents'),
('payslips','My Payslips'),
('offboarding','My Offboarding'),
('alerts','My Alert'),
('reports','My Reports')
] %}
<section class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
<div class="mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-slate-500">My Workspace</div>
<div class="overflow-x-auto pb-1">
<div class="flex min-w-max flex-nowrap gap-2" id="employee-portal-tabs">
{% for code, label in tabs %}
<button type="button" data-tab="{{ code }}" class="employee-portal-tab inline-flex shrink-0 items-center rounded-xl px-3 py-2 text-sm font-semibold whitespace-nowrap transition {% if active_tab == code %}bg-brand-600 text-white shadow-soft{% else %}border border-slate-300 bg-white text-slate-700 hover:bg-slate-50{% endif %}">
{{ label }}{% if code == 'alerts' and unread_alert_count is defined and unread_alert_count > 0 %}<span class="ml-2 rounded-full bg-white/20 px-2 py-0.5 text-[10px]">{{ unread_alert_count }}</span>{% endif %}
</button>
{% endfor %}
</div>
</div>
</section>
<section id="employee-portal-panel" class="space-y-6">
{% include "modules/employees/templates/employees/portal_partials/overview.html" %}
</section>
</div>
<script>
(function () {
const panel = document.getElementById('employee-portal-panel');
const tabs = Array.from(document.querySelectorAll('.employee-portal-tab'));
if (!panel || !tabs.length) return;
function setActive(tabName) {
tabs.forEach(function (button) {
const active = button.dataset.tab === tabName;
button.classList.toggle('bg-brand-600', active);
button.classList.toggle('text-white', active);
button.classList.toggle('shadow-soft', active);
button.classList.toggle('border', !active);
button.classList.toggle('border-slate-300', !active);
button.classList.toggle('bg-white', !active);
button.classList.toggle('text-slate-700', !active);
button.classList.toggle('hover:bg-slate-50', !active);
});
}
async function loadTab(tabName, pushState) {
setActive(tabName);
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
try {
const response = await fetch('/employee/dashboard/tab/' + encodeURIComponent(tabName), {
headers: {'X-Requested-With': 'fetch'}
});
if (!response.ok) throw new Error('HTTP ' + response.status);
panel.innerHTML = await response.text();
if (pushState) {
const url = new URL(window.location.href);
url.searchParams.set('tab', tabName);
window.history.pushState({tab: tabName}, '', url.toString());
}
if (window.EmployeePortalGeo && typeof window.EmployeePortalGeo.bind === 'function') {
window.EmployeePortalGeo.bind();
}
} catch (error) {
panel.innerHTML = '<div class="rounded-3xl border border-red-200 bg-red-50 p-8 text-center text-sm text-red-700 shadow-soft">Unable to load tab. Please refresh the page.</div>';
}
}
document.addEventListener('click', function (event) {
const button = event.target.closest('.employee-portal-tab');
if (!button || !button.dataset.tab) return;
event.preventDefault();
loadTab(button.dataset.tab || 'overview', true);
});
window.addEventListener('popstate', function (event) {
const params = new URLSearchParams(window.location.search);
loadTab((event.state && event.state.tab) || params.get('tab') || 'overview', false);
});
})();
</script>
{% endblock %}