feat: tambah fitur impor excel karyawan hse, perapian sidebar pg, dan bel notifikasi suara asisten verifikasi gerbang
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Matriks Role & Permission (RBAC) - Super Admin RKM')
|
||||
@section('title', 'Matriks Peran & Hak Akses Pengguna - Super Admin | PT Kerinci Merangin Hidro')
|
||||
|
||||
@section('content')
|
||||
<div class="space-y-6">
|
||||
@@ -9,10 +9,10 @@
|
||||
<div>
|
||||
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
||||
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
||||
Matriks Role & Hak Akses (RBAC)
|
||||
Matriks Peran & Hak Akses Pengguna
|
||||
</h1>
|
||||
<p class="text-xs text-slate-500 mt-1">
|
||||
Konfigurasi izin wewenang (permissions) untuk setiap role pengguna menggunakan paket Spatie Laravel Permission.
|
||||
Atur wewenang dan batasan menu untuk setiap jabatan atau peran pengguna di lingkungan PT Kerinci Merangin Hidro.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2.5">
|
||||
@@ -61,9 +61,9 @@
|
||||
<i class="fa-solid fa-crown"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="font-bold text-indigo-950">Privilese Khusus Super Administrator (Gate::before Bypass)</h2>
|
||||
<h2 class="font-bold text-indigo-950">Hak Akses Penuh Super Administrator</h2>
|
||||
<p class="text-indigo-800/80 mt-0.5 leading-relaxed">
|
||||
Role <strong>super_admin</strong> secara otomatis memiliki hak akses tak terbatas ke seluruh modul sistem (HSE, QMA, PG, dan Pengaturan RBAC) melalui interceptor gerbang Laravel. Matriks centang di bawah ini berlaku aktif untuk role operasional lainnya.
|
||||
Akun dengan peran <strong>Super Administrator</strong> secara otomatis memiliki akses penuh ke seluruh menu dan modul sistem tanpa batasan. Pilihan centang di bawah ini digunakan untuk mengatur batasan akses pada peran staf operasional lainnya.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,16 +94,16 @@
|
||||
<i class="fa-solid fa-trash-can text-xs"></i>
|
||||
</button>
|
||||
@else
|
||||
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Core</span>
|
||||
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Peran Utama</span>
|
||||
@endif
|
||||
</div>
|
||||
<h2 class="text-xs font-bold text-slate-800 capitalize">{{ str_replace('_', ' ', $role->name) }}</h2>
|
||||
<p class="text-[10px] text-slate-400 mt-0.5 font-mono">{{ $role->name }}</p>
|
||||
</div>
|
||||
<div class="mt-3 pt-2.5 border-t border-slate-100 flex items-center justify-between text-[11px]">
|
||||
<span class="text-slate-500">Izin Aktif:</span>
|
||||
<span class="text-slate-500">Jumlah Hak Akses:</span>
|
||||
<span class="font-bold text-indigo-700">
|
||||
{{ $role->name === 'super_admin' ? 'Semua' : $role->permissions->count() }}
|
||||
{{ $role->name === 'super_admin' ? 'Akses Lengkap' : $role->permissions->count() . ' Izin' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,12 +121,12 @@
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-sm font-bold text-slate-900 capitalize flex items-center gap-2">
|
||||
<span>Role: {{ str_replace('_', ' ', $role->name) }}</span>
|
||||
<span>Peran: {{ str_replace('_', ' ', $role->name) }}</span>
|
||||
@if($role->name === 'super_admin')
|
||||
<span class="px-2 py-0.5 rounded-full text-[9px] font-black bg-indigo-100 text-indigo-800">UNRESTRICTED</span>
|
||||
<span class="px-2 py-0.5 rounded-full text-[9px] font-black bg-indigo-100 text-indigo-800">AKSES LENGKAP</span>
|
||||
@endif
|
||||
</h2>
|
||||
<p class="text-[11px] text-slate-400">Atur centang hak akses yang diizinkan untuk peran pengguna ini.</p>
|
||||
<p class="text-[11px] text-slate-400">Atur centang hak akses menu yang diizinkan untuk peran pengguna ini.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
<i class="{{ $module['icon'] }} text-indigo-600 text-xs"></i>
|
||||
<span>{{ $module['name'] }}</span>
|
||||
</span>
|
||||
<span class="text-[10px] text-slate-400 font-semibold">{{ count($module['permissions']) }} izin</span>
|
||||
<span class="text-[10px] text-slate-400 font-semibold">{{ count($module['permissions']) }} hak akses</span>
|
||||
</h3>
|
||||
|
||||
<div class="space-y-2">
|
||||
|
||||
@@ -66,9 +66,13 @@
|
||||
|
||||
<!-- Card Filter & Pencarian -->
|
||||
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm">
|
||||
<form method="GET" action="{{ route('admin.users.index') }}" class="flex flex-col sm:flex-row gap-3">
|
||||
<form id="usersFilterForm" method="GET" action="{{ route('admin.users.index') }}" class="flex flex-col sm:flex-row gap-3 items-stretch sm:items-center">
|
||||
<input type="hidden" name="sort" id="userSortInput" value="{{ request('sort', 'latest') }}">
|
||||
|
||||
<div class="flex-1 relative">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<button type="submit" class="absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-indigo-600 transition text-xs" title="Cari pengguna">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</button>
|
||||
<input type="text"
|
||||
name="search"
|
||||
value="{{ request('search') }}"
|
||||
@@ -77,7 +81,7 @@
|
||||
</div>
|
||||
|
||||
<div class="w-full sm:w-48">
|
||||
<select name="role" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition">
|
||||
<select name="role" onchange="document.getElementById('usersFilterForm').submit()" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition cursor-pointer">
|
||||
<option value="">-- Semua Role --</option>
|
||||
@foreach($roles as $role)
|
||||
<option value="{{ $role->name }}" {{ request('role') === $role->name ? 'selected' : '' }}>
|
||||
@@ -87,14 +91,89 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<button type="submit" class="px-4 py-2 bg-slate-800 hover:bg-slate-900 text-white rounded-xl text-xs font-bold transition flex items-center gap-2">
|
||||
<i class="fa-solid fa-filter"></i>
|
||||
<span>Filter</span>
|
||||
<!-- Tombol Menu Urutkan (Sorting Popover) -->
|
||||
<div class="relative flex items-center gap-2" id="sortDropdownContainer">
|
||||
@php
|
||||
$currentSort = request('sort', 'latest');
|
||||
$sortLabels = [
|
||||
'latest' => 'Terbaru',
|
||||
'oldest' => 'Terlama',
|
||||
'name_asc' => 'Nama (A-Z)',
|
||||
'name_desc' => 'Nama (Z-A)',
|
||||
];
|
||||
$activeSortLabel = $sortLabels[$currentSort] ?? 'Terbaru';
|
||||
$isCustomSort = $currentSort !== 'latest';
|
||||
@endphp
|
||||
|
||||
<button type="button"
|
||||
id="sortDropdownBtn"
|
||||
onclick="toggleSortDropdown()"
|
||||
class="w-full sm:w-auto px-3.5 py-2 {{ $isCustomSort ? 'bg-indigo-50 border-indigo-200 text-indigo-700 shadow-sm' : 'bg-slate-800 hover:bg-slate-900 text-white' }} border rounded-xl text-xs font-bold transition flex items-center justify-between sm:justify-start gap-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<i class="fa-solid fa-arrow-down-wide-short {{ $isCustomSort ? 'text-indigo-600' : 'text-slate-300' }}"></i>
|
||||
<span>Urutkan: <strong class="{{ $isCustomSort ? 'text-indigo-800 font-black' : 'text-white' }}">{{ $activeSortLabel }}</strong></span>
|
||||
</div>
|
||||
<i id="sortDropdownChevron" class="fa-solid fa-chevron-down text-[10px] {{ $isCustomSort ? 'text-indigo-500' : 'text-slate-300' }} transition-transform duration-200"></i>
|
||||
</button>
|
||||
@if(request()->hasAny(['search', 'role']))
|
||||
<a href="{{ route('admin.users.index') }}" class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-semibold transition" title="Reset Filter">
|
||||
|
||||
<!-- Menu Popover Dropdown Urutkan -->
|
||||
<div id="sortDropdownMenu"
|
||||
class="hidden absolute right-0 top-full mt-2 w-56 bg-white border border-slate-200 rounded-2xl shadow-xl z-30 py-2 divide-y divide-slate-100 animate-scale-in">
|
||||
<div class="px-3 py-1.5 text-[10px] font-bold text-slate-400 uppercase tracking-wider">
|
||||
Kriteria Pengurutan
|
||||
</div>
|
||||
<div class="py-1">
|
||||
<button type="button"
|
||||
onclick="applyUserSort('latest')"
|
||||
class="w-full px-3.5 py-2 text-left text-xs flex items-center justify-between hover:bg-slate-50 transition {{ $currentSort === 'latest' ? 'text-indigo-600 font-bold bg-indigo-50/50' : 'text-slate-700 font-medium' }}">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-solid fa-clock-rotate-left text-slate-400 text-[11px]"></i>
|
||||
<span>Terdaftar Terbaru</span>
|
||||
</span>
|
||||
@if($currentSort === 'latest')
|
||||
<i class="fa-solid fa-check text-indigo-600 text-[10px]"></i>
|
||||
@endif
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="applyUserSort('oldest')"
|
||||
class="w-full px-3.5 py-2 text-left text-xs flex items-center justify-between hover:bg-slate-50 transition {{ $currentSort === 'oldest' ? 'text-indigo-600 font-bold bg-indigo-50/50' : 'text-slate-700 font-medium' }}">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-regular fa-clock text-slate-400 text-[11px]"></i>
|
||||
<span>Terdaftar Terlama</span>
|
||||
</span>
|
||||
@if($currentSort === 'oldest')
|
||||
<i class="fa-solid fa-check text-indigo-600 text-[10px]"></i>
|
||||
@endif
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="applyUserSort('name_asc')"
|
||||
class="w-full px-3.5 py-2 text-left text-xs flex items-center justify-between hover:bg-slate-50 transition {{ $currentSort === 'name_asc' ? 'text-indigo-600 font-bold bg-indigo-50/50' : 'text-slate-700 font-medium' }}">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-solid fa-arrow-down-a-z text-slate-400 text-[11px]"></i>
|
||||
<span>Nama Pengguna (A → Z)</span>
|
||||
</span>
|
||||
@if($currentSort === 'name_asc')
|
||||
<i class="fa-solid fa-check text-indigo-600 text-[10px]"></i>
|
||||
@endif
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="applyUserSort('name_desc')"
|
||||
class="w-full px-3.5 py-2 text-left text-xs flex items-center justify-between hover:bg-slate-50 transition {{ $currentSort === 'name_desc' ? 'text-indigo-600 font-bold bg-indigo-50/50' : 'text-slate-700 font-medium' }}">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-solid fa-arrow-down-z-a text-slate-400 text-[11px]"></i>
|
||||
<span>Nama Pengguna (Z → A)</span>
|
||||
</span>
|
||||
@if($currentSort === 'name_desc')
|
||||
<i class="fa-solid fa-check text-indigo-600 text-[10px]"></i>
|
||||
@endif
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(request()->anyFilled(['search', 'role']) || request('sort', 'latest') !== 'latest')
|
||||
<a href="{{ route('admin.users.index') }}" class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-semibold transition flex items-center gap-1.5" title="Reset Filter & Urutan">
|
||||
<i class="fa-solid fa-arrow-rotate-left"></i>
|
||||
<span class="hidden sm:inline">Reset</span>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
@@ -486,5 +565,37 @@
|
||||
document.getElementById('deleteUserModal').classList.add('hidden');
|
||||
document.documentElement.classList.remove('modal-open');
|
||||
}
|
||||
|
||||
function toggleSortDropdown() {
|
||||
const menu = document.getElementById('sortDropdownMenu');
|
||||
const chevron = document.getElementById('sortDropdownChevron');
|
||||
if (menu) {
|
||||
menu.classList.toggle('hidden');
|
||||
}
|
||||
if (chevron) {
|
||||
chevron.classList.toggle('rotate-180');
|
||||
}
|
||||
}
|
||||
|
||||
function applyUserSort(sortValue) {
|
||||
const sortInput = document.getElementById('userSortInput');
|
||||
const form = document.getElementById('usersFilterForm');
|
||||
if (sortInput && form) {
|
||||
sortInput.value = sortValue;
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(e) {
|
||||
const container = document.getElementById('sortDropdownContainer');
|
||||
const menu = document.getElementById('sortDropdownMenu');
|
||||
const chevron = document.getElementById('sortDropdownChevron');
|
||||
if (container && menu && !container.contains(e.target)) {
|
||||
menu.classList.add('hidden');
|
||||
if (chevron) {
|
||||
chevron.classList.remove('rotate-180');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -50,11 +50,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
|
||||
<!-- Tombol Tambah & Impor Karyawan (Diatur Hak Akses hse.employees.create) -->
|
||||
@can('hse.employees.create')
|
||||
<button type="button"
|
||||
onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
|
||||
class="w-full sm:w-auto flex-1 sm:flex-none bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm cursor-pointer">
|
||||
onclick="openImportKaryawanModal()"
|
||||
class="w-full sm:w-auto flex-1 sm:flex-none border border-emerald-600/30 text-emerald-800 bg-emerald-50/60 hover:bg-emerald-100/70 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm cursor-pointer"
|
||||
title="Impor Data Karyawan secara Massal dari File Excel / CSV">
|
||||
<i class="fa-solid fa-file-arrow-up text-emerald-700 text-sm"></i>
|
||||
<span class="truncate">Impor Data</span>
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="openAddKaryawanModal()"
|
||||
class="w-full sm:w-auto flex-1 sm:flex-none bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm cursor-pointer"
|
||||
title="Tambah Karyawan Baru Secara Manual">
|
||||
<i class="fa-solid fa-plus text-xs"></i>
|
||||
<span class="truncate">Tambah Karyawan</span>
|
||||
</button>
|
||||
@@ -138,7 +146,7 @@
|
||||
@endphp
|
||||
<tr class="simper-row hover:bg-slate-50/70 transition">
|
||||
<!-- Nomor -->
|
||||
<td class="py-3.5 px-4 text-center font-medium text-slate-400">{{ $index + 1 }}</td>
|
||||
<td class="py-3.5 px-4 text-center font-medium text-slate-400">{{ $employees->firstItem() ? ($employees->firstItem() + $index) : ($index + 1) }}</td>
|
||||
|
||||
<!-- NIK (Font Bold Hitam Tegas) -->
|
||||
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs">{{ $emp->nik }}</td>
|
||||
@@ -247,6 +255,177 @@
|
||||
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: TAMBAH KARYAWAN MANUAL -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-slate-900 tracking-tight flex items-center gap-2">
|
||||
<i class="fa-solid fa-user-plus text-[#1b5e20]"></i>
|
||||
<span>Tambah Data Karyawan</span>
|
||||
</h3>
|
||||
<p class="text-xs text-slate-500 mt-0.5">Daftarkan karyawan baru beserta informasi SIMPER jika pengemudi.</p>
|
||||
</div>
|
||||
<button type="button" onclick="closeAddKaryawanModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<i class="fa-solid fa-xmark text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="{{ route('hse.employees.store') }}" method="POST" class="mt-5 space-y-4">
|
||||
@csrf
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">NIK (Nomor Induk Karyawan) <span class="text-rose-500">*</span></label>
|
||||
<input type="text" name="nik" required placeholder="Contoh: KMH-2026-101"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nama Lengkap <span class="text-rose-500">*</span></label>
|
||||
<input type="text" name="name" required placeholder="Contoh: Muhammad Rizki"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Unit Kerja <span class="text-rose-500">*</span></label>
|
||||
<select name="unit_kerja" required class="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
<option value="Pembangkit">Pembangkit</option>
|
||||
<option value="Bendungan">Bendungan</option>
|
||||
<option value="Teknik">Teknik</option>
|
||||
<option value="Umum" selected>Umum</option>
|
||||
<option value="Logistik">Logistik</option>
|
||||
<option value="HSE">HSE</option>
|
||||
<option value="QMA">QMA</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi <span class="text-rose-500">*</span></label>
|
||||
<input type="text" name="division" required placeholder="Contoh: Operasi"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Posisi / Jabatan <span class="text-rose-500">*</span></label>
|
||||
<input type="text" name="position" required placeholder="Contoh: Driver"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5 pt-1">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Operator / Driver <span class="text-rose-500">*</span></label>
|
||||
<select name="is_operator" id="addOperatorSelect" onchange="toggleAddSimperDate(this.value)" required
|
||||
class="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
<option value="1">YA (Aktif Mengemudi)</option>
|
||||
<option value="0">TIDAK (Bukan Driver)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="addSimperDateWrapper">
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">Masa Berlaku SIMPER</label>
|
||||
<input type="date" name="simper_expired_at" id="addSimperDateInput"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-5 border-t border-slate-100 flex items-center justify-end gap-2.5 mt-5">
|
||||
<button type="button" onclick="closeAddKaryawanModal()" class="px-4 py-2.5 rounded-xl border border-slate-200 bg-slate-100 hover:bg-slate-200 text-slate-600 font-bold text-xs transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit" class="px-5 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
|
||||
Simpan Karyawan
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: IMPOR DATA KARYAWAN EXCEL -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="importKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-slate-900 tracking-tight flex items-center gap-2">
|
||||
<i class="fa-solid fa-file-excel text-emerald-600"></i>
|
||||
<span>Impor Data Karyawan via Excel</span>
|
||||
</h3>
|
||||
<p class="text-xs text-slate-500 mt-0.5">Unggah data karyawan secara massal menggunakan file Excel (.xlsx) atau CSV (.csv).</p>
|
||||
</div>
|
||||
<button type="button" onclick="closeImportKaryawanModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<i class="fa-solid fa-xmark text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Banner Unduh Template -->
|
||||
<div class="mt-4 bg-emerald-50/70 border border-emerald-200/80 rounded-2xl p-4 flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-xl bg-emerald-100 text-emerald-700 flex items-center justify-center text-lg flex-shrink-0">
|
||||
<i class="fa-regular fa-file-excel"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs font-bold text-emerald-950">Unduh Format Template</p>
|
||||
<p class="text-[11px] text-emerald-700">Format kolom resmi agar data dapat diproses otomatis tanpa kendala.</p>
|
||||
</div>
|
||||
</div>
|
||||
<a href="{{ route('hse.employees.import_template') }}"
|
||||
class="px-3 py-2 bg-emerald-700 hover:bg-emerald-800 text-white rounded-xl text-xs font-bold transition flex items-center gap-1.5 flex-shrink-0 shadow-xs"
|
||||
title="Unduh Template Excel">
|
||||
<i class="fa-solid fa-download text-[11px]"></i>
|
||||
<span>Unduh</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form action="{{ route('hse.employees.import') }}" method="POST" enctype="multipart/form-data" class="mt-4 space-y-4">
|
||||
@csrf
|
||||
|
||||
<!-- Upload Box -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-2">Pilih File Spreadsheet <span class="text-rose-500">*</span></label>
|
||||
<div class="border-2 border-dashed border-slate-300 hover:border-emerald-600 rounded-2xl p-6 text-center bg-slate-50/60 hover:bg-white transition cursor-pointer relative"
|
||||
onclick="document.getElementById('importFileInput').click()">
|
||||
<i class="fa-solid fa-cloud-arrow-up text-3xl text-emerald-600 mb-2 block"></i>
|
||||
<p class="text-xs font-bold text-slate-800" id="importFileName">Klik untuk memilih file spreadsheet</p>
|
||||
<p class="text-[11px] text-slate-400 mt-1">Mendukung format Microsoft Excel (.xlsx) atau file teks CSV (.csv)</p>
|
||||
<input type="file"
|
||||
name="file"
|
||||
id="importFileInput"
|
||||
accept=".xlsx,.csv"
|
||||
required
|
||||
class="hidden"
|
||||
onchange="handleImportFileChange(this)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Petunjuk Ringkas -->
|
||||
<div class="bg-slate-50 border border-slate-200/70 rounded-xl p-3 text-[11px] text-slate-600 space-y-1">
|
||||
<p class="font-bold text-slate-700 flex items-center gap-1.5">
|
||||
<i class="fa-solid fa-circle-info text-emerald-600"></i>
|
||||
<span>Informasi Pemrosesan:</span>
|
||||
</p>
|
||||
<ul class="list-disc list-inside text-[11px] text-slate-500 space-y-0.5 pl-1">
|
||||
<li>Jika NIK sudah ada di database, data karyawan akan <strong>diperbarui (update)</strong>.</li>
|
||||
<li>Jika NIK baru, sistem otomatis <strong>menambahkan data & membuat akun login karyawan</strong>.</li>
|
||||
<li>Pastikan kolom NIK dan Nama tidak kosong pada setiap baris data.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Footer -->
|
||||
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
|
||||
<button type="button" onclick="closeImportKaryawanModal()" class="px-4 py-2.5 rounded-xl border border-slate-200 bg-slate-100 hover:bg-slate-200 text-slate-600 font-bold text-xs transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit" class="px-5 py-2.5 rounded-xl bg-emerald-700 hover:bg-emerald-800 text-white font-bold text-xs transition shadow-sm flex items-center gap-2">
|
||||
<i class="fa-solid fa-file-import text-xs"></i>
|
||||
<span>Unggah & Proses Impor</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Dialog Perpanjang SIMPER (Clean White Card) -->
|
||||
<div id="renewModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-md w-full p-7 border border-slate-100 overflow-hidden">
|
||||
@@ -640,9 +819,53 @@
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') {
|
||||
closeGuideModal();
|
||||
closeAddKaryawanModal();
|
||||
closeImportKaryawanModal();
|
||||
const exportMenu = document.getElementById('exportMenuSimper');
|
||||
if (exportMenu) exportMenu.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Modal Tambah Karyawan Manual
|
||||
function openAddKaryawanModal() {
|
||||
const modal = document.getElementById('addKaryawanModal');
|
||||
if (modal) modal.classList.remove('hidden');
|
||||
}
|
||||
function closeAddKaryawanModal() {
|
||||
const modal = document.getElementById('addKaryawanModal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
function toggleAddSimperDate(val) {
|
||||
const wrapper = document.getElementById('addSimperDateWrapper');
|
||||
const input = document.getElementById('addSimperDateInput');
|
||||
if (wrapper) {
|
||||
if (val === '1') {
|
||||
wrapper.style.display = 'block';
|
||||
} else {
|
||||
wrapper.style.display = 'none';
|
||||
if (input) input.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Modal Impor Karyawan via Excel
|
||||
function openImportKaryawanModal() {
|
||||
const modal = document.getElementById('importKaryawanModal');
|
||||
if (modal) modal.classList.remove('hidden');
|
||||
}
|
||||
function closeImportKaryawanModal() {
|
||||
const modal = document.getElementById('importKaryawanModal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
function handleImportFileChange(input) {
|
||||
const display = document.getElementById('importFileName');
|
||||
if (input.files && input.files[0]) {
|
||||
display.textContent = 'File terpilih: ' + input.files[0].name;
|
||||
display.classList.add('text-emerald-700');
|
||||
} else {
|
||||
display.textContent = 'Klik untuk memilih file spreadsheet';
|
||||
display.classList.remove('text-emerald-700');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -160,7 +160,8 @@
|
||||
|
||||
<!-- Menu Navigasi Sidebar -->
|
||||
<div class="flex-1 overflow-y-auto px-4 py-5 space-y-6 no-scrollbar">
|
||||
<!-- Grup: Navigasi Utama -->
|
||||
<!-- Grup: Navigasi Utama (Dashboard Utama) -->
|
||||
@if(!auth()->user()->isGateOfficer())
|
||||
<div>
|
||||
<nav class="space-y-1">
|
||||
@if(auth()->user()->isSuperAdmin())
|
||||
@@ -213,14 +214,6 @@
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
@endcan
|
||||
@elseif(auth()->user()->isGateOfficer())
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}"
|
||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
@elseif(auth()->user()->isEmployee())
|
||||
<a href="{{ route('employee.dashboard') }}"
|
||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('employee.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
@@ -245,6 +238,7 @@
|
||||
@endif
|
||||
</nav>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Grup: Super Admin & RBAC -->
|
||||
@if(auth()->user()->isSuperAdmin())
|
||||
@@ -399,15 +393,13 @@
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
@if(!auth()->user()->isGateOfficer())
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}"
|
||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
@endif
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}"
|
||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
</nav>
|
||||
</div>
|
||||
@endif
|
||||
@@ -468,6 +460,7 @@
|
||||
|
||||
<div class="p-4 space-y-4 flex-1 overflow-y-auto no-scrollbar">
|
||||
<!-- Grup: Navigasi Utama Mobile -->
|
||||
@if(!auth()->user()->isGateOfficer())
|
||||
<div>
|
||||
<nav class="space-y-1">
|
||||
@if(auth()->user()->isSuperAdmin())
|
||||
@@ -516,13 +509,6 @@
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
@endcan
|
||||
@elseif(auth()->user()->isGateOfficer())
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
@elseif(auth()->user()->isEmployee())
|
||||
<a href="{{ route('employee.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('employee.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||
@@ -544,6 +530,7 @@
|
||||
@endif
|
||||
</nav>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Grup: Super Admin & RBAC Mobile -->
|
||||
@if(auth()->user()->isSuperAdmin())
|
||||
@@ -684,14 +671,12 @@
|
||||
<span>Log Verifikasi Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
@if(!auth()->user()->isGateOfficer())
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
@endif
|
||||
@can('gate.inspect')
|
||||
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
|
||||
<span>Verifikasi Pos Gerbang</span>
|
||||
</a>
|
||||
@endcan
|
||||
</nav>
|
||||
</div>
|
||||
@endif
|
||||
@@ -988,40 +973,54 @@
|
||||
}
|
||||
}
|
||||
|
||||
let isBackdropClickTarget = false;
|
||||
let activeBackdropTargetModal = null;
|
||||
let isMouseDownOnBackdrop = false;
|
||||
let activeBackdropModal = null;
|
||||
|
||||
document.addEventListener('mousedown', function(e) {
|
||||
const modal = e.target.closest('[id$="Modal"], [id$="modal"], .fixed.inset-0.z-50');
|
||||
if (modal && !modal.classList.contains('hidden') && modal.id !== 'mobileDrawer') {
|
||||
const dialogCard = modal.querySelector('.bg-white, [role="dialog"], .modal-dialog, div[class*="rounded-"]');
|
||||
// Tandai mousedown hanya jika terjadi langsung di luar kartu dialog (pada area backdrop)
|
||||
if (dialogCard && !dialogCard.contains(e.target)) {
|
||||
isBackdropClickTarget = true;
|
||||
activeBackdropTargetModal = modal;
|
||||
isMouseDownOnBackdrop = true;
|
||||
activeBackdropModal = modal;
|
||||
return;
|
||||
}
|
||||
}
|
||||
isBackdropClickTarget = false;
|
||||
activeBackdropTargetModal = null;
|
||||
isMouseDownOnBackdrop = false;
|
||||
activeBackdropModal = null;
|
||||
});
|
||||
|
||||
document.addEventListener('mouseup', function(e) {
|
||||
if (isBackdropClickTarget && activeBackdropTargetModal) {
|
||||
const modal = activeBackdropTargetModal;
|
||||
if (!modal.classList.contains('hidden')) {
|
||||
const dialogCard = modal.querySelector('.bg-white, [role="dialog"], .modal-dialog, div[class*="rounded-"]');
|
||||
if (dialogCard && !dialogCard.contains(e.target)) {
|
||||
closeAnyActiveModal(modal);
|
||||
// Dukungan klik langsung pada backdrop (hanya tutup jika mousedown & click keduanya murni pada backdrop dan tidak sedang memblok teks)
|
||||
document.addEventListener('click', function(e) {
|
||||
// Jika mousedown tidak bermula di area backdrop, abaikan klik
|
||||
// (Mencegah modal tertutup saat pengguna memblok / drag teks dari dalam form input)
|
||||
if (!isMouseDownOnBackdrop || !activeBackdropModal) {
|
||||
isMouseDownOnBackdrop = false;
|
||||
activeBackdropModal = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const modal = activeBackdropModal;
|
||||
isMouseDownOnBackdrop = false;
|
||||
activeBackdropModal = null;
|
||||
|
||||
// Proteksi: jangan tutup modal jika pengguna sedang menyeleksi / memblok teks
|
||||
const selection = window.getSelection();
|
||||
if (selection && selection.toString().trim().length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeEl = document.activeElement;
|
||||
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA')) {
|
||||
if (typeof activeEl.selectionStart === 'number' && typeof activeEl.selectionEnd === 'number') {
|
||||
if (activeEl.selectionStart !== activeEl.selectionEnd) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
isBackdropClickTarget = false;
|
||||
activeBackdropTargetModal = null;
|
||||
});
|
||||
|
||||
// Dukungan klik langsung pada backdrop
|
||||
document.addEventListener('click', function(e) {
|
||||
const modal = e.target.closest('[id$="Modal"], [id$="modal"], .fixed.inset-0.z-50');
|
||||
// Pastikan click target saat dilepas juga berada di area backdrop (di luar dialog card)
|
||||
if (modal && !modal.classList.contains('hidden') && modal.id !== 'mobileDrawer') {
|
||||
const dialogCard = modal.querySelector('.bg-white, [role="dialog"], .modal-dialog, div[class*="rounded-"]');
|
||||
if (dialogCard && !dialogCard.contains(e.target)) {
|
||||
|
||||
@@ -3,13 +3,31 @@
|
||||
@section('title', 'Verifikasi Pos Gerbang - Private Guard (PG) | PT Kerinci Merangin Hidro')
|
||||
|
||||
@section('content')
|
||||
<div class="w-full space-y-4 sm:space-y-5">
|
||||
<div class="w-full space-y-4 sm:space-y-5 relative">
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 1. STATUS BAR POS JAGA & JAM KERJA SATPAM (SEAMLESS / TANPA KARTU) -->
|
||||
<!-- FLOATING TOAST NOTIFIKASI KENDARAAN BARU (KEDIP & MUNCUL DARI ATAS) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-slate-200/80">
|
||||
<!-- Pos Jaga Aktif, Regu, dan Nama Petugas (Tanpa Icon Perisai) -->
|
||||
<div id="incomingVehicleToast"
|
||||
class="fixed top-5 right-5 z-50 max-w-sm w-[92vw] sm:w-full bg-[#06213f] text-white rounded-2xl p-4 shadow-2xl border-2 border-amber-400/80 transition-all duration-300 pointer-events-none opacity-0 -translate-y-10 scale-95 flex items-start gap-3.5">
|
||||
<div class="w-11 h-11 rounded-xl bg-amber-400 text-slate-950 flex items-center justify-center text-xl flex-shrink-0 font-bold shadow-md animate-bounce">
|
||||
<i class="fa-solid fa-bell"></i>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center justify-between gap-1 mb-1">
|
||||
<span class="text-[10px] font-black uppercase tracking-wider text-amber-300">KENDARAAN BARU DI PORTAL</span>
|
||||
<span id="toastDirectionBadge" class="text-[9px] font-black uppercase px-2 py-0.5 rounded-full bg-amber-500/30 text-amber-300 border border-amber-400/50">MASUK</span>
|
||||
</div>
|
||||
<p id="toastVehicleUnit" class="text-sm font-extrabold text-white truncate">Toyota Hilux (LV 01)</p>
|
||||
<p id="toastDriverName" class="text-xs text-slate-300 truncate mt-0.5">Driver: Hendra Saputra</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- 1. STATUS BAR POS JAGA, JAM KERJA & KONTROL BEL SUARA -->
|
||||
<!-- ========================================================================= -->
|
||||
<div class="flex flex-col md:flex-row md:items-center justify-between gap-3 pb-3 border-b border-slate-200/80">
|
||||
<!-- Pos Jaga Aktif, Regu, dan Nama Petugas -->
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center flex-wrap gap-2.5">
|
||||
<h1 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight">
|
||||
@@ -27,10 +45,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Jam Digital WIB (Di Atas Kanan) -->
|
||||
<div class="flex items-center justify-end pt-2 sm:pt-0 border-t sm:border-t-0 border-slate-100 flex-shrink-0">
|
||||
<!-- Bagian Kanan: Kontrol Bel Notifikasi & Jam Digital WIB -->
|
||||
<div class="flex items-center justify-start md:justify-end flex-wrap gap-2 pt-2 md:pt-0 border-t md:border-t-0 border-slate-100 flex-shrink-0">
|
||||
<!-- Kontrol Bel Suara: Mode & Tombol Tes -->
|
||||
<div class="inline-flex items-center bg-white border border-slate-200/90 rounded-xl p-1 shadow-2xs gap-1">
|
||||
<button type="button"
|
||||
id="btnSoundToggle"
|
||||
onclick="cycleSoundMode()"
|
||||
class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg font-bold text-xs transition cursor-pointer bg-emerald-50 text-emerald-800 hover:bg-emerald-100 border border-emerald-200/80"
|
||||
title="Klik untuk mengganti mode bel suara">
|
||||
<i id="soundModeIcon" class="fa-solid fa-volume-high text-xs text-emerald-600"></i>
|
||||
<span id="soundModeLabel">Bel & Suara</span>
|
||||
</button>
|
||||
<button type="button"
|
||||
onclick="testSoundAlert()"
|
||||
class="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg font-bold text-xs text-slate-700 bg-slate-50 hover:bg-slate-100 hover:text-slate-900 border border-slate-200/70 transition cursor-pointer"
|
||||
title="Uji coba nada bel Ting-Tung & suara asisten">
|
||||
<i class="fa-solid fa-play text-[10px] text-slate-500"></i>
|
||||
<span>Tes Bel</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Jam Digital Realtime WIB -->
|
||||
<div class="inline-flex items-center space-x-1.5 bg-white border border-slate-200/80 px-3 py-1.5 rounded-xl font-mono text-xs font-bold text-slate-700 shadow-2xs">
|
||||
<div class="inline-flex items-center space-x-1.5 bg-white border border-slate-200/80 px-3 py-2 rounded-xl font-mono text-xs font-bold text-slate-700 shadow-2xs">
|
||||
<span class="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
|
||||
<span id="posDigitalClock">--:--:-- WIB</span>
|
||||
</div>
|
||||
@@ -70,12 +107,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- JAVASCRIPT LOGIC UNTUK JAM DIGITAL, REALTIME LIVE SYNC & PANDUAN -->
|
||||
<!-- JAVASCRIPT LOGIC: JAM DIGITAL, BEL SUARA TING-TUNG & ASISTEN BICARA -->
|
||||
<!-- ========================================================================= -->
|
||||
<script>
|
||||
// 1. Jam Digital Pos Gerbang (WIB)
|
||||
@@ -92,7 +125,209 @@
|
||||
setInterval(updateClock, 1000);
|
||||
updateClock();
|
||||
|
||||
// 2. Realtime Live Sync Antrean Tanpa Reload Halaman (Setiap 3 Detik)
|
||||
// =========================================================================
|
||||
// 2. SISTEM NOTIFIKASI AUDIO: BEL TING-TUNG & SPEECH SYNTHESIS (ASISTEN)
|
||||
// =========================================================================
|
||||
// Mode suara yang didukung:
|
||||
// - 'both' : Bel Ting-Tung + Suara Asisten Bicara (Default)
|
||||
// - 'chime' : Hanya Bel Ting-Tung
|
||||
// - 'voice' : Hanya Suara Asisten Bicara
|
||||
// - 'mute' : Senyap (Hanya Toast Visual)
|
||||
let currentSoundMode = localStorage.getItem('pg_gate_sound_mode') || 'both';
|
||||
|
||||
function updateSoundUI() {
|
||||
const iconEl = document.getElementById('soundModeIcon');
|
||||
const labelEl = document.getElementById('soundModeLabel');
|
||||
const btnEl = document.getElementById('btnSoundToggle');
|
||||
if (!iconEl || !labelEl || !btnEl) return;
|
||||
|
||||
btnEl.classList.remove('bg-emerald-50', 'text-emerald-800', 'border-emerald-200/80',
|
||||
'bg-blue-50', 'text-blue-800', 'border-blue-200/80',
|
||||
'bg-amber-50', 'text-amber-800', 'border-amber-200/80',
|
||||
'bg-slate-100', 'text-slate-600', 'border-slate-200');
|
||||
|
||||
if (currentSoundMode === 'both') {
|
||||
btnEl.classList.add('bg-emerald-50', 'text-emerald-800', 'border-emerald-200/80');
|
||||
iconEl.className = 'fa-solid fa-volume-high text-xs text-emerald-600';
|
||||
labelEl.textContent = 'Bel & Suara';
|
||||
btnEl.title = 'Mode: Bel Ting-Tung + Asisten Bicara aktif (Klik untuk ganti)';
|
||||
} else if (currentSoundMode === 'chime') {
|
||||
btnEl.classList.add('bg-blue-50', 'text-blue-800', 'border-blue-200/80');
|
||||
iconEl.className = 'fa-solid fa-bell text-xs text-blue-600';
|
||||
labelEl.textContent = 'Hanya Bel';
|
||||
btnEl.title = 'Mode: Hanya Bel Ting-Tung (Klik untuk ganti)';
|
||||
} else if (currentSoundMode === 'voice') {
|
||||
btnEl.classList.add('bg-amber-50', 'text-amber-800', 'border-amber-200/80');
|
||||
iconEl.className = 'fa-solid fa-bullhorn text-xs text-amber-600';
|
||||
labelEl.textContent = 'Hanya Suara';
|
||||
btnEl.title = 'Mode: Hanya Suara Asisten Bicara (Klik untuk ganti)';
|
||||
} else {
|
||||
btnEl.classList.add('bg-slate-100', 'text-slate-600', 'border-slate-200');
|
||||
iconEl.className = 'fa-solid fa-volume-xmark text-xs text-slate-400';
|
||||
labelEl.textContent = 'Senyap';
|
||||
btnEl.title = 'Mode: Senyap / Tanpa Suara (Klik untuk ganti)';
|
||||
}
|
||||
}
|
||||
|
||||
function cycleSoundMode() {
|
||||
if (currentSoundMode === 'both') currentSoundMode = 'chime';
|
||||
else if (currentSoundMode === 'chime') currentSoundMode = 'voice';
|
||||
else if (currentSoundMode === 'voice') currentSoundMode = 'mute';
|
||||
else currentSoundMode = 'both';
|
||||
|
||||
localStorage.setItem('pg_gate_sound_mode', currentSoundMode);
|
||||
updateSoundUI();
|
||||
requestDesktopNotificationPermission();
|
||||
}
|
||||
|
||||
// A. Web Audio API Synthesizer: Nada Bel Dua Ketuk "Ting - Tung"
|
||||
function playChime(callback) {
|
||||
try {
|
||||
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
if (!AudioContext) {
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
const ctx = new AudioContext();
|
||||
const now = ctx.currentTime;
|
||||
|
||||
// Nada 1: "Ting" (Frekuensi 880 Hz - A5 jernih dengan desah lembut)
|
||||
const osc1 = ctx.createOscillator();
|
||||
const gain1 = ctx.createGain();
|
||||
osc1.type = 'sine';
|
||||
osc1.frequency.setValueAtTime(880, now);
|
||||
gain1.gain.setValueAtTime(0.3, now);
|
||||
gain1.gain.exponentialRampToValueAtTime(0.001, now + 0.45);
|
||||
osc1.connect(gain1);
|
||||
gain1.connect(ctx.destination);
|
||||
osc1.start(now);
|
||||
osc1.stop(now + 0.45);
|
||||
|
||||
// Nada 2: "Tung" (Frekuensi 659.25 Hz - E5 nada bel resepsionis/bandara)
|
||||
const osc2 = ctx.createOscillator();
|
||||
const gain2 = ctx.createGain();
|
||||
osc2.type = 'sine';
|
||||
osc2.frequency.setValueAtTime(659.25, now + 0.22);
|
||||
gain2.gain.setValueAtTime(0.35, now + 0.22);
|
||||
gain2.gain.exponentialRampToValueAtTime(0.001, now + 0.85);
|
||||
osc2.connect(gain2);
|
||||
gain2.connect(ctx.destination);
|
||||
osc2.start(now + 0.22);
|
||||
osc2.stop(now + 0.85);
|
||||
|
||||
if (callback) {
|
||||
setTimeout(callback, 800);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Web Audio error:', e);
|
||||
if (callback) callback();
|
||||
}
|
||||
}
|
||||
|
||||
// B. Web Speech Synthesis: Suara Asisten Bicara Bahasa Indonesia
|
||||
function speakAnnouncement(text) {
|
||||
if (!('speechSynthesis' in window)) return;
|
||||
try {
|
||||
window.speechSynthesis.cancel(); // Hentikan suara sebelumnya jika masih bicara
|
||||
const utterance = new SpeechSynthesisUtterance(text);
|
||||
utterance.lang = 'id-ID';
|
||||
utterance.rate = 0.95; // Kecepatan bicara normal dan jelas
|
||||
utterance.pitch = 1.0;
|
||||
|
||||
// Cari suara bahasa Indonesia bawaan komputer jika ada
|
||||
const voices = window.speechSynthesis.getVoices();
|
||||
const idVoice = voices.find(v => (v.lang && (v.lang.startsWith('id') || v.lang.includes('ID'))) ||
|
||||
(v.name && v.name.toLowerCase().includes('indonesia')));
|
||||
if (idVoice) {
|
||||
utterance.voice = idVoice;
|
||||
}
|
||||
|
||||
window.speechSynthesis.speak(utterance);
|
||||
} catch (e) {
|
||||
console.warn('Speech error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// C. Pemicu Pengumuman Kendaraan Sesuai Mode Aktif
|
||||
function announceIncomingVehicle(announcementText) {
|
||||
if (currentSoundMode === 'mute') return;
|
||||
|
||||
if (currentSoundMode === 'chime') {
|
||||
playChime();
|
||||
} else if (currentSoundMode === 'voice') {
|
||||
speakAnnouncement(announcementText);
|
||||
} else {
|
||||
// Default 'both': Bunyi Bel Ting-Tung dulu, lalu disambung Asisten Bicara
|
||||
playChime(() => {
|
||||
speakAnnouncement(announcementText);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// D. Pop-up Toast Visual di Layar
|
||||
let toastTimeout = null;
|
||||
function showVehicleToast(vehicleUnit, driverName, direction) {
|
||||
const toast = document.getElementById('incomingVehicleToast');
|
||||
const unitEl = document.getElementById('toastVehicleUnit');
|
||||
const driverEl = document.getElementById('toastDriverName');
|
||||
const badgeEl = document.getElementById('toastDirectionBadge');
|
||||
if (!toast || !unitEl || !driverEl || !badgeEl) return;
|
||||
|
||||
unitEl.textContent = vehicleUnit || 'Kendaraan Operasional';
|
||||
driverEl.textContent = 'Driver: ' + (driverName || 'Karyawan');
|
||||
|
||||
const isMasuk = direction === 'in' || direction === 'masuk';
|
||||
badgeEl.textContent = isMasuk ? 'MASUK (IN)' : 'KELUAR (OUT)';
|
||||
badgeEl.className = isMasuk
|
||||
? 'text-[9px] font-black uppercase px-2 py-0.5 rounded-full bg-blue-500/30 text-blue-300 border border-blue-400/50'
|
||||
: 'text-[9px] font-black uppercase px-2 py-0.5 rounded-full bg-amber-500/30 text-amber-300 border border-amber-400/50';
|
||||
|
||||
// Tampilkan toast
|
||||
toast.classList.remove('opacity-0', '-translate-y-10', 'scale-95');
|
||||
toast.classList.add('opacity-100', 'translate-y-0', 'scale-100');
|
||||
|
||||
clearTimeout(toastTimeout);
|
||||
toastTimeout = setTimeout(() => {
|
||||
toast.classList.remove('opacity-100', 'translate-y-0', 'scale-100');
|
||||
toast.classList.add('opacity-0', '-translate-y-10', 'scale-95');
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// E. Izin Notifikasi Desktop Windows
|
||||
function requestDesktopNotificationPermission() {
|
||||
if ('Notification' in window && Notification.permission === 'default') {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
function showDesktopNotification(title, body) {
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
try {
|
||||
new Notification(title, {
|
||||
body: body,
|
||||
icon: '/images/logo-kerinci.png',
|
||||
silent: true // Suara sudah ditangani oleh Bel & Asisten Bicara
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// F. Tombol "Tes Bel" untuk Uji Coba Langsung di Layar
|
||||
function testSoundAlert() {
|
||||
requestDesktopNotificationPermission();
|
||||
const contohTeks = "Perhatian, Unit Toyota Hilux LV 62, pengemudi Hendra Saputra, akan masuk gerbang.";
|
||||
showVehicleToast("Toyota Hilux (LV 62)", "Hendra Saputra", "in");
|
||||
announceIncomingVehicle(contohTeks);
|
||||
showDesktopNotification("🔔 Tes Notifikasi Portal Pos Gerbang", "Unit Toyota Hilux LV 62 - Hendra Saputra akan masuk gerbang.");
|
||||
}
|
||||
|
||||
// Inisialisasi Tampilan Suara saat halaman pertama dimuat
|
||||
updateSoundUI();
|
||||
|
||||
// =========================================================================
|
||||
// 3. REALTIME LIVE SYNC ANTREAN PORTAL (SETIAP 3 DETIK)
|
||||
// =========================================================================
|
||||
let knownActivityIds = new Set(@json($pendingActivities->pluck('id')));
|
||||
let lastQueueHtml = null;
|
||||
let isSyncing = false;
|
||||
|
||||
@@ -115,7 +350,31 @@
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// 1. Update Badge Jumlah Antrean
|
||||
// 1. Deteksi apakah ada KENDARAAN BARU yang baru saja masuk antrean
|
||||
if (Array.isArray(data.items)) {
|
||||
const currentIds = new Set(data.items.map(item => item.id));
|
||||
const newArrivals = data.items.filter(item => !knownActivityIds.has(item.id));
|
||||
|
||||
if (newArrivals.length > 0) {
|
||||
// Ambil kendaraan yang paling baru masuk antrean
|
||||
const newest = newArrivals[newArrivals.length - 1];
|
||||
const unitName = (newest.brand_type || 'Kendaraan') + (newest.code ? ' (' + newest.code + ')' : '');
|
||||
|
||||
// Bunyikan Bel Ting-Tung & Asisten Suara!
|
||||
announceIncomingVehicle(newest.announcement);
|
||||
|
||||
// Tampilkan Pop-up Visual di Layar Pos
|
||||
showVehicleToast(unitName, newest.driver_name, newest.direction);
|
||||
|
||||
// Kirim Notifikasi Desktop Windows
|
||||
showDesktopNotification("🔔 Kendaraan Baru di Portal!", `${unitName} - Driver: ${newest.driver_name} (${newest.direction === 'in' ? 'Masuk' : 'Keluar'})`);
|
||||
}
|
||||
|
||||
// Perbarui daftar ID antrean yang diketahui
|
||||
knownActivityIds = currentIds;
|
||||
}
|
||||
|
||||
// 2. Update Badge Jumlah Antrean
|
||||
const badgeContainer = document.getElementById('queueBadgeContainer');
|
||||
if (badgeContainer) {
|
||||
if (data.count > 0) {
|
||||
@@ -135,7 +394,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Update Daftar Kartu Antrean Secara Halus (Hanya Jika Ada Perubahan)
|
||||
// 3. Update Daftar Kartu Antrean Secara Halus (Hanya Jika Ada Perubahan)
|
||||
const listContainer = document.getElementById('queueListContainer');
|
||||
if (listContainer && lastQueueHtml !== null && lastQueueHtml !== data.html) {
|
||||
listContainer.innerHTML = data.html;
|
||||
@@ -143,7 +402,7 @@
|
||||
|
||||
lastQueueHtml = data.html;
|
||||
} catch (err) {
|
||||
// Abaikan kegagalan sementara koneksi jaringan
|
||||
// Abaikan kegagalan sementara jaringan
|
||||
} finally {
|
||||
isSyncing = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user