777 lines
43 KiB
PHP
777 lines
43 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', $title)
|
|
|
|
@push('styles')
|
|
<style>
|
|
/* Tooltip styles */
|
|
[title]:hover {
|
|
position: relative;
|
|
}
|
|
|
|
[title]:hover:after {
|
|
content: attr(title);
|
|
position: absolute;
|
|
bottom: 100%;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: rgba(0, 0, 0, 0.8);
|
|
color: white;
|
|
padding: 8px 12px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
white-space: nowrap;
|
|
z-index: 1000;
|
|
pointer-events: none;
|
|
max-width: 300px;
|
|
white-space: normal;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
[title]:hover:before {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 100%;
|
|
left: 50%;
|
|
transform: translateX(-50%) translateY(100%);
|
|
border: 5px solid transparent;
|
|
border-top-color: rgba(0, 0, 0, 0.8);
|
|
z-index: 1000;
|
|
}
|
|
</style>
|
|
@endpush
|
|
|
|
@section('content')
|
|
<div class="min-h-screen bg-gray-50">
|
|
@include('admin.partials.top-nav')
|
|
|
|
<div class="flex">
|
|
@include('admin.partials.sidebar')
|
|
|
|
<!-- Main Content -->
|
|
<div class="flex-1 lg:ml-0">
|
|
<div class="px-4 sm:px-6 lg:px-8 py-6 md:py-8">
|
|
<!-- Header -->
|
|
<div class="mb-8 animate-fade-in">
|
|
<h1 class="text-3xl md:text-4xl font-bold text-gray-900 mb-2">{{ $title }}</h1>
|
|
<p class="text-gray-600 text-lg">Kelola antrian untuk {{ $title }}</p>
|
|
</div>
|
|
|
|
<!-- Table -->
|
|
<div class="bg-white rounded-2xl shadow-xl overflow-hidden">
|
|
<!-- Desktop Table -->
|
|
<div class="hidden lg:block overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-gray-200">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-20">
|
|
No Antrian</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
Nama</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-32">
|
|
Alamat</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-24">
|
|
JK</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-28">
|
|
No HP</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-32">
|
|
No KTP</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-24">
|
|
Status</th>
|
|
<th
|
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-32">
|
|
Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y divide-gray-200">
|
|
@forelse($antrians as $antrian)
|
|
<tr class="hover:bg-gray-50">
|
|
<td class="px-6 py-4 whitespace-nowrap font-semibold text-gray-900">
|
|
{{ $antrian->no_antrian }}</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-gray-900">
|
|
{{ $antrian->user?->nama }}</td>
|
|
<td class="px-6 py-4 text-gray-700 max-w-32"
|
|
title="{{ $antrian->user?->alamat }}">
|
|
<div class="truncate">
|
|
{{ Str::limit($antrian->user?->alamat, 30) }}
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-gray-700"
|
|
title="{{ $antrian->user?->jenis_kelamin }}">
|
|
{{ $antrian->user?->jenis_kelamin == 'laki-laki' ? 'L' : 'P' }}</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
|
{{ $antrian->user?->no_hp }}</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-gray-700">
|
|
{{ $antrian->user?->no_ktp }}</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if ($antrian->status == 'menunggu')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-yellow-100 text-yellow-800">
|
|
Menunggu
|
|
</span>
|
|
@elseif($antrian->status == 'dipanggil')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-blue-100 text-blue-800">
|
|
Dipanggil
|
|
</span>
|
|
@elseif($antrian->status == 'sedang_diperiksa')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-purple-100 text-purple-800">
|
|
Sedang Diperiksa
|
|
</span>
|
|
@elseif($antrian->status == 'selesai')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-green-100 text-green-800">
|
|
Selesai
|
|
</span>
|
|
@else
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-red-100 text-red-800">
|
|
Batal
|
|
</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if ($antrian->status == 'menunggu')
|
|
<button
|
|
onclick="panggil('{{ route('admin.panggil-antrian-id', $antrian) }}')"
|
|
class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Panggil
|
|
</button>
|
|
@elseif($antrian->status == 'dipanggil')
|
|
<div class="flex flex-col space-y-1">
|
|
@if (!$antrian->waktu_hadir)
|
|
<button onclick="konfirmasiKehadiran({{ $antrian->id }})"
|
|
class="bg-orange-500 hover:bg-orange-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Pasien Hadir
|
|
</button>
|
|
@else
|
|
<button onclick="mulaiPemeriksaan({{ $antrian->id }})"
|
|
class="bg-purple-500 hover:bg-purple-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Mulai Periksa
|
|
</button>
|
|
@endif
|
|
<div class="flex space-x-1">
|
|
<button
|
|
onclick="selesai('{{ route('admin.selesai-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Selesai
|
|
</button>
|
|
<button
|
|
onclick="batal('{{ route('admin.batal-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-red-500 hover:bg-red-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Batal
|
|
</button>
|
|
</div>
|
|
</div>
|
|
@elseif($antrian->status == 'sedang_diperiksa')
|
|
<div class="flex space-x-2">
|
|
<button
|
|
onclick="selesai('{{ route('admin.selesai-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Selesai
|
|
</button>
|
|
</div>
|
|
@else
|
|
<span class="text-gray-400 text-xs">-</span>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="8" class="px-6 py-8 text-center text-gray-500">
|
|
<svg class="w-12 h-12 mx-auto mb-4 text-gray-400" fill="none"
|
|
stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">
|
|
</path>
|
|
</svg>
|
|
<p class="text-lg font-medium">Tidak ada antrian</p>
|
|
<p class="text-sm text-gray-400">Belum ada antrian yang terdaftar</p>
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Mobile Table -->
|
|
<div class="lg:hidden">
|
|
@forelse($antrians as $antrian)
|
|
<div class="border-b border-gray-200 p-4 hover:bg-gray-50">
|
|
<!-- 4 Kolom Penting untuk Mobile -->
|
|
<div class="grid grid-cols-2 gap-4 mb-3">
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase tracking-wider">No
|
|
Antrian</p>
|
|
<p class="text-sm font-semibold text-gray-900">{{ $antrian->no_antrian }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase tracking-wider">Nama</p>
|
|
<p class="text-sm text-gray-900">{{ $antrian->user?->nama }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase tracking-wider">Status
|
|
</p>
|
|
@if ($antrian->status == 'menunggu')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-yellow-100 text-yellow-800">
|
|
Menunggu
|
|
</span>
|
|
@elseif($antrian->status == 'dipanggil')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-blue-100 text-blue-800">
|
|
Dipanggil
|
|
</span>
|
|
@elseif($antrian->status == 'sedang_diperiksa')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-purple-100 text-purple-800">
|
|
Sedang Diperiksa
|
|
</span>
|
|
@elseif($antrian->status == 'selesai')
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-green-100 text-green-800">
|
|
Selesai
|
|
</span>
|
|
@else
|
|
<span
|
|
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-red-100 text-red-800">
|
|
Batal
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</p>
|
|
@if ($antrian->status == 'menunggu')
|
|
<button
|
|
onclick="panggil('{{ route('admin.panggil-antrian-id', $antrian) }}')"
|
|
class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Panggil
|
|
</button>
|
|
@elseif($antrian->status == 'dipanggil')
|
|
<div class="flex flex-col space-y-1">
|
|
@if (!$antrian->waktu_hadir)
|
|
<button onclick="konfirmasiKehadiran({{ $antrian->id }})"
|
|
class="bg-orange-500 hover:bg-orange-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Pasien Hadir
|
|
</button>
|
|
@else
|
|
<button onclick="mulaiPemeriksaan({{ $antrian->id }})"
|
|
class="bg-purple-500 hover:bg-purple-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Mulai Periksa
|
|
</button>
|
|
@endif
|
|
<div class="flex space-x-1">
|
|
<button
|
|
onclick="selesai('{{ route('admin.selesai-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Selesai
|
|
</button>
|
|
<button
|
|
onclick="batal('{{ route('admin.batal-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-red-500 hover:bg-red-600 text-white px-2 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Batal
|
|
</button>
|
|
</div>
|
|
</div>
|
|
@elseif($antrian->status == 'sedang_diperiksa')
|
|
<div class="flex space-x-2">
|
|
<button
|
|
onclick="selesai('{{ route('admin.selesai-antrian') }}', {{ $antrian->id }})"
|
|
class="bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded-md text-xs font-medium transition duration-200">
|
|
Selesai
|
|
</button>
|
|
</div>
|
|
@else
|
|
<span class="text-gray-400 text-xs">-</span>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Button Selengkapnya untuk Mobile -->
|
|
<div class="border-t border-gray-100 pt-3">
|
|
<button onclick="toggleDetails({{ $antrian->id }})"
|
|
class="text-blue-600 hover:text-blue-800 text-sm font-medium flex items-center">
|
|
<span id="btn-text-{{ $antrian->id }}">Selengkapnya</span>
|
|
<svg id="icon-{{ $antrian->id }}"
|
|
class="w-4 h-4 ml-1 transform transition-transform" fill="none"
|
|
stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M19 9l-7 7-7-7"></path>
|
|
</svg>
|
|
</button>
|
|
|
|
<!-- Detail Tambahan (Hidden by default) -->
|
|
<div id="details-{{ $antrian->id }}" class="hidden mt-3 space-y-2">
|
|
<div class="grid grid-cols-1 gap-2 text-sm">
|
|
<div>
|
|
<span class="font-medium text-gray-700">Alamat:</span>
|
|
<span class="text-gray-600 block mt-1"
|
|
title="{{ $antrian->user?->alamat }}">
|
|
{{ Str::limit($antrian->user?->alamat, 50) }}
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<span class="font-medium text-gray-700">Jenis Kelamin:</span>
|
|
<span
|
|
class="text-gray-600">{{ $antrian->user?->jenis_kelamin }}</span>
|
|
</div>
|
|
<div>
|
|
<span class="font-medium text-gray-700">Nomor HP:</span>
|
|
<span class="text-gray-600">{{ $antrian->user?->no_hp }}</span>
|
|
</div>
|
|
<div>
|
|
<span class="font-medium text-gray-700">Nomor KTP:</span>
|
|
<span class="text-gray-600">{{ $antrian->user?->no_ktp }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@empty
|
|
<div class="p-8 text-center text-gray-500">
|
|
<svg class="w-12 h-12 mx-auto mb-4 text-gray-400" fill="none"
|
|
stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">
|
|
</path>
|
|
</svg>
|
|
<p class="text-lg font-medium">Tidak ada antrian</p>
|
|
<p class="text-sm text-gray-400">Belum ada antrian yang terdaftar</p>
|
|
</div>
|
|
@endforelse
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
<div class="mt-8">
|
|
{{ $antrians->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script>
|
|
// Sidebar toggle for mobile
|
|
document.getElementById('sidebar-toggle').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.remove('-translate-x-full');
|
|
document.getElementById('sidebar-overlay').classList.remove('hidden');
|
|
});
|
|
|
|
document.getElementById('sidebar-close').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.add('-translate-x-full');
|
|
document.getElementById('sidebar-overlay').classList.add('hidden');
|
|
});
|
|
|
|
document.getElementById('sidebar-overlay').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.add('-translate-x-full');
|
|
document.getElementById('sidebar-overlay').classList.add('hidden');
|
|
});
|
|
|
|
function panggil(url) {
|
|
Swal.fire({
|
|
title: 'Panggil Antrian?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya',
|
|
cancelButtonText: 'Batal'
|
|
}).then((res) => {
|
|
if (!res.isConfirmed) return;
|
|
fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
|
}
|
|
})
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
if (d.success) {
|
|
// Show success alert with sound
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Antrian Dipanggil!',
|
|
text: `Antrian selanjutnya poli ${d.poli_name} nomor ${d.queue_number}`,
|
|
confirmButtonText: 'OK',
|
|
confirmButtonColor: '#10B981',
|
|
timer: 3000,
|
|
timerProgressBar: true,
|
|
showClass: {
|
|
popup: 'animate__animated animate__fadeInDown'
|
|
},
|
|
hideClass: {
|
|
popup: 'animate__animated animate__fadeOutUp'
|
|
}
|
|
});
|
|
|
|
// Play notification sound
|
|
playNotificationSound();
|
|
|
|
// Reload page after delay
|
|
setTimeout(() => {
|
|
location.reload();
|
|
}, 2000);
|
|
} else {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: 'Gagal',
|
|
text: d.message
|
|
});
|
|
}
|
|
})
|
|
.catch(() => Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Terjadi kesalahan'
|
|
}));
|
|
});
|
|
}
|
|
|
|
// Play notification sound
|
|
function playNotificationSound() {
|
|
const audio = new Audio(
|
|
'data:audio/wav;base64,UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqFbF1fdJivrJBhNjVgodDbq2EcBj+a2/LDciUFLIHO8tiJNwgZaLvt559NEAxQp+PwtmMcBjiR1/LMeSwFJHfH8N2QQAoUXrTp66hVFApGn+DyvmwhBSuBzvLZiTYIG2m98OScTgwOUarm7blmGgU7k9n1unEiBC13yO/eizEIHWq+8+OWT'
|
|
);
|
|
audio.play();
|
|
}
|
|
|
|
// Function to convert queue number to Indonesian pronunciation
|
|
function convertQueueNumberToIndonesian(queueNumber) {
|
|
// Indonesian number words
|
|
const indonesianNumbers = {
|
|
'0': 'Nol',
|
|
'1': 'Satu',
|
|
'2': 'Dua',
|
|
'3': 'Tiga',
|
|
'4': 'Empat',
|
|
'5': 'Lima',
|
|
'6': 'Enam',
|
|
'7': 'Tujuh',
|
|
'8': 'Delapan',
|
|
'9': 'Sembilan',
|
|
'10': 'Sepuluh',
|
|
'11': 'Sebelas',
|
|
'12': 'Dua Belas',
|
|
'13': 'Tiga Belas',
|
|
'14': 'Empat Belas',
|
|
'15': 'Lima Belas',
|
|
'16': 'Enam Belas',
|
|
'17': 'Tujuh Belas',
|
|
'18': 'Delapan Belas',
|
|
'19': 'Sembilan Belas',
|
|
'20': 'Dua Puluh',
|
|
'30': 'Tiga Puluh',
|
|
'40': 'Empat Puluh',
|
|
'50': 'Lima Puluh',
|
|
'60': 'Enam Puluh',
|
|
'70': 'Tujuh Puluh',
|
|
'80': 'Delapan Puluh',
|
|
'90': 'Sembilan Puluh',
|
|
'100': 'Seratus'
|
|
};
|
|
|
|
// If it's a pure number, convert it
|
|
if (!isNaN(queueNumber)) {
|
|
const number = parseInt(queueNumber);
|
|
if (indonesianNumbers[number]) {
|
|
return indonesianNumbers[number];
|
|
} else {
|
|
// For numbers > 100, build the pronunciation
|
|
if (number < 100) {
|
|
const tens = Math.floor(number / 10) * 10;
|
|
const ones = number % 10;
|
|
if (ones === 0) {
|
|
return indonesianNumbers[tens];
|
|
} else {
|
|
return indonesianNumbers[tens] + ' ' + indonesianNumbers[ones];
|
|
}
|
|
} else {
|
|
return queueNumber; // Fallback for large numbers
|
|
}
|
|
}
|
|
}
|
|
|
|
// For alphanumeric (like "U5", "A10"), convert the numeric part
|
|
let letters = '';
|
|
let numbers = '';
|
|
|
|
// Split into letters and numbers
|
|
for (let i = 0; i < queueNumber.length; i++) {
|
|
const char = queueNumber[i];
|
|
if (!isNaN(char)) {
|
|
numbers += char;
|
|
} else {
|
|
letters += char;
|
|
}
|
|
}
|
|
|
|
// If we have both letters and numbers
|
|
if (letters && numbers) {
|
|
const numberValue = parseInt(numbers);
|
|
if (indonesianNumbers[numberValue]) {
|
|
return letters + ' ' + indonesianNumbers[numberValue];
|
|
} else {
|
|
// For numbers > 100, build the pronunciation
|
|
if (numberValue < 100) {
|
|
const tens = Math.floor(numberValue / 10) * 10;
|
|
const ones = numberValue % 10;
|
|
if (ones === 0) {
|
|
return letters + ' ' + indonesianNumbers[tens];
|
|
} else {
|
|
return letters + ' ' + indonesianNumbers[tens] + ' ' + indonesianNumbers[ones];
|
|
}
|
|
} else {
|
|
return queueNumber; // Fallback for large numbers
|
|
}
|
|
}
|
|
}
|
|
|
|
// If no conversion needed, return as is
|
|
return queueNumber;
|
|
}
|
|
|
|
// Function to play TTS locally (fallback)
|
|
function playTTSLocally(poliName, queueNumber) {
|
|
// Create audio sequence manually
|
|
const attentionSound = '{{ asset('assets/music/call-to-attention-123107.mp3') }}';
|
|
|
|
// Play attention sound first
|
|
const audio1 = new Audio(attentionSound);
|
|
audio1.play();
|
|
|
|
// After attention sound, use browser TTS for poli and number
|
|
setTimeout(() => {
|
|
// Convert queue number to Indonesian pronunciation
|
|
const indonesianQueueNumber = convertQueueNumberToIndonesian(queueNumber);
|
|
const text = `Nomor antrian ${indonesianQueueNumber}, silakan menuju ke ${poliName}`;
|
|
if ('speechSynthesis' in window) {
|
|
const utterance = new SpeechSynthesisUtterance(text);
|
|
utterance.lang = 'id-ID';
|
|
utterance.rate = 0.85; // Slightly faster for more natural flow
|
|
utterance.volume = 1.0;
|
|
|
|
// Try to select a female Indonesian voice if available
|
|
const voices = speechSynthesis.getVoices();
|
|
const indonesianVoice = voices.find(voice =>
|
|
voice.lang === 'id-ID' &&
|
|
voice.name.toLowerCase().includes('female')
|
|
) || voices.find(voice => voice.lang === 'id-ID');
|
|
|
|
if (indonesianVoice) {
|
|
utterance.voice = indonesianVoice;
|
|
}
|
|
|
|
speechSynthesis.speak(utterance);
|
|
}
|
|
|
|
// Play final attention sound
|
|
setTimeout(() => {
|
|
const audio2 = new Audio(attentionSound);
|
|
audio2.play();
|
|
}, 3000);
|
|
}, 2000);
|
|
}
|
|
|
|
function selesai(url, antrianId) {
|
|
Swal.fire({
|
|
title: 'Selesai Antrian?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya',
|
|
cancelButtonText: 'Batal'
|
|
}).then((res) => {
|
|
if (!res.isConfirmed) return;
|
|
fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
antrian_id: antrianId
|
|
})
|
|
})
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
Swal.fire({
|
|
icon: d.success ? 'success' : 'warning',
|
|
title: d.success ? 'Berhasil' : 'Gagal',
|
|
text: d.message
|
|
})
|
|
.then(() => location.reload());
|
|
})
|
|
.catch(() => Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Terjadi kesalahan'
|
|
}));
|
|
});
|
|
}
|
|
|
|
function batal(url, antrianId) {
|
|
Swal.fire({
|
|
title: 'Batal Antrian?',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya',
|
|
cancelButtonText: 'Tidak'
|
|
}).then((res) => {
|
|
if (!res.isConfirmed) return;
|
|
fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
antrian_id: antrianId
|
|
})
|
|
})
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
Swal.fire({
|
|
icon: d.success ? 'success' : 'warning',
|
|
title: d.success ? 'Berhasil' : 'Gagal',
|
|
text: d.message
|
|
})
|
|
.then(() => location.reload());
|
|
})
|
|
.catch(() => Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Terjadi kesalahan'
|
|
}));
|
|
});
|
|
}
|
|
|
|
function konfirmasiKehadiran(antrianId) {
|
|
Swal.fire({
|
|
title: 'Konfirmasi Kehadiran Pasien?',
|
|
text: 'Pasien sudah datang dan siap untuk diperiksa?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Pasien Hadir',
|
|
cancelButtonText: 'Batal'
|
|
}).then((res) => {
|
|
if (!res.isConfirmed) return;
|
|
fetch('{{ route('admin.konfirmasi-kehadiran') }}', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
antrian_id: antrianId
|
|
})
|
|
})
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
Swal.fire({
|
|
icon: d.success ? 'success' : 'warning',
|
|
title: d.success ? 'Berhasil' : 'Gagal',
|
|
text: d.message
|
|
})
|
|
.then(() => location.reload());
|
|
})
|
|
.catch(() => Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Terjadi kesalahan'
|
|
}));
|
|
});
|
|
}
|
|
|
|
function mulaiPemeriksaan(antrianId) {
|
|
Swal.fire({
|
|
title: 'Mulai Pemeriksaan?',
|
|
text: 'Pasien akan dipindah ke status sedang diperiksa',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Mulai Periksa',
|
|
cancelButtonText: 'Batal'
|
|
}).then((res) => {
|
|
if (!res.isConfirmed) return;
|
|
fetch('{{ route('admin.mulai-pemeriksaan') }}', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
antrian_id: antrianId
|
|
})
|
|
})
|
|
.then(r => r.json())
|
|
.then(d => {
|
|
Swal.fire({
|
|
icon: d.success ? 'success' : 'warning',
|
|
title: d.success ? 'Berhasil' : 'Gagal',
|
|
text: d.message
|
|
})
|
|
.then(() => location.reload());
|
|
})
|
|
.catch(() => Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error',
|
|
text: 'Terjadi kesalahan'
|
|
}));
|
|
});
|
|
}
|
|
|
|
function confirmLogout() {
|
|
Swal.fire({
|
|
title: 'Konfirmasi Logout',
|
|
text: 'Apakah Anda yakin ingin keluar dari sistem?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Logout',
|
|
cancelButtonText: 'Batal',
|
|
confirmButtonColor: '#EF4444',
|
|
cancelButtonColor: '#6B7280'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
const form = document.createElement('form');
|
|
form.method = 'POST';
|
|
form.action = '{{ route('logout') }}';
|
|
|
|
const csrfToken = document.createElement('input');
|
|
csrfToken.type = 'hidden';
|
|
csrfToken.name = '_token';
|
|
csrfToken.value = '{{ csrf_token() }}';
|
|
|
|
form.appendChild(csrfToken);
|
|
document.body.appendChild(form);
|
|
form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
function toggleDetails(antrianId) {
|
|
const details = document.getElementById(`details-${antrianId}`);
|
|
const buttonText = document.getElementById(`btn-text-${antrianId}`);
|
|
const icon = document.getElementById(`icon-${antrianId}`);
|
|
|
|
if (details.classList.contains('hidden')) {
|
|
details.classList.remove('hidden');
|
|
buttonText.textContent = 'Kurangi';
|
|
icon.classList.remove('transform', 'rotate-180');
|
|
} else {
|
|
details.classList.add('hidden');
|
|
buttonText.textContent = 'Selengkapnya';
|
|
icon.classList.add('transform', 'rotate-180');
|
|
}
|
|
}
|
|
</script>
|
|
@endpush
|
|
|
|
@include('admin.partials.sidebar-script')
|
|
@endsection
|