2026-10-15 13:53:52 +07:00
@ extends ( 'layouts.app' )
@ section ( 'title' , 'Dashboard Karyawan - Sistem RKM | PT Kerinci Merangin Hidro' )
@ section ( 'content' )
< div class = "w-full space-y-6" >
<!-- Header Halaman Simple Kayak Satpam ( Seamless , Tanpa Card Wrapper ) -->
2026-10-20 19:22:28 +07:00
< div class = "flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-slate-200/80" >
< div class = "flex items-center space-x-3.5 min-w-0" >
@ php
$empPhoto = $employee ?-> photo_url ?: auth () -> user () -> photo_url ;
$empName = $employee ? $employee -> name : auth () -> user () -> name ;
@ endphp
@ if ( $empPhoto )
< img src = "{{ $empPhoto }}" alt = "{{ $empName }}" class = "w-12 h-12 rounded-2xl object-cover ring-2 ring-emerald-500/20 shadow-sm flex-shrink-0" >
@ else
< div class = "w-12 h-12 rounded-2xl bg-gradient-to-br from-emerald-700 to-[#1b5e20] text-white font-black text-lg flex items-center justify-center ring-2 ring-emerald-500/20 shadow-sm flex-shrink-0" >
{{ strtoupper ( substr ( $empName , 0 , 1 )) }}
</ div >
@ endif
< 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" >
{{ $empName }}
</ h1 >
@ if ( $employee && $employee -> hasValidSimper ())
< span class = "px-2.5 py-0.5 rounded-lg text-xs font-black bg-emerald-50 text-emerald-700 border border-emerald-200" >
SIMPER Aktif
</ span >
@ elseif ( $employee )
< span class = "px-2.5 py-0.5 rounded-lg text-xs font-black bg-rose-50 text-rose-700 border border-rose-200" >
SIMPER Exp
</ span >
@ endif
</ div >
< div class = "text-xs sm:text-sm text-slate-500 font-medium truncate mt-0.5 flex items-center flex-wrap gap-1.5" >
@ if ( $employee && $employee -> nik )
< span class = "text-slate-700 font-mono font-semibold" > NIK : {{ $employee -> nik }} </ span >
@ endif
@ if ( $employee && $employee -> division )
< span class = "text-slate-300" >& bull ; </ span >
< span class = "text-slate-600" > {{ $employee -> division }} </ span >
@ endif
@ if ( $employee && $employee -> position )
< span class = "text-slate-300" >& bull ; </ span >
< span class = "text-slate-600 font-semibold" > {{ $employee -> position }} </ span >
@ endif
</ div >
2026-10-15 13:53:52 +07:00
</ div >
</ div >
@ if ( $employee && $employee -> simper_expired_at )
2026-10-20 19:22:28 +07:00
< div class = "text-xs text-slate-500 font-medium self-start sm:self-center bg-slate-50 px-3 py-1.5 rounded-xl border border-slate-200/60" >
2026-10-15 13:53:52 +07:00
Masa Berlaku SIMPER : < span class = "font-bold text-slate-800" > {{ $employee -> simper_expired_at -> format ( 'd/m/Y' ) }} </ span >
</ div >
@ endif
</ div >
2026-10-20 19:36:54 +07:00
{{ -- CARD PERJALANAN AKTIF ( MENUNGGU PEMERIKSAAN SATPAM ) -- }}
2026-10-19 23:21:55 +07:00
@ if ( isset ( $pendingActivity ) && $pendingActivity )
2026-10-22 16:13:24 +07:00
< div id = "pendingTripCard"
data - activity - id = "{{ $pendingActivity->id }}"
class = "bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-white border-2 border-amber-300/80 rounded-2xl p-5 sm:p-6 shadow-sm relative overflow-hidden transition-all duration-300" >
2026-10-19 23:21:55 +07:00
< div class = "relative z-10 space-y-4" >
2026-10-20 19:36:54 +07:00
{{ -- Header Card Perjalanan -- }}
2026-10-19 23:21:55 +07:00
< div class = "flex flex-col sm:flex-row sm:items-center justify-between gap-2.5 pb-3 border-b border-amber-200/60" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-9 h-9 rounded-xl bg-amber-500 text-white flex items-center justify-center font-bold text-sm shadow-sm flex-shrink-0" >
2026-10-20 19:36:54 +07:00
< i class = "fa-solid fa-route" ></ i >
2026-10-19 23:21:55 +07:00
</ div >
< div >
< div class = "flex items-center space-x-2" >
2026-10-20 19:36:54 +07:00
< span class = "text-xs font-bold uppercase tracking-wider text-amber-900" > Perjalanan Aktif </ span >
2026-10-19 23:21:55 +07:00
< span class = "text-[11px] font-mono font-bold text-amber-700 bg-amber-100/80 px-2 py-0.5 rounded-md border border-amber-200" >
{{ $pendingActivity -> transaction_no }}
</ span >
</ div >
< p class = "text-[11px] text-slate-500 mt-0.5" > Input : {{ $pendingActivity -> recorded_at -> locale ( 'id' ) -> translatedFormat ( 'd M Y, H:i' ) }} WIB </ p >
</ div >
</ div >
2026-10-22 12:23:13 +07:00
< div class = "self-start sm:self-center flex flex-wrap items-center gap-2" >
<!-- Timer Countdown Sisa Waktu 5 Jam -->
< div id = "pendingTripCountdownContainer"
data - expires - at = "{{ $pendingActivity->expires_at ?->toISOString() }}"
class = "inline-flex items-center px-3 py-1 rounded-full text-xs font-mono font-bold bg-white text-rose-700 border border-rose-300 shadow-2xs" >
< i class = "fa-solid fa-stopwatch mr-1.5 text-rose-600 animate-pulse" ></ i >
< span > Sisa : < strong id = "tripCountdownTimerText" >--:--:--</ strong ></ span >
</ div >
2026-10-19 23:21:55 +07:00
< span class = "inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-amber-100 text-amber-900 border border-amber-300" >
< span class = "w-2 h-2 rounded-full bg-amber-500 animate-ping mr-1.5" ></ span >
< span class = "w-2 h-2 rounded-full bg-amber-500 mr-1.5 -ml-3.5" ></ span >
Menunggu Pemeriksaan Satpam
</ span >
2026-10-22 16:13:24 +07:00
< span class = "inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200 shadow-2xs" title = "Sistem memantau persetujuan satpam secara otomatis tanpa refresh" >
< span class = "w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse mr-1.5" ></ span >
< span > Auto - Check Aktif </ span >
</ span >
2026-10-19 23:21:55 +07:00
</ div >
</ div >
2026-10-20 19:31:16 +07:00
{{ -- Visual Foto Mobil LV & Foto Driver -- }}
< div class = "grid grid-cols-1 sm:grid-cols-2 gap-3" >
<!-- Foto Unit Kendaraan ( LV ) -->
< div class = "flex items-center space-x-3 bg-white/95 p-3 rounded-xl border border-amber-200/80 shadow-2xs" >
@ if ( $pendingActivity -> vehicle && $pendingActivity -> vehicle -> photo_url )
< img src = "{{ $pendingActivity->vehicle ->photo_url }}" alt = "{{ $pendingActivity->vehicle ->brand_type }}" class = "w-14 h-14 rounded-xl object-cover ring-2 ring-blue-500/20 shadow-2xs flex-shrink-0" >
@ else
< div class = "w-14 h-14 rounded-xl bg-blue-50 text-blue-700 flex items-center justify-center text-xl flex-shrink-0 ring-1 ring-blue-200" >
< i class = "fa-solid fa-car" ></ i >
</ div >
@ endif
< div class = "min-w-0" >
< span class = "text-[10px] font-bold uppercase tracking-wider text-slate-400 block" > Unit Kendaraan :</ span >
< p class = "text-xs font-black text-slate-900 truncate" > {{ $pendingActivity -> vehicle -> brand_type }} </ p >
< p class = "text-[11px] font-mono font-bold text-amber-800" > {{ $pendingActivity -> vehicle -> code }} & bull ; {{ $pendingActivity -> vehicle -> license_plate ?? 'Tanpa Plat' }} </ p >
</ div >
</ div >
<!-- Foto Pengemudi / Driver -->
< div class = "flex items-center space-x-3 bg-white/95 p-3 rounded-xl border border-amber-200/80 shadow-2xs" >
@ php $driverPhoto = $pendingActivity -> driver ?-> photo_url ?: auth () -> user () -> photo_url ; @ endphp
@ if ( $driverPhoto )
< img src = "{{ $driverPhoto }}" alt = "{{ $pendingActivity->driver ->name }}" class = "w-14 h-14 rounded-xl object-cover ring-2 ring-emerald-500/20 shadow-2xs flex-shrink-0" >
@ else
< div class = "w-14 h-14 rounded-xl bg-emerald-50 text-[#1b5e20] flex items-center justify-center text-lg font-black flex-shrink-0 ring-1 ring-emerald-200" >
{{ strtoupper ( substr ( $pendingActivity -> driver -> name ?? 'D' , 0 , 1 )) }}
</ div >
@ endif
< div class = "min-w-0" >
< span class = "text-[10px] font-bold uppercase tracking-wider text-slate-400 block" > Driver Terverifikasi :</ span >
< p class = "text-xs font-black text-slate-900 truncate" > {{ $pendingActivity -> driver -> name }} </ p >
< p class = "text-[11px] text-slate-500 truncate" > NIK : {{ $pendingActivity -> driver -> nik ?? '-' }} & bull ; {{ $pendingActivity -> driver -> division ?? 'Operasional' }} </ p >
</ div >
</ div >
</ div >
2026-10-20 19:36:54 +07:00
{{ -- Grid Rincian Perjalanan -- }}
2026-10-19 23:21:55 +07:00
< div class = "grid grid-cols-2 sm:grid-cols-4 gap-3 bg-white/90 p-4 rounded-xl border border-amber-200/70 text-xs shadow-xs" >
< div >
< span class = "text-[11px] text-slate-400 font-medium block" > Kendaraan ( Unit ) :</ span >
< span class = "font-bold text-slate-900 text-sm font-mono block mt-0.5" > {{ $pendingActivity -> vehicle -> code }} </ span >
< span class = "text-[10px] text-slate-500 block truncate" > {{ $pendingActivity -> vehicle -> brand_type }} </ span >
</ div >
< div >
< span class = "text-[11px] text-slate-400 font-medium block" > Plat Nomor :</ span >
< span class = "font-bold text-amber-800 text-sm font-mono block mt-0.5" > {{ $pendingActivity -> vehicle -> license_plate ?? '-' }} </ span >
< span class = "text-[10px] text-slate-500 block" > {{ $pendingActivity -> gate -> name }} </ span >
</ div >
< div >
< span class = "text-[11px] text-slate-400 font-medium block" > Arah Gerbang :</ span >
< div class = "mt-1" >
@ if ( $pendingActivity -> direction === 'in' )
< span class = "inline-flex items-center px-2 py-0.5 rounded text-[10px] font-black bg-emerald-100 text-emerald-800 border border-emerald-300" >
< i class = "fa-solid fa-arrow-right-to-bracket mr-1" ></ i > MASUK
</ span >
@ else
< span class = "inline-flex items-center px-2 py-0.5 rounded text-[10px] font-black bg-blue-100 text-blue-800 border border-blue-300" >
< i class = "fa-solid fa-arrow-right-from-bracket mr-1" ></ i > KELUAR
</ span >
@ endif
</ div >
< span class = "text-[10px] text-slate-400 block mt-0.5" > KM Awal : {{ number_format ( $pendingActivity -> previous_km , 0 , ',' , '.' ) }} </ span >
</ div >
< div >
< span class = "text-[11px] text-slate-400 font-medium block" > KM Input Saat Ini :</ span >
< span class = "font-bold text-emerald-700 text-sm font-mono block mt-0.5" > {{ number_format ( $pendingActivity -> current_km , 0 , ',' , '.' ) }} KM </ span >
< span class = "text-[10px] font-bold text-emerald-600 block" > Jarak : + {{ number_format ( $pendingActivity -> distance , 0 , ',' , '.' ) }} KM </ span >
</ div >
</ div >
{{ -- Keperluan Perjalanan -- }}
< div class = "bg-amber-50/60 p-3 rounded-xl border border-amber-200/50 text-xs" >
< span class = "font-bold text-slate-700" > Keperluan :</ span >
< span class = "text-slate-600 ml-1" > {{ $pendingActivity -> purpose }} </ span >
</ div >
{{ -- Petunjuk & Tombol Aksi Driver -- }}
< div class = "flex flex-col sm:flex-row sm:items-center justify-between gap-3 pt-2" >
< div class = "text-[11px] text-slate-500 flex items-center" >
< i class = "fa-solid fa-circle-info text-amber-600 mr-1.5 flex-shrink-0" ></ i >
2026-10-20 19:36:54 +07:00
< span > Tunjukkan data perjalanan ini ke petugas Satpam di pos gerbang untuk verifikasi fisik speedometer .</ span >
2026-10-19 23:21:55 +07:00
</ div >
< div class = "flex items-center space-x-2 self-end sm:self-auto flex-shrink-0" >
{{ -- Tombol Koreksi KM Driver -- }}
< button type = "button"
onclick = "openDriverEditKmModal({{ json_encode([
'id' => $pendingActivity->id ,
'trx' => $pendingActivity->transaction_no ,
'code' => $pendingActivity->vehicle ->code,
'previous_km' => (float) $pendingActivity->previous_km ,
'current_km' => (float) $pendingActivity->current_km ,
'distance' => (float) $pendingActivity->distance ,
]) }})"
class = "inline-flex items-center space-x-1.5 px-3 py-2 rounded-xl text-xs font-bold bg-white text-slate-700 border border-slate-300 hover:bg-slate-50 hover:text-slate-900 shadow-xs transition cursor-pointer" >
< i class = "fa-solid fa-pen-to-square text-amber-600" ></ i >
< span > Koreksi Angka KM </ span >
</ button >
{{ -- Tombol Batalkan Driver -- }}
< button type = "button"
onclick = "openDriverCancelModal({{ json_encode([
'id' => $pendingActivity->id ,
'trx' => $pendingActivity->transaction_no ,
'code' => $pendingActivity->vehicle ->code,
]) }})"
class = "inline-flex items-center space-x-1.5 px-3 py-2 rounded-xl text-xs font-bold bg-rose-50 text-rose-700 border border-rose-200 hover:bg-rose-100 transition cursor-pointer" >
< i class = "fa-solid fa-xmark" ></ i >
< span > Batalkan </ span >
</ button >
</ div >
</ div >
</ div >
</ div >
@ endif
{{ -- 2 Card Fitur : Pemeriksaan P2H dan Timesheet ( Dikontrol Hak Akses RBAC ) -- }}
@ if ( auth () -> user () -> can ( 'employee.p2h' ) || auth () -> user () -> can ( 'employee.timesheet' ))
< div class = "grid grid-cols-1 {{ auth()->user()->can('employee.p2h') && auth()->user()->can('employee.timesheet') ? 'md:grid-cols-2' : '' }} gap-5 sm:gap-6" >
{{ -- Card 1 : Pemeriksaan P2H -- }}
@ can ( 'employee.p2h' )
2026-10-15 13:53:52 +07:00
< div class = "bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md transition flex flex-col justify-between group" >
< div >
< div class = "flex items-center justify-end mb-4" >
< span class = "px-2.5 py-1 rounded-lg text-[11px] font-bold bg-amber-50 text-amber-800 border border-amber-200" >
2026-10-24 14:37:46 +07:00
Heavy Equipment
2026-10-15 13:53:52 +07:00
</ span >
</ div >
< h2 class = "text-lg sm:text-xl font-black text-slate-900 tracking-tight mb-1" >
Pemeriksaan Pra - Harian ( P2H )
</ h2 >
< p class = "text-xs sm:text-sm text-slate-500 leading-relaxed mb-4" >
2026-10-24 14:37:46 +07:00
Pengisian formulir checklist kelaikan operasi harian sebelum mengoperasikan alat berat Heavy Equipment ( Excavator , Crane , Bulldozer , dan unit lainnya ) .
2026-10-15 13:53:52 +07:00
</ p >
< div class = "text-xs text-slate-600 bg-slate-50 p-3 rounded-xl border border-slate-100 flex items-center justify-between" >
< span class = "text-slate-400" > Total Unit Terdaftar :</ span >
2026-10-24 14:37:46 +07:00
< span class = "font-extrabold text-[#1b5e20]" > {{ $totalSupport }} Heavy Equipment </ span >
2026-10-15 13:53:52 +07:00
</ div >
</ div >
< div class = "mt-6 pt-4 border-t border-slate-100" >
< a href = "{{ route('p2h.index') }}" class = "w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-3 px-4 rounded-xl shadow-sm transition flex items-center justify-center space-x-2 text-xs sm:text-sm" >
< span > Buka Modul Pemeriksaan P2H </ span >
< i class = "fa-solid fa-arrow-right text-xs" ></ i >
</ a >
</ div >
</ div >
2026-10-19 23:21:55 +07:00
@ endcan
2026-10-15 13:53:52 +07:00
<!-- Card 2 : Timesheet Kendaraan Ringan ( LV ) -->
2026-10-19 23:21:55 +07:00
@ can ( 'employee.timesheet' )
2026-10-15 13:53:52 +07:00
< div class = "bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md transition flex flex-col justify-between group" >
< div >
< div class = "flex items-center justify-end mb-4" >
< span class = "px-2.5 py-1 rounded-lg text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200" >
Kendaraan Ringan ( LV )
</ span >
</ div >
< h2 class = "text-lg sm:text-xl font-black text-slate-900 tracking-tight mb-1" >
Timesheet Kendaraan Ringan
</ h2 >
< p class = "text-xs sm:text-sm text-slate-500 leading-relaxed mb-4" >
Pencatatan aktivitas mobilisasi harian light vehicle ( LV ), odometer kilometer ( KM ), tujuan penugasan operasional , dan verifikasi pos gerbang .
</ p >
< div class = "text-xs text-slate-600 bg-slate-50 p-3 rounded-xl border border-slate-100 flex items-center justify-between" >
< span class = "text-slate-400" > Armada Tersedia :</ span >
< span class = "font-extrabold text-[#1b5e20]" > {{ $totalLv }} Unit Kendaraan Ringan </ span >
</ div >
</ div >
2026-10-19 23:21:55 +07:00
< div class = "mt-6 pt-4 border-t border-slate-100 space-y-2" >
< button type = "button"
onclick = "openUnitQrScannerModal()"
class = "w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-3 px-4 rounded-xl shadow-sm transition flex items-center justify-center space-x-2 text-xs sm:text-sm cursor-pointer" >
< i class = "fa-solid fa-qrcode text-base" ></ i >
< span > Scan Barcode Unit Mobil </ span >
</ button >
< a href = "{{ route('timesheet.index') }}" class = "w-full py-2 px-3 text-center block text-xs text-slate-500 hover:text-slate-800 font-semibold rounded-lg hover:bg-slate-50 transition" >
Atau Pilih Manual dari Katalog Unit & rarr ;
2026-10-15 13:53:52 +07:00
</ a >
</ div >
</ div >
2026-10-19 23:21:55 +07:00
@ endcan
</ div >
@ else
< div class = "bg-white rounded-2xl border border-slate-200 p-8 text-center shadow-sm" >
< div class = "w-12 h-12 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto text-xl mb-3" >
< i class = "fa-solid fa-lock" ></ i >
</ div >
< h3 class = "text-base font-bold text-slate-800" > Modul Kerja Mandiri Tidak Aktif </ h3 >
< p class = "text-xs text-slate-500 max-w-md mx-auto mt-1" >
Akun Anda saat ini tidak memiliki izin akses untuk pengisian formulir Pemeriksaan P2H maupun Timesheet . Silakan hubungi Administrator jika membutuhkan akses operasional ini .
</ p >
</ div >
@ endif
{{ -- TABEL / RIWAYAT PERJALANAN SAYA ( BUKTI DIGITAL PENGEMUDI ) -- }}
@ if ( isset ( $myRecentActivities ) && $myRecentActivities -> isNotEmpty ())
< div class = "bg-white rounded-2xl border border-slate-200 p-5 sm:p-6 shadow-sm space-y-4" >
< div class = "flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-3 border-b border-slate-100" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-8 h-8 rounded-xl bg-slate-100 text-slate-700 flex items-center justify-center text-sm font-bold flex-shrink-0" >
< i class = "fa-solid fa-clock-rotate-left" ></ i >
</ div >
< div >
< h3 class = "text-sm sm:text-base font-black text-slate-900 tracking-tight" > Riwayat Perjalanan Terakhir Saya </ h3 >
< p class = "text-xs text-slate-500" > Catatan mobilisasi kendaraan yang pernah Anda isi di sistem .</ p >
</ div >
</ div >
2026-10-28 14:58:54 +07:00
< div class = "flex items-center gap-3 self-start sm:self-center" >
< span class = "text-xs font-semibold text-slate-400" >
{{ $myRecentActivities -> count () }} Perjalanan Terbaru
</ span >
< a href = "{{ route('employee.history') }}"
class = "inline-flex items-center text-xs font-bold text-[#1b5e20] hover:underline" >
< span > Lihat Seluruh Riwayat </ span >
< i class = "fa-solid fa-arrow-right text-[10px] ml-1" ></ i >
</ a >
</ div >
2026-10-19 23:21:55 +07:00
</ div >
< div class = "overflow-x-auto -mx-5 sm:mx-0" >
< table class = "w-full text-xs text-left min-w-[640px]" >
< thead >
< tr class = "bg-slate-50 text-slate-600 font-bold uppercase tracking-wider text-[10px] border-b border-slate-200" >
< th class = "py-2.5 px-4" > Waktu </ th >
< th class = "py-2.5 px-4" > Unit Kendaraan </ th >
< th class = "py-2.5 px-4" > Pos Gerbang </ th >
< th class = "py-2.5 px-4 text-center" > Arah </ th >
< th class = "py-2.5 px-4 text-right" > Odometer & Jarak </ th >
< th class = "py-2.5 px-4 text-center" > Status </ th >
</ tr >
</ thead >
< tbody class = "divide-y divide-slate-100 text-slate-700" >
@ foreach ( $myRecentActivities as $act )
< tr class = "hover:bg-slate-50/60 transition" >
< td class = "py-3 px-4 whitespace-nowrap" >
< span class = "font-bold text-slate-900 block" > {{ $act -> recorded_at -> locale ( 'id' ) -> translatedFormat ( 'd M Y' ) }} </ span >
< span class = "text-[11px] text-slate-400 block" > {{ $act -> recorded_at -> format ( 'H:i' ) }} WIB </ span >
</ td >
< td class = "py-3 px-4 whitespace-nowrap" >
< span class = "font-bold text-slate-800 font-mono text-xs block" > {{ $act -> vehicle -> code }} </ span >
< span class = "text-[11px] text-slate-500 block truncate max-w-[140px]" > {{ $act -> vehicle -> brand_type }} </ span >
</ td >
< td class = "py-3 px-4 whitespace-nowrap text-slate-600 font-medium" >
{{ $act -> gate -> name }}
</ td >
< td class = "py-3 px-4 text-center whitespace-nowrap" >
@ if ( $act -> direction === 'in' )
< span class = "inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200" >
MASUK
</ span >
@ else
< span class = "inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-blue-50 text-blue-700 border border-blue-200" >
KELUAR
</ span >
@ endif
</ td >
< td class = "py-3 px-4 text-right whitespace-nowrap font-mono" >
< div class = "font-bold text-slate-900" > {{ number_format ( $act -> current_km , 0 , ',' , '.' ) }} KM </ div >
< div class = "text-[11px] text-emerald-600 font-semibold" >+ {{ number_format ( $act -> distance , 0 , ',' , '.' ) }} KM </ div >
@ if ( $act -> is_corrected )
< span class = "inline-block mt-0.5 px-1.5 py-0.2 rounded text-[9px] font-bold bg-amber-50 text-amber-800 border border-amber-200" title = "Dikoreksi QMA: {{ $act->correction_reason }}" >
Terkoreksi QMA
</ span >
@ endif
</ td >
< td class = "py-3 px-4 text-center whitespace-nowrap" >
@ if ( $act -> validation_status === 'approved' )
< span class = "inline-flex items-center px-2.5 py-1 rounded-lg text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200" title = "Divalidasi oleh: {{ $act->securityGuard ->name ?? 'Satpam' }}" >
< i class = "fa-solid fa-circle-check mr-1 text-emerald-600" ></ i > Disetujui
</ span >
@ elseif ( $act -> validation_status === 'cancelled' )
2026-10-22 16:13:24 +07:00
@ if ( $act -> isCancelledBySystem ())
< div class = "inline-flex flex-col items-center" >
< span class = "inline-flex items-center px-2 py-0.5 rounded-lg text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200" title = "{{ $act->rejection_note }}" >
< i class = "fa-solid fa-robot mr-1 text-amber-600" ></ i > Batal Sistem
</ span >
< span class = "text-[9px] text-amber-600 mt-0.5 font-medium" > Timeout > 5 Jam </ span >
</ div >
@ else
< div class = "inline-flex flex-col items-center" >
< span class = "inline-flex items-center px-2 py-0.5 rounded-lg text-[10px] font-bold bg-slate-100 text-slate-700 border border-slate-200" title = "{{ $act->rejection_note }}" >
< i class = "fa-solid fa-user-xmark mr-1 text-slate-500" ></ i > Batal Pengemudi
</ span >
@ if ( $act -> rejection_note && $act -> rejection_note !== 'Dibatalkan mandiri oleh pengemudi' )
< span class = "text-[9px] text-slate-500 mt-0.5 truncate max-w-[120px]" title = "{{ $act->rejection_note }}" > {{ $act -> rejection_note }} </ span >
@ endif
</ div >
@ endif
2026-10-19 23:21:55 +07:00
@ elseif ( $act -> validation_status === 'rejected' )
< span class = "inline-flex items-center px-2.5 py-1 rounded-lg text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200" title = "Alasan: {{ $act->rejection_note }}" >
< i class = "fa-solid fa-circle-xmark mr-1 text-rose-600" ></ i > Ditolak
</ span >
@ else
< span class = "inline-flex items-center px-2.5 py-1 rounded-lg text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200 animate-pulse" >
< i class = "fa-solid fa-clock mr-1 text-amber-600" ></ i > Menunggu Satpam
</ span >
@ endif
</ td >
</ tr >
@ endforeach
</ tbody >
</ table >
</ div >
</ div >
2026-10-22 16:40:04 +07:00
@ else
< div class = "bg-white rounded-2xl border border-slate-200 p-6 text-center shadow-sm" >
< div class = "w-11 h-11 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-2 text-lg" >
< i class = "fa-solid fa-clock-rotate-left" ></ i >
</ div >
< h4 class = "text-xs font-bold text-slate-700" > Belum Ada Riwayat Perjalanan </ h4 >
< p class = "text-[11px] text-slate-400 mt-1 max-w-sm mx-auto" >
Catatan mobilisasi unit kendaraan ringan ( LV ) yang Anda kendarai akan otomatis muncul di sini setelah Anda mengisi formulir perjalanan .
</ p >
2026-10-28 14:58:54 +07:00
< div class = "mt-3" >
< a href = "{{ route('employee.history') }}" class = "text-xs font-bold text-[#1b5e20] hover:underline" >
Buka Halaman Riwayat Saya & rarr ;
</ a >
</ div >
2026-10-22 16:40:04 +07:00
</ div >
2026-10-19 23:21:55 +07:00
@ endif
</ div >
{{ -- MODAL 1 : KOREKSI ODOMETER DRIVER ( HANYA STATUS PENDING ) -- }}
< div id = "driverEditKmModal"
2026-10-27 20:44:35 +07:00
data - backdrop = "static"
2026-10-19 23:21:55 +07:00
class = "hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
aria - labelledby = "modal-title" role = "dialog" aria - modal = "true" >
< div class = "relative z-10 bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-lg w-full border border-slate-200 animate-scale-in" >
< form id = "driverEditKmForm" method = "POST" action = "" >
@ csrf
< div class = "p-5 sm:p-6 space-y-4" >
< div class = "flex items-center justify-between pb-3 border-b border-slate-100" >
< div class = "flex items-center space-x-2.5" >
< div class = "w-9 h-9 rounded-xl bg-amber-50 text-amber-700 flex items-center justify-center text-base font-bold flex-shrink-0 border border-amber-200" >
< i class = "fa-solid fa-pen-to-square" ></ i >
</ div >
< div >
< h3 class = "font-bold text-slate-800 text-sm sm:text-base" > Koreksi Angka Odometer ( KM ) </ h3 >
< p class = "text-xs text-slate-500" > Perbaiki angka KM sebelum diverifikasi oleh Satpam di pos gerbang .</ p >
</ div >
</ div >
< button type = "button" onclick = "closeDriverEditKmModal()" class = "text-slate-400 hover:text-slate-600 text-lg cursor-pointer" >
< i class = "fa-solid fa-xmark" ></ i >
</ button >
</ div >
2026-10-20 19:36:54 +07:00
{{ -- Info Unit & Perjalanan -- }}
2026-10-19 23:21:55 +07:00
< div class = "bg-slate-50 p-3.5 rounded-xl border border-slate-200 text-xs space-y-1.5 font-medium text-slate-600" >
< div class = "flex justify-between" >
2026-10-20 19:36:54 +07:00
< span class = "text-slate-400" > Nomor Perjalanan :</ span >
2026-10-19 23:21:55 +07:00
< span id = "modalEditTrxNo" class = "font-mono font-bold text-slate-800" >-</ span >
</ div >
< div class = "flex justify-between" >
< span class = "text-slate-400" > Unit Kendaraan :</ span >
< span id = "modalEditVehicleCode" class = "font-mono font-bold text-slate-800" >-</ span >
</ div >
< div class = "flex justify-between" >
< span class = "text-slate-400" > KM Awal Sebelumnya :</ span >
< span id = "modalEditPreviousKmText" class = "font-mono font-bold text-slate-800" >- KM </ span >
</ div >
</ div >
{{ -- Input Angka KM Baru -- }}
< div >
< label for = "driverInputCurrentKm" class = "block text-xs font-bold text-slate-700 mb-1.5 uppercase tracking-wider" >
Angka Odometer Saat Ini ( KM ) < span class = "text-rose-500" >*</ span >
</ label >
< div class = "relative" >
< input type = "number"
step = "0.01"
name = "current_km"
id = "driverInputCurrentKm"
required
oninput = "calculateDriverDistancePreview()"
placeholder = "Contoh: 50150"
class = "w-full pl-3.5 pr-14 py-2.5 rounded-xl border border-slate-300 text-sm font-mono font-bold text-slate-800 focus:border-[#1b5e20] focus:ring-3 focus:ring-[#1b5e20]/10 transition" >
< span class = "absolute inset-y-0 right-0 pr-3.5 flex items-center pointer-events-none text-xs font-bold text-slate-400" >
KM
</ span >
</ div >
< input type = "hidden" id = "driverModalPreviousKm" value = "0" >
</ div >
{{ -- Live Preview Kalkulasi Jarak Tempuh -- }}
< div id = "driverDistancePreviewBox" class = "p-3 bg-emerald-50 border border-emerald-200 rounded-xl text-xs flex items-center justify-between" >
< span class = "text-emerald-800 font-medium" > Estimasi Jarak Tempuh Baru :</ span >
< span id = "driverDistancePreviewValue" class = "font-mono font-bold text-emerald-800 text-sm" >+ 0 KM </ span >
</ div >
{{ -- Warning jika angka lebih kecil dari KM awal -- }}
< div id = "driverDistanceErrorBox" class = "hidden p-3 bg-rose-50 border border-rose-200 rounded-xl text-xs text-rose-800 font-medium" >
< i class = "fa-solid fa-triangle-exclamation mr-1 text-rose-600" ></ i >
< span > Angka KM baru tidak boleh lebih kecil dari KM awal ( < span id = "driverDistanceMinText" > 0 </ span > KM ) .</ span >
</ div >
</ div >
< div class = "bg-slate-50 px-6 py-3.5 border-t border-slate-100 flex items-center justify-end space-x-2" >
< button type = "button" onclick = "closeDriverEditKmModal()" class = "px-4 py-2 text-xs font-bold text-slate-600 hover:text-slate-800 hover:bg-slate-200/60 rounded-xl transition cursor-pointer" >
Batal
</ button >
< button type = "submit" id = "btnSubmitDriverEditKm" class = "px-5 py-2 text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] rounded-xl shadow-xs transition flex items-center space-x-1.5 cursor-pointer" >
< i class = "fa-solid fa-check text-xs" ></ i >
< span > Simpan Perbaikan Odometer </ span >
</ button >
</ div >
</ form >
2026-10-15 13:53:52 +07:00
</ div >
</ div >
2026-10-19 23:21:55 +07:00
2026-10-20 19:36:54 +07:00
{{ -- MODAL 2 : KONFIRMASI BATALKAN PERJALANAN -- }}
2026-10-19 23:21:55 +07:00
< div id = "driverCancelModal"
2026-10-27 20:44:35 +07:00
data - backdrop = "static"
2026-10-19 23:21:55 +07:00
class = "hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
aria - labelledby = "modal-title" role = "dialog" aria - modal = "true" >
< div class = "relative z-10 bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-md w-full border border-slate-200 animate-scale-in" >
< form id = "driverCancelForm" method = "POST" action = "" >
@ csrf
< div class = "p-6 space-y-4" >
< div class = "w-12 h-12 rounded-full bg-rose-100 text-rose-600 flex items-center justify-center text-xl mx-auto" >
< i class = "fa-solid fa-trash-can" ></ i >
</ div >
< div class = "text-center space-y-1" >
2026-10-20 19:36:54 +07:00
< h3 class = "font-bold text-slate-900 text-base" > Batalkan Perjalanan ?</ h3 >
< p class = "text-xs text-slate-500" > Perjalanan untuk unit < strong id = "modalCancelVehicleCode" class = "text-slate-800 font-mono" >-</ strong > ( < span id = "modalCancelTrxNo" >-</ span > ) akan dibatalkan dan dihapus dari antrean pos Satpam .</ p >
2026-10-19 23:21:55 +07:00
</ div >
< div >
< label for = "cancelReasonInput" class = "block text-xs font-bold text-slate-700 mb-1.5" >
Alasan Pembatalan ( Opsional )
</ label >
< select name = "cancel_reason" id = "cancelReasonInput" class = "w-full text-xs rounded-xl border border-slate-300 p-2.5 text-slate-800 focus:outline-none focus:border-rose-500 focus:ring-2 focus:ring-rose-500/10" >
< option value = "Dibatalkan mandiri oleh pengemudi (Batal jalan)" > Batal melakukan perjalanan </ option >
< option value = "Salah input unit mobil" > Salah memilih unit mobil </ option >
< option value = "Perubahan pengemudi/tugas" > Perubahan penugasan kerja </ option >
< option value = "Salah input form / input ulang" > Ingin mengisi ulang formulir dari awal </ option >
</ select >
</ div >
</ div >
< div class = "bg-slate-50 px-6 py-3.5 border-t border-slate-100 flex items-center justify-end space-x-2" >
< button type = "button" onclick = "closeDriverCancelModal()" class = "px-4 py-2 text-xs font-bold text-slate-600 hover:text-slate-800 rounded-xl transition cursor-pointer" >
Kembali
</ button >
< button type = "submit" class = "px-5 py-2 text-xs font-bold text-white bg-rose-600 hover:bg-rose-700 active:scale-[0.99] rounded-xl shadow-xs transition flex items-center space-x-1.5 cursor-pointer" >
< i class = "fa-solid fa-ban text-xs" ></ i >
2026-10-20 19:36:54 +07:00
< span > Ya , Batalkan Perjalanan </ span >
2026-10-19 23:21:55 +07:00
</ button >
</ div >
</ form >
</ div >
</ div >
2026-10-23 10:10:03 +07:00
{{ -- MODAL 3 : IN - APP LIVE QR / BARCODE SCANNER UNIT ( LANGSUNG LIVE STREAMING KAMERA KE FORM ) -- }}
2026-10-19 23:21:55 +07:00
< div id = "unitQrScannerModal"
2026-10-23 10:10:03 +07:00
class = "hidden fixed inset-0 z-50 bg-slate-900/80 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
2026-10-19 23:21:55 +07:00
aria - labelledby = "qr-scanner-title" role = "dialog" aria - modal = "true" >
2026-10-23 10:10:03 +07:00
< div class = "relative z-10 bg-slate-900 rounded-3xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-md w-full border border-slate-800 animate-scale-in text-white" >
<!-- Input File Tersembunyi ( Hanya sebagai fallback darurat ) -->
2026-10-22 16:25:24 +07:00
< input type = "file" id = "qrNativeCameraInput" accept = "image/*" capture = "environment" class = "hidden" onchange = "handleQrFileSelected(event)" >
< input type = "file" id = "qrGalleryInput" accept = "image/*" class = "hidden" onchange = "handleQrFileSelected(event)" >
2026-10-23 10:10:03 +07:00
<!-- Header Modal Scanner Modern -->
< div class = "p-4 bg-slate-900 border-b border-slate-800 flex items-center justify-between" >
< div class = "flex items-center space-x-3" >
< div class = "w-9 h-9 rounded-xl bg-emerald-500/20 text-emerald-400 flex items-center justify-center text-sm flex-shrink-0" >
< i class = "fa-solid fa-barcode" ></ i >
2026-10-19 23:21:55 +07:00
</ div >
< div >
2026-10-23 10:10:03 +07:00
< h3 id = "qr-scanner-title" class = "font-extrabold text-sm text-white" > Live Scanner Barcode Unit </ h3 >
< p class = "text-[11px] text-slate-400" > Arahkan kamera langsung ke stiker barcode / QR unit </ p >
2026-10-19 23:21:55 +07:00
</ div >
</ div >
2026-10-23 10:10:03 +07:00
< button type = "button" onclick = "closeUnitQrScannerModal()" class = "w-8 h-8 rounded-full bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white flex items-center justify-center transition cursor-pointer" >
< i class = "fa-solid fa-xmark text-sm" ></ i >
2026-10-19 23:21:55 +07:00
</ button >
</ div >
2026-10-23 10:10:03 +07:00
<!-- Viewport Kamera Live dengan Efek Scanner Viewfinder -->
< div class = "relative bg-black flex flex-col items-center justify-center overflow-hidden min-h-[340px]" >
<!-- Kontainer Video Html5Qrcode -->
< div id = "qr-reader" class = "w-full" ></ div >
2026-10-22 16:25:24 +07:00
2026-10-23 10:10:03 +07:00
<!-- Viewfinder Overlay ( Corner Brackets & Laser Scan Line ) -->
< div id = "qrScanOverlay" class = "absolute inset-0 pointer-events-none flex items-center justify-center" >
< div class = "relative w-64 h-64 border border-emerald-500/25 rounded-2xl" >
<!-- Corner Highlights -->
< div class = "absolute -top-1 -left-1 w-6 h-6 border-t-3 border-l-3 border-emerald-400 rounded-tl-xl" ></ div >
< div class = "absolute -top-1 -right-1 w-6 h-6 border-t-3 border-r-3 border-emerald-400 rounded-tr-xl" ></ div >
< div class = "absolute -bottom-1 -left-1 w-6 h-6 border-b-3 border-l-3 border-emerald-400 rounded-bl-xl" ></ div >
< div class = "absolute -bottom-1 -right-1 w-6 h-6 border-b-3 border-r-3 border-emerald-400 rounded-br-xl" ></ div >
<!-- Animated Laser Sweep Line -->
< div class = "scanner-laser-line" ></ div >
</ div >
2026-10-22 16:25:24 +07:00
</ div >
2026-10-23 10:10:03 +07:00
<!-- Loading Indicator Live Video -->
< div id = "qrScannerLoading" class = "absolute inset-0 flex flex-col items-center justify-center bg-slate-950/90 text-white space-y-3 z-20" >
< i class = "fa-solid fa-circle-notch fa-spin text-3xl text-emerald-400" ></ i >
< span class = "text-xs text-slate-200 font-bold" > Membuka Kamera Live ...</ span >
< span class = "text-[11px] text-slate-400" > Pastikan izin kamera diizinkan di peramban </ span >
</ div >
<!-- Loading Indicator Analisis Foto ( Fallback ) -->
2026-10-22 16:25:24 +07:00
< div id = "qrScannerFileLoadingOverlay" class = "hidden absolute inset-0 flex flex-col items-center justify-center bg-slate-950/95 text-white space-y-3 z-30 p-4 text-center" >
< i class = "fa-solid fa-spinner fa-spin text-3xl text-emerald-400" ></ i >
< span class = "text-xs text-slate-200 font-bold" > Membaca Barcode dari Foto ...</ span >
</ div >
2026-10-23 10:10:03 +07:00
<!-- Error State / Izin Kamera Ditolak / HTTP Limitation -->
< div id = "qrScannerError" class = "hidden absolute inset-0 p-6 flex flex-col items-center justify-center bg-slate-950/95 text-center text-white space-y-3.5 z-25" >
2026-10-22 16:25:24 +07:00
< div class = "w-12 h-12 rounded-full bg-amber-500/20 text-amber-400 flex items-center justify-center text-xl" >
2026-10-23 10:10:03 +07:00
< i class = "fa-solid fa-triangle-exclamation" ></ i >
2026-10-22 16:25:24 +07:00
</ div >
2026-10-23 10:10:03 +07:00
< h4 class = "font-bold text-sm text-amber-200" id = "qrScannerErrorTitle" > Kamera Live Memerlukan Izin / HTTPS </ h4 >
< p class = "text-xs text-slate-300 leading-relaxed max-w-xs" id = "qrScannerErrorMsg" >
Peramban membatasi streaming video langsung . Silakan gunakan tombol jepret foto di bawah atau izinkan akses kamera di setelan browser .
2026-10-22 16:25:24 +07:00
</ p >
2026-10-23 10:10:03 +07:00
< div class = "w-full space-y-2 pt-2 max-w-xs" >
2026-10-22 16:25:24 +07:00
< button type = "button"
onclick = "document.getElementById('qrNativeCameraInput').click()"
class = "w-full bg-emerald-600 hover:bg-emerald-500 text-white font-bold py-2.5 px-4 rounded-xl text-xs shadow-md transition flex items-center justify-center space-x-2 cursor-pointer" >
< i class = "fa-solid fa-camera" ></ i >
< span > Gunakan Kamera HP ( Ambil Foto ) </ span >
2026-10-19 23:21:55 +07:00
</ button >
2026-10-22 16:25:24 +07:00
< div class = "flex items-center space-x-2" >
< button type = "button" onclick = "startQrScanner()" class = "flex-1 py-2 bg-slate-800 hover:bg-slate-700 text-xs text-slate-200 font-bold rounded-xl transition cursor-pointer" >
< i class = "fa-solid fa-rotate-right mr-1" ></ i > Coba Live Lagi
</ button >
< a href = "{{ route('timesheet.index') }}" class = "flex-1 py-2 bg-slate-800 hover:bg-slate-700 text-xs text-slate-200 text-center font-bold rounded-xl transition" >
Pilih Manual
</ a >
</ div >
2026-10-19 23:21:55 +07:00
</ div >
</ div >
2026-10-23 10:10:03 +07:00
<!-- Overlay Sukses Terdeteksi ( Instan ) -->
< div id = "qrScannerSuccessOverlay" class = "hidden absolute inset-0 flex flex-col items-center justify-center bg-emerald-950/95 text-white space-y-3 z-40 animate-fade-in" >
< div class = "w-14 h-14 rounded-full bg-emerald-500 text-slate-950 flex items-center justify-center text-2xl shadow-lg" >
< i class = "fa-solid fa-check" ></ i >
</ div >
< div class = "text-center" >
< h4 class = "text-sm font-black text-emerald-300" id = "qrScannedUnitCode" > Barcode Terdeteksi !</ h4 >
< p class = "text-[11px] text-slate-300 mt-0.5" > Membuka formulir timesheet unit ...</ p >
2026-10-19 23:21:55 +07:00
</ div >
</ div >
</ div >
2026-10-23 10:10:03 +07:00
<!-- Bar Kontrol Bawah : Switch Kamera & Opsi Darurat -->
< div class = "p-3 bg-slate-900 border-t border-slate-800 flex items-center justify-between text-xs" >
<!-- Tombol Switch Kamera Depan / Belakang -->
< button type = "button"
id = "btnSwitchCamera"
onclick = "switchCamera()"
class = "hidden items-center space-x-1.5 px-3 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 font-semibold transition cursor-pointer" >
< i class = "fa-solid fa-camera-rotate text-emerald-400" ></ i >
< span > Ganti Kamera </ span >
</ button >
<!-- Link Darurat Manual / Galeri -->
< div class = "flex items-center space-x-3 ml-auto text-slate-400 text-[11px]" >
< button type = "button" onclick = "document.getElementById('qrGalleryInput').click()" class = "hover:text-emerald-400 font-semibold transition cursor-pointer" >
< i class = "fa-solid fa-image mr-1" ></ i > Dari Galeri
</ button >
< span class = "text-slate-700" >& bull ; </ span >
< a href = "{{ route('timesheet.index') }}" class = "hover:text-emerald-400 font-semibold transition" >
Pilih Manual & rarr ;
</ a >
</ div >
2026-10-19 23:21:55 +07:00
</ div >
</ div >
</ div >
2026-10-22 16:13:24 +07:00
{{ -- MODAL 4 : NOTIFIKASI HASIL VALIDASI POS GERBANG ( POLLING REAL - TIME ) -- }}
< div id = "validationNotificationModal"
class = "hidden fixed inset-0 z-50 bg-slate-900/70 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
aria - labelledby = "validationNotificationTitle" role = "dialog" aria - modal = "true" >
< div id = "validationNotificationCard" class = "relative z-10 bg-white rounded-2xl max-w-md w-full shadow-2xl border border-slate-200 overflow-hidden transform transition-all duration-300 scale-95" >
< div id = "validationNotificationBanner" class = "p-6 text-center text-white bg-gradient-to-br from-emerald-600 to-[#1b5e20]" >
< div id = "validationNotificationIcon" class = "w-16 h-16 mx-auto rounded-full bg-white/20 flex items-center justify-center text-3xl mb-3 shadow-inner" >
< i class = "fa-solid fa-circle-check text-emerald-100" ></ i >
</ div >
< h3 id = "validationNotificationTitle" class = "text-lg font-black tracking-tight" > Perjalanan Disetujui !</ h3 >
< p id = "validationNotificationSubtitle" class = "text-xs text-white/90 mt-1" > Verifikasi di Pos Gerbang Berhasil </ p >
</ div >
< div class = "p-6 space-y-4" >
< div class = "bg-slate-50 rounded-xl p-4 border border-slate-200/80 text-xs space-y-2.5" >
< div class = "flex justify-between items-center pb-2 border-b border-slate-200/60" >
< span class = "text-slate-400 font-medium" > No . Transaksi :</ span >
< span id = "validationTrxNo" class = "font-mono font-bold text-slate-800" >-</ span >
</ div >
< div class = "flex justify-between items-center pb-2 border-b border-slate-200/60" >
< span class = "text-slate-400 font-medium" > Unit Kendaraan :</ span >
< span id = "validationVehicle" class = "font-bold text-slate-800" >-</ span >
</ div >
< div class = "flex justify-between items-center pb-2 border-b border-slate-200/60" >
< span class = "text-slate-400 font-medium" > Pos Gerbang :</ span >
< span id = "validationGate" class = "font-bold text-slate-800" >-</ span >
</ div >
< div class = "flex justify-between items-center" >
< span class = "text-slate-400 font-medium" > Petugas Satpam :</ span >
< span id = "validationGuard" class = "font-bold text-slate-800" >-</ span >
</ div >
< div id = "validationNoteRow" class = "pt-2 border-t border-slate-200 hidden" >
< span class = "text-slate-400 font-medium block mb-1" > Catatan Penolakan :</ span >
< p id = "validationNote" class = "text-slate-700 italic bg-white p-2.5 rounded-lg border border-slate-200 text-[11px]" >-</ p >
</ div >
</ div >
< button type = "button"
id = "validationDismissBtn"
onclick = "handleValidationDismiss()"
class = "w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm shadow-md transition flex items-center justify-center space-x-2 cursor-pointer" >
< span > Lanjutkan ke Dashboard </ span >
< i class = "fa-solid fa-arrow-right text-xs" ></ i >
</ button >
</ div >
</ div >
</ div >
2026-10-19 23:21:55 +07:00
< style >
#qr-reader {
border : none ! important ;
2026-10-23 10:10:03 +07:00
width : 100 % ! important ;
2026-10-19 23:21:55 +07:00
}
#qr-reader video {
width : 100 % ! important ;
height : auto ! important ;
2026-10-23 10:10:03 +07:00
max - height : 380 px ! important ;
border - radius : 1 rem ;
2026-10-19 23:21:55 +07:00
object - fit : cover ;
}
#qr-reader__scan_region {
background : transparent ! important ;
}
#qr-reader__scan_region video {
2026-10-23 10:10:03 +07:00
border - radius : 1 rem ;
}
#qr-reader__dashboard {
display : none ! important ;
}
@ keyframes scanLaserLine {
0 % { top : 6 % ; opacity : 0.2 ; }
50 % { top : 92 % ; opacity : 1 ; }
100 % { top : 6 % ; opacity : 0.2 ; }
}
. scanner - laser - line {
position : absolute ;
left : 6 % ;
right : 6 % ;
height : 2.5 px ;
background : linear - gradient ( 90 deg , transparent , #10b981 25%, #34d399 50%, #10b981 75%, transparent);
box - shadow : 0 0 12 px #10b981, 0 0 4px #34d399;
animation : scanLaserLine 2 s ease - in - out infinite ;
2026-10-19 23:21:55 +07:00
}
</ style >
2026-10-22 16:25:24 +07:00
< script src = "{{ asset('vendor/html5-qrcode/html5-qrcode.min.js') }}" ></ script >
< script >
if ( typeof Html5Qrcode === 'undefined' ) {
document . write ( '<script src="https://cdnjs.cloudflare.com/ajax/libs/html5-qrcode/2.3.8/html5-qrcode.min.js"><\/script>' );
}
</ script >
2026-10-19 23:21:55 +07:00
< script >
function openDriverEditKmModal ( data ) {
document . getElementById ( 'modalEditTrxNo' ) . innerText = data . trx ;
document . getElementById ( 'modalEditVehicleCode' ) . innerText = data . code ;
document . getElementById ( 'modalEditPreviousKmText' ) . innerText = Number ( data . previous_km ) . toLocaleString ( 'id-ID' ) + ' KM' ;
document . getElementById ( 'driverModalPreviousKm' ) . value = data . previous_km ;
document . getElementById ( 'driverInputCurrentKm' ) . value = data . current_km ;
document . getElementById ( 'driverDistanceMinText' ) . innerText = Number ( data . previous_km ) . toLocaleString ( 'id-ID' );
const form = document . getElementById ( 'driverEditKmForm' );
form . action = '/karyawan/aktivitas/' + data . id + '/update-km' ;
calculateDriverDistancePreview ();
document . getElementById ( 'driverEditKmModal' ) . classList . remove ( 'hidden' );
}
function closeDriverEditKmModal () {
document . getElementById ( 'driverEditKmModal' ) . classList . add ( 'hidden' );
}
function calculateDriverDistancePreview () {
const prevKm = parseFloat ( document . getElementById ( 'driverModalPreviousKm' ) . value ) || 0 ;
const inputVal = parseFloat ( document . getElementById ( 'driverInputCurrentKm' ) . value ) || 0 ;
const diff = inputVal - prevKm ;
const previewBox = document . getElementById ( 'driverDistancePreviewBox' );
const errorBox = document . getElementById ( 'driverDistanceErrorBox' );
const submitBtn = document . getElementById ( 'btnSubmitDriverEditKm' );
const valText = document . getElementById ( 'driverDistancePreviewValue' );
if ( inputVal < prevKm ) {
previewBox . classList . add ( 'hidden' );
errorBox . classList . remove ( 'hidden' );
submitBtn . disabled = true ;
submitBtn . classList . add ( 'opacity-50' , 'cursor-not-allowed' );
} else {
previewBox . classList . remove ( 'hidden' );
errorBox . classList . add ( 'hidden' );
submitBtn . disabled = false ;
submitBtn . classList . remove ( 'opacity-50' , 'cursor-not-allowed' );
valText . innerText = '+' + diff . toLocaleString ( 'id-ID' ) + ' KM' ;
}
}
function openDriverCancelModal ( data ) {
document . getElementById ( 'modalCancelTrxNo' ) . innerText = data . trx ;
document . getElementById ( 'modalCancelVehicleCode' ) . innerText = data . code ;
const form = document . getElementById ( 'driverCancelForm' );
form . action = '/karyawan/aktivitas/' + data . id + '/cancel' ;
document . getElementById ( 'driverCancelModal' ) . classList . remove ( 'hidden' );
}
function closeDriverCancelModal () {
document . getElementById ( 'driverCancelModal' ) . classList . add ( 'hidden' );
}
2026-10-23 10:10:03 +07:00
// --- IN-APP LIVE QR/BARCODE SCANNER LOGIC ---
2026-10-19 23:21:55 +07:00
let html5QrScanner = null ;
let isScanProcessing = false ;
2026-10-23 10:10:03 +07:00
let availableCameras = [];
let currentCameraIndex = 0 ;
// Suara Beep saat Barcode Berhasil Terdeteksi (Web Audio API)
function playScanBeep () {
try {
const AudioCtx = window . AudioContext || window . webkitAudioContext ;
if ( AudioCtx ) {
const audioCtx = new AudioCtx ();
const oscillator = audioCtx . createOscillator ();
const gainNode = audioCtx . createGain ();
oscillator . type = 'sine' ;
oscillator . frequency . setValueAtTime ( 880 , audioCtx . currentTime ); // 880 Hz beep nada tinggi
gainNode . gain . setValueAtTime ( 0.25 , audioCtx . currentTime );
gainNode . gain . exponentialRampToValueAtTime ( 0.01 , audioCtx . currentTime + 0.15 );
oscillator . connect ( gainNode );
gainNode . connect ( audioCtx . destination );
oscillator . start ();
oscillator . stop ( audioCtx . currentTime + 0.15 );
}
} catch ( e ) {
// Audio context tidak diizinkan atau dinonaktifkan
}
if ( navigator . vibrate ) {
try { navigator . vibrate ([ 80 , 40 , 80 ]); } catch ( e ) {}
}
}
2026-10-19 23:21:55 +07:00
function parseScannedCode ( decodedText ) {
if ( ! decodedText ) return null ;
decodedText = decodedText . trim ();
2026-10-23 10:10:03 +07:00
// 1. Cek jika barcode berupa URL penuh (misal: http://.../gate-activity/LV-01)
2026-10-19 23:21:55 +07:00
try {
const url = new URL ( decodedText );
if ( url . pathname . includes ( '/gate-activity/' )) {
2026-10-23 10:10:03 +07:00
return url . pathname + ( url . search || '' );
2026-10-19 23:21:55 +07:00
}
} catch ( e ) {
2026-10-23 10:10:03 +07:00
// Bukan URL lengkap, lanjutkan parsing teks biasa
2026-10-19 23:21:55 +07:00
}
2026-10-23 10:10:03 +07:00
// 2. Format path parsial /gate-activity/...
2026-10-19 23:21:55 +07:00
if ( decodedText . startsWith ( '/gate-activity/' )) {
return decodedText ;
}
const match = decodedText . match ( / \ / gate - activity\ / ([ a - zA - Z0 - 9_ \ - ] + ) / i );
if ( match ) {
return '/gate-activity/' + match [ 1 ];
}
2026-10-23 10:10:03 +07:00
// 3. Format kode unit langsung (misal: "LV-01", "LV01", "KMH-LV-05")
2026-10-19 23:21:55 +07:00
const cleanCode = decodedText . replace ( / [ ^ a - zA - Z0 - 9_ \ - ] / g , '' );
if ( cleanCode . length >= 2 ) {
2026-10-23 10:10:03 +07:00
return '/gate-activity/' + encodeURIComponent ( cleanCode );
2026-10-19 23:21:55 +07:00
}
return null ;
}
function openUnitQrScannerModal () {
isScanProcessing = false ;
document . getElementById ( 'unitQrScannerModal' ) . classList . remove ( 'hidden' );
document . getElementById ( 'qrScannerSuccessOverlay' ) . classList . add ( 'hidden' );
2026-10-22 16:25:24 +07:00
const fileLoadingEl = document . getElementById ( 'qrScannerFileLoadingOverlay' );
if ( fileLoadingEl ) fileLoadingEl . classList . add ( 'hidden' );
2026-10-19 23:21:55 +07:00
startQrScanner ();
}
async function closeUnitQrScannerModal () {
await stopQrScanner ();
document . getElementById ( 'unitQrScannerModal' ) . classList . add ( 'hidden' );
isScanProcessing = false ;
}
async function stopQrScanner () {
if ( html5QrScanner ) {
try {
if ( html5QrScanner . isScanning ) {
await html5QrScanner . stop ();
}
html5QrScanner . clear ();
} catch ( e ) {
console . error ( 'Error stopping scanner:' , e );
}
html5QrScanner = null ;
}
}
2026-10-23 10:10:03 +07:00
// Handler cadangan jika scan lewat foto galeri atau kamera native HP
2026-10-22 16:25:24 +07:00
async function handleQrFileSelected ( event ) {
const file = event . target . files && event . target . files [ 0 ];
if ( ! file ) return ;
const fileLoadingEl = document . getElementById ( 'qrScannerFileLoadingOverlay' );
if ( fileLoadingEl ) fileLoadingEl . classList . remove ( 'hidden' );
await stopQrScanner ();
try {
if ( typeof Html5Qrcode === 'undefined' ) {
2026-10-23 10:10:03 +07:00
throw new Error ( 'Komponen pemindai barcode belum selesai dimuat.' );
2026-10-22 16:25:24 +07:00
}
const scanner = new Html5Qrcode ( "qr-reader" );
const decodedText = await scanner . scanFile ( file , true );
if ( fileLoadingEl ) fileLoadingEl . classList . add ( 'hidden' );
const targetUrl = parseScannedCode ( decodedText );
if ( targetUrl ) {
2026-10-23 10:10:03 +07:00
playScanBeep ();
2026-10-22 16:25:24 +07:00
const successOverlay = document . getElementById ( 'qrScannerSuccessOverlay' );
2026-10-23 10:10:03 +07:00
const unitTitle = document . getElementById ( 'qrScannedUnitCode' );
if ( unitTitle ) unitTitle . textContent = 'Unit Terdeteksi!' ;
2026-10-22 16:25:24 +07:00
if ( successOverlay ) successOverlay . classList . remove ( 'hidden' );
2026-10-23 10:10:03 +07:00
2026-10-22 16:25:24 +07:00
setTimeout (() => {
window . location . href = targetUrl ;
2026-10-23 10:10:03 +07:00
}, 300 );
2026-10-22 16:25:24 +07:00
} else {
2026-10-23 10:10:03 +07:00
alert ( `Barcode terdeteksi: "${decodedText}", namun format bukan kode unit yang valid.` );
2026-10-22 16:25:24 +07:00
}
} catch ( err ) {
if ( fileLoadingEl ) fileLoadingEl . classList . add ( 'hidden' );
console . error ( 'File scan error:' , err );
2026-10-23 10:10:03 +07:00
alert ( 'Barcode tidak terbaca dari foto. Pastikan stiker barcode tampak jelas dan tidak silau.' );
2026-10-22 16:25:24 +07:00
} finally {
event . target . value = '' ;
}
}
2026-10-19 23:21:55 +07:00
async function startQrScanner () {
const loadingEl = document . getElementById ( 'qrScannerLoading' );
const errorEl = document . getElementById ( 'qrScannerError' );
const errorMsg = document . getElementById ( 'qrScannerErrorMsg' );
2026-10-23 10:10:03 +07:00
const errorTitle = document . getElementById ( 'qrScannerErrorTitle' );
const switchBtn = document . getElementById ( 'btnSwitchCamera' );
const overlay = document . getElementById ( 'qrScanOverlay' );
2026-10-19 23:21:55 +07:00
loadingEl . classList . remove ( 'hidden' );
errorEl . classList . add ( 'hidden' );
2026-10-23 10:10:03 +07:00
if ( overlay ) overlay . classList . remove ( 'hidden' );
2026-10-19 23:21:55 +07:00
await stopQrScanner ();
if ( typeof Html5Qrcode === 'undefined' ) {
loadingEl . classList . add ( 'hidden' );
errorEl . classList . remove ( 'hidden' );
2026-10-23 10:10:03 +07:00
if ( errorTitle ) errorTitle . textContent = 'Gagal Memuat Scanner' ;
errorMsg . textContent = 'Komponen scanner kamera gagal dimuat. Periksa koneksi internet Anda atau gunakan tombol Ambil Foto Barcode di bawah.' ;
2026-10-22 16:25:24 +07:00
return ;
}
2026-10-23 10:10:03 +07:00
// Polyfill navigator.mediaDevices untuk peramban mobile
if ( navigator . mediaDevices === undefined ) {
navigator . mediaDevices = {};
}
if ( navigator . mediaDevices . getUserMedia === undefined ) {
navigator . mediaDevices . getUserMedia = function ( constraints ) {
const legacyGetUserMedia = navigator . webkitGetUserMedia || navigator . mozGetUserMedia || navigator . msGetUserMedia ;
if ( ! legacyGetUserMedia ) {
return Promise . reject ( new Error ( 'Kamera live tidak didukung pada peramban ini' ));
}
return new Promise ( function ( resolve , reject ) {
legacyGetUserMedia . call ( navigator , constraints , resolve , reject );
});
};
2026-10-19 23:21:55 +07:00
}
try {
html5QrScanner = new Html5Qrcode ( "qr-reader" );
2026-10-23 10:10:03 +07:00
// Konfigurasi performa tinggi (20 FPS) & scan box fleksibel
2026-10-19 23:21:55 +07:00
const config = {
2026-10-23 10:10:03 +07:00
fps : 20 ,
qrbox : ( viewfinderWidth , viewfinderHeight ) => {
const minEdge = Math . min ( viewfinderWidth , viewfinderHeight );
const qrboxEdge = Math . max ( 180 , Math . floor ( minEdge * 0.72 ));
return { width : qrboxEdge , height : qrboxEdge };
},
aspectRatio : 1.0 ,
experimentalFeatures : {
useBarCodeDetectorIfSupported : true
}
2026-10-19 23:21:55 +07:00
};
2026-10-22 16:25:24 +07:00
const onScanSuccess = ( decodedText ) => {
if ( isScanProcessing ) return ;
const targetUrl = parseScannedCode ( decodedText );
if ( targetUrl ) {
isScanProcessing = true ;
2026-10-23 10:10:03 +07:00
playScanBeep ();
2026-10-22 16:25:24 +07:00
const successOverlay = document . getElementById ( 'qrScannerSuccessOverlay' );
2026-10-23 10:10:03 +07:00
const unitTitle = document . getElementById ( 'qrScannedUnitCode' );
if ( unitTitle ) {
const parts = targetUrl . split ( '/' );
const code = parts [ parts . length - 1 ];
unitTitle . textContent = `Unit "${decodeURIComponent(code)}" Terdeteksi!` ;
}
2026-10-22 16:25:24 +07:00
if ( successOverlay ) successOverlay . classList . remove ( 'hidden' );
2026-10-23 10:10:03 +07:00
stopQrScanner () . finally (() => {
2026-10-22 16:25:24 +07:00
window . location . href = targetUrl ;
});
2026-10-19 23:21:55 +07:00
}
2026-10-22 16:25:24 +07:00
};
// Dapatkan daftar kamera perangkat
try {
2026-10-23 10:10:03 +07:00
availableCameras = await Html5Qrcode . getCameras ();
2026-10-22 16:25:24 +07:00
} catch ( camErr ) {
console . warn ( 'Gagal ambil daftar kamera:' , camErr );
2026-10-23 10:10:03 +07:00
availableCameras = [];
2026-10-22 16:25:24 +07:00
}
2026-10-23 10:10:03 +07:00
if ( availableCameras && availableCameras . length > 1 && switchBtn ) {
switchBtn . classList . remove ( 'hidden' );
switchBtn . classList . add ( 'inline-flex' );
}
if ( availableCameras && availableCameras . length > 0 ) {
// Pilih kamera belakang secara default
let rearIdx = availableCameras . findIndex ( c => {
2026-10-22 16:25:24 +07:00
const label = ( c . label || '' ) . toLowerCase ();
return label . includes ( 'back' ) || label . includes ( 'rear' ) || label . includes ( 'belakang' ) || label . includes ( 'environment' );
2026-10-23 10:10:03 +07:00
});
if ( rearIdx === - 1 ) rearIdx = availableCameras . length - 1 ;
currentCameraIndex = rearIdx ;
2026-10-22 16:25:24 +07:00
await html5QrScanner . start (
2026-10-23 10:10:03 +07:00
availableCameras [ currentCameraIndex ] . id ,
2026-10-22 16:25:24 +07:00
config ,
onScanSuccess ,
2026-10-23 10:10:03 +07:00
() => {}
2026-10-22 16:25:24 +07:00
);
} else {
2026-10-23 10:10:03 +07:00
// Fallback jika getCameras kosong tapi getUserMedia didukung
2026-10-22 16:25:24 +07:00
await html5QrScanner . start (
{ facingMode : "environment" },
config ,
onScanSuccess ,
2026-10-23 10:10:03 +07:00
() => {}
2026-10-22 16:25:24 +07:00
);
}
2026-10-19 23:21:55 +07:00
loadingEl . classList . add ( 'hidden' );
} catch ( err ) {
2026-10-22 16:25:24 +07:00
console . error ( 'Kamera scanner error:' , err );
2026-10-19 23:21:55 +07:00
loadingEl . classList . add ( 'hidden' );
errorEl . classList . remove ( 'hidden' );
2026-10-23 10:10:03 +07:00
if ( overlay ) overlay . classList . add ( 'hidden' );
2026-10-22 16:25:24 +07:00
2026-10-23 10:10:03 +07:00
let customMsg = 'Live kamera tidak dapat diakses di browser ini.' ;
if ( err && ( err . name === 'NotAllowedError' || err . name === 'PermissionDeniedError' )) {
if ( errorTitle ) errorTitle . textContent = 'Izin Kamera Belum Diaktifkan' ;
customMsg = 'Izin kamera ditolak di peramban. Silakan klik ikon gembok / setelan situs di samping alamat URL browser, lalu izinkan akses Kamera.' ;
} else if ( ! window . isSecureContext && window . location . protocol === 'http:' ) {
if ( errorTitle ) errorTitle . textContent = 'Akses Kamera Dibatasi oleh HTTP' ;
customMsg = 'Browser Chrome membatasi streaming kamera langsung di jaringan HTTP. Silakan gunakan tombol "Gunakan Kamera HP" di bawah ATAU akses aplikasi melalui HTTPS.' ;
2026-10-22 16:25:24 +07:00
} else if ( err && err . message ) {
customMsg = err . message ;
}
errorMsg . textContent = customMsg ;
2026-10-19 23:21:55 +07:00
}
}
2026-10-22 12:23:13 +07:00
2026-10-23 10:10:03 +07:00
async function switchCamera () {
if ( ! availableCameras || availableCameras . length <= 1 || ! html5QrScanner ) return ;
currentCameraIndex = ( currentCameraIndex + 1 ) % availableCameras . length ;
await stopQrScanner ();
await startQrScanner ();
}
2026-10-22 12:23:13 +07:00
// Countdown Timer Tiket Pending (Batas Waktu 5 Jam)
const countdownContainer = document . getElementById ( 'pendingTripCountdownContainer' );
if ( countdownContainer ) {
const expiresAtRaw = countdownContainer . getAttribute ( 'data-expires-at' );
const timerTextEl = document . getElementById ( 'tripCountdownTimerText' );
if ( expiresAtRaw && timerTextEl ) {
const expireTime = new Date ( expiresAtRaw ) . getTime ();
function updateTripCountdown () {
const now = new Date () . getTime ();
const distance = expireTime - now ;
if ( distance <= 0 ) {
timerTextEl . textContent = 'Kedaluwarsa' ;
countdownContainer . classList . remove ( 'text-rose-700' , 'border-rose-300' );
countdownContainer . classList . add ( 'text-slate-600' , 'bg-slate-100' , 'border-slate-300' );
setTimeout (() => {
window . location . reload ();
}, 2500 );
return ;
}
const hours = Math . floor ( distance / ( 1000 * 60 * 60 ));
const minutes = Math . floor (( distance % ( 1000 * 60 * 60 )) / ( 1000 * 60 ));
const seconds = Math . floor (( distance % ( 1000 * 60 )) / 1000 );
const pad = ( n ) => String ( n ) . padStart ( 2 , '0' );
timerTextEl . textContent = `${pad(hours)}:${pad(minutes)}:${pad(seconds)}` ;
}
updateTripCountdown ();
setInterval ( updateTripCountdown , 1000 );
}
}
2026-10-22 16:13:24 +07:00
// Real-Time Lightweight Polling untuk Memantau Status Validasi Pos Gerbang
const pendingTripCard = document . getElementById ( 'pendingTripCard' );
if ( pendingTripCard ) {
const activityId = pendingTripCard . getAttribute ( 'data-activity-id' );
let pollingTimer = null ;
let isPollingInProgress = false ;
async function pollTripStatus () {
// Jangan lakukan polling jika tab sedang di-minimize/background untuk hemat resource
if ( document . hidden ) return ;
if ( isPollingInProgress ) return ;
isPollingInProgress = true ;
try {
const response = await fetch ( `{{ route('employee.activity.status_polling') }}?activity_id=${activityId}` , {
headers : {
'Accept' : 'application/json' ,
'X-Requested-With' : 'XMLHttpRequest'
}
});
if ( ! response . ok ) {
isPollingInProgress = false ;
return ;
}
const data = await response . json ();
isPollingInProgress = false ;
// Jika status sudah berubah dari pending, hentikan polling dan tampilkan notifikasi
if ( data && data . status && data . status !== 'pending' ) {
if ( pollingTimer ) {
clearInterval ( pollingTimer );
pollingTimer = null ;
}
showValidationNotification ( data );
}
} catch ( err ) {
isPollingInProgress = false ;
// Supresi error jaringan agar tidak mengganggu driver
}
}
// Jalankan polling ringan berkala setiap 4 detik
pollingTimer = setInterval ( pollTripStatus , 4000 );
// Jika user kembali ke tab browser, langsung cek status 1 kali
document . addEventListener ( 'visibilitychange' , () => {
if ( ! document . hidden && pollingTimer ) {
pollTripStatus ();
}
});
}
function showValidationNotification ( data ) {
const modal = document . getElementById ( 'validationNotificationModal' );
const card = document . getElementById ( 'validationNotificationCard' );
const banner = document . getElementById ( 'validationNotificationBanner' );
const icon = document . getElementById ( 'validationNotificationIcon' );
const title = document . getElementById ( 'validationNotificationTitle' );
const subtitle = document . getElementById ( 'validationNotificationSubtitle' );
const trxNo = document . getElementById ( 'validationTrxNo' );
const vehicle = document . getElementById ( 'validationVehicle' );
const gate = document . getElementById ( 'validationGate' );
const guard = document . getElementById ( 'validationGuard' );
const noteRow = document . getElementById ( 'validationNoteRow' );
const note = document . getElementById ( 'validationNote' );
const dismissBtn = document . getElementById ( 'validationDismissBtn' );
if ( ! modal ) return ;
trxNo . textContent = data . transaction_no || '-' ;
vehicle . textContent = `${data.vehicle_code} (${data.vehicle_name})` ;
gate . textContent = data . gate_name || 'Pos Gerbang' ;
guard . textContent = data . guard_name || 'Petugas Satpam' ;
if ( data . is_approved ) {
banner . className = 'p-6 text-center text-white bg-gradient-to-br from-emerald-600 to-[#1b5e20]' ;
icon . innerHTML = '<i class="fa-solid fa-circle-check text-emerald-100"></i>' ;
title . textContent = 'Perjalanan Disetujui!' ;
subtitle . textContent = `Pemeriksaan selesai oleh Satpam ${data.guard_name} pada ${data.validated_at || 'hari ini'}` ;
dismissBtn . className = 'w-full bg-[#1b5e20] hover:bg-[#144918] text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm shadow-md transition flex items-center justify-center space-x-2 cursor-pointer' ;
dismissBtn . innerHTML = '<span>Lanjutkan Perjalanan (OK)</span><i class="fa-solid fa-arrow-right text-xs"></i>' ;
noteRow . classList . add ( 'hidden' );
} else if ( data . is_rejected ) {
banner . className = 'p-6 text-center text-white bg-gradient-to-br from-rose-600 to-rose-800' ;
icon . innerHTML = '<i class="fa-solid fa-circle-xmark text-rose-100"></i>' ;
title . textContent = 'Perjalanan Ditolak' ;
subtitle . textContent = `Ditolak oleh Satpam ${data.guard_name} di ${data.gate_name}` ;
dismissBtn . className = 'w-full bg-rose-700 hover:bg-rose-800 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm shadow-md transition flex items-center justify-center space-x-2 cursor-pointer' ;
dismissBtn . innerHTML = '<span>Tutup & Periksa Dashboard</span>' ;
if ( data . rejection_note ) {
note . textContent = data . rejection_note ;
noteRow . classList . remove ( 'hidden' );
}
} else if ( data . is_cancelled ) {
banner . className = 'p-6 text-center text-white bg-gradient-to-br from-amber-600 to-amber-800' ;
icon . innerHTML = '<i class="fa-solid fa-ban text-amber-100"></i>' ;
title . textContent = data . cancellation_source || 'Perjalanan Dibatalkan' ;
subtitle . textContent = 'Status tiket perjalanan telah dibatalkan' ;
dismissBtn . className = 'w-full bg-slate-700 hover:bg-slate-800 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm shadow-md transition flex items-center justify-center space-x-2 cursor-pointer' ;
dismissBtn . innerHTML = '<span>Tutup</span>' ;
if ( data . rejection_note ) {
note . textContent = data . rejection_note ;
noteRow . classList . remove ( 'hidden' );
}
}
modal . classList . remove ( 'hidden' );
setTimeout (() => {
card . classList . remove ( 'scale-95' );
card . classList . add ( 'scale-100' );
}, 10 );
}
function handleValidationDismiss () {
// Refresh halus setelah driver klik agar state tabel tersinkron permanen
window . location . reload ();
}
2026-10-19 23:21:55 +07:00
</ script >
2026-10-15 13:53:52 +07:00
@ endsection