330 lines
21 KiB
PHP
330 lines
21 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Tambah User Baru - Admin Dashboard')
|
|
|
|
@section('content')
|
|
<div class="min-h-screen bg-gray-50">
|
|
<!-- Top Navigation -->
|
|
<nav class="bg-white shadow-lg sticky top-0 z-40">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex justify-between h-16">
|
|
<div class="flex items-center">
|
|
<button id="sidebar-toggle" class="lg:hidden text-gray-700 hover:text-primary mr-4">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 6h16M4 12h16M4 18h16"></path>
|
|
</svg>
|
|
</button>
|
|
<div class="flex-shrink-0">
|
|
<h1 class="text-xl md:text-2xl font-bold text-primary">🏥 Admin Puskesmas</h1>
|
|
</div>
|
|
</div>
|
|
<div class="hidden md:flex items-center space-x-4">
|
|
<a href="{{ route('display') }}"
|
|
class="text-gray-700 hover:text-primary px-3 py-2 rounded-md text-sm font-medium transition duration-200">Display</a>
|
|
<span class="text-gray-700">Selamat datang, Admin</span>
|
|
<button onclick="confirmLogout()"
|
|
class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-md text-sm font-medium transition duration-200">
|
|
Logout
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="flex">
|
|
<!-- Sidebar -->
|
|
<aside id="sidebar"
|
|
class="fixed inset-y-0 left-0 z-50 w-64 bg-white shadow-xl transform -translate-x-full lg:translate-x-0 lg:static lg:inset-0 transition duration-200 ease-in-out">
|
|
<div class="flex items-center justify-between h-16 px-6 border-b border-gray-200">
|
|
<h2 class="text-lg font-semibold text-gray-900">Menu Admin</h2>
|
|
<button id="sidebar-close" class="lg:hidden text-gray-500 hover:text-gray-700">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12">
|
|
</path>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<nav class="px-6 py-6">
|
|
<div class="space-y-6">
|
|
<!-- Dashboard -->
|
|
<div>
|
|
<a href="{{ route('admin.dashboard') }}"
|
|
class="flex items-center px-4 py-3 rounded-xl {{ request()->routeIs('admin.dashboard') ? 'bg-blue-50 text-blue-700 border border-blue-200' : 'text-gray-700 hover:bg-gray-50' }} transition duration-200">
|
|
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"></path>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M8 5a2 2 0 012-2h4a2 2 0 012 2v6H8V5z"></path>
|
|
</svg>
|
|
<span class="font-medium">Dashboard</span>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Daftar Antrian -->
|
|
<div>
|
|
<div
|
|
class="flex items-center px-4 py-2 text-sm font-semibold text-gray-500 uppercase tracking-wider">
|
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2">
|
|
</path>
|
|
</svg>
|
|
Daftar Antrian
|
|
</div>
|
|
<div class="mt-3 space-y-1">
|
|
<a href="{{ route('admin.poli.umum') }}"
|
|
class="flex items-center px-4 py-2 rounded-lg {{ request()->routeIs('admin.poli.umum') ? 'bg-blue-50 text-blue-700' : 'text-gray-600 hover:bg-gray-50' }} transition duration-200">
|
|
<div class="w-2 h-2 bg-blue-500 rounded-full mr-3"></div>
|
|
<span class="text-sm">Poli Umum</span>
|
|
</a>
|
|
<a href="{{ route('admin.poli.gigi') }}"
|
|
class="flex items-center px-4 py-2 rounded-lg {{ request()->routeIs('admin.poli.gigi') ? 'bg-green-50 text-green-700' : 'text-gray-600 hover:bg-gray-50' }} transition duration-200">
|
|
<div class="w-2 h-2 bg-green-500 rounded-full mr-3"></div>
|
|
<span class="text-sm">Poli Gigi</span>
|
|
</a>
|
|
<a href="{{ route('admin.poli.jiwa') }}"
|
|
class="flex items-center px-4 py-2 rounded-lg {{ request()->routeIs('admin.poli.jiwa') ? 'bg-purple-50 text-purple-700' : 'text-gray-600 hover:bg-gray-50' }} transition duration-200">
|
|
<div class="w-2 h-2 bg-purple-500 rounded-full mr-3"></div>
|
|
<span class="text-sm">Poli Jiwa</span>
|
|
</a>
|
|
<a href="{{ route('admin.poli.tradisional') }}"
|
|
class="flex items-center px-4 py-2 rounded-lg {{ request()->routeIs('admin.poli.tradisional') ? 'bg-yellow-50 text-yellow-700' : 'text-gray-600 hover:bg-gray-50' }} transition duration-200">
|
|
<div class="w-2 h-2 bg-yellow-500 rounded-full mr-3"></div>
|
|
<span class="text-sm">Poli Tradisional</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Kelola User -->
|
|
<div>
|
|
<div
|
|
class="flex items-center px-4 py-2 text-sm font-semibold text-gray-500 uppercase tracking-wider">
|
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z">
|
|
</path>
|
|
</svg>
|
|
Kelola User
|
|
</div>
|
|
<div class="mt-3 space-y-1">
|
|
<a href="{{ route('admin.users.index') }}"
|
|
class="flex items-center px-4 py-2 rounded-lg {{ request()->routeIs('admin.users.*') ? 'bg-blue-50 text-blue-700' : 'text-gray-600 hover:bg-gray-50' }} transition duration-200">
|
|
<div class="w-2 h-2 bg-blue-500 rounded-full mr-3"></div>
|
|
<span class="text-sm">Daftar User</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Laporan -->
|
|
<div>
|
|
<a href="{{ route('admin.laporan.index') }}"
|
|
class="flex items-center px-4 py-3 rounded-xl {{ request()->routeIs('admin.laporan.*') ? 'bg-blue-50 text-blue-700 border border-blue-200' : 'text-gray-700 hover:bg-gray-50' }} transition duration-200">
|
|
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 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>
|
|
<span class="font-medium">Laporan</span>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Indonesian TTS -->
|
|
<div>
|
|
<a href="{{ route('admin.indonesian-tts.index') }}"
|
|
class="flex items-center px-4 py-3 rounded-xl {{ request()->routeIs('admin.indonesian-tts.*') ? 'bg-blue-50 text-blue-700 border border-blue-200' : 'text-gray-700 hover:bg-gray-50' }} transition duration-200">
|
|
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z">
|
|
</path>
|
|
</svg>
|
|
<span class="font-medium">Indonesian TTS</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</aside>
|
|
|
|
<!-- Main Content -->
|
|
<div class="flex-1 lg:ml-64">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<!-- Header -->
|
|
<div class="mb-8">
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">Tambah User Baru</h1>
|
|
<p class="mt-2 text-gray-600">Tambahkan user baru ke sistem Puskesmas</p>
|
|
</div>
|
|
<a href="{{ route('admin.users.index') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
|
</svg>
|
|
Kembali
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Form -->
|
|
<div class="bg-white shadow rounded-lg">
|
|
<div class="px-6 py-4 border-b border-gray-200">
|
|
<h3 class="text-lg font-medium text-gray-900">Informasi User</h3>
|
|
</div>
|
|
|
|
<form action="{{ route('admin.users.store') }}" method="POST" class="p-6 space-y-6">
|
|
@csrf
|
|
|
|
@if ($errors->any())
|
|
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md">
|
|
<ul class="list-disc list-inside space-y-1">
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<!-- Nama -->
|
|
<div>
|
|
<label for="nama" class="block text-sm font-medium text-gray-700 mb-2">Nama
|
|
Lengkap <span class="text-red-500">*</span></label>
|
|
<input type="text" name="nama" id="nama" value="{{ old('nama') }}"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- No KTP -->
|
|
<div>
|
|
<label for="no_ktp" class="block text-sm font-medium text-gray-700 mb-2">Nomor KTP
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="no_ktp" id="no_ktp" value="{{ old('no_ktp') }}"
|
|
maxlength="16" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
placeholder="16 digit angka">
|
|
</div>
|
|
|
|
<!-- Jenis Kelamin -->
|
|
<div>
|
|
<label for="jenis_kelamin" class="block text-sm font-medium text-gray-700 mb-2">Jenis
|
|
Kelamin <span class="text-red-500">*</span></label>
|
|
<select name="jenis_kelamin" id="jenis_kelamin" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="">Pilih Jenis Kelamin</option>
|
|
<option value="laki-laki"
|
|
{{ old('jenis_kelamin') == 'laki-laki' ? 'selected' : '' }}>Laki-laki</option>
|
|
<option value="perempuan"
|
|
{{ old('jenis_kelamin') == 'perempuan' ? 'selected' : '' }}>Perempuan</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- No HP -->
|
|
<div>
|
|
<label for="no_hp" class="block text-sm font-medium text-gray-700 mb-2">Nomor HP
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="no_hp" id="no_hp" value="{{ old('no_hp') }}"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- Pekerjaan -->
|
|
<div>
|
|
<label for="pekerjaan" class="block text-sm font-medium text-gray-700 mb-2">Pekerjaan
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="pekerjaan" id="pekerjaan"
|
|
value="{{ old('pekerjaan') }}" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- Password -->
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="password" name="password" id="password" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
placeholder="Minimal 8 karakter">
|
|
</div>
|
|
|
|
<!-- Konfirmasi Password -->
|
|
<div>
|
|
<label for="password_confirmation"
|
|
class="block text-sm font-medium text-gray-700 mb-2">Konfirmasi Password <span
|
|
class="text-red-500">*</span></label>
|
|
<input type="password" name="password_confirmation" id="password_confirmation"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alamat -->
|
|
<div>
|
|
<label for="alamat" class="block text-sm font-medium text-gray-700 mb-2">Alamat Lengkap
|
|
<span class="text-red-500">*</span></label>
|
|
<textarea name="alamat" id="alamat" rows="3" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">{{ old('alamat') }}</textarea>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="flex justify-end space-x-3 pt-6 border-t border-gray-200">
|
|
<a href="{{ route('admin.users.index') }}"
|
|
class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Batal
|
|
</a>
|
|
<button type="submit"
|
|
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Tambah User
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Sidebar toggle functionality
|
|
document.getElementById('sidebar-toggle').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.toggle('-translate-x-full');
|
|
});
|
|
|
|
document.getElementById('sidebar-close').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.add('-translate-x-full');
|
|
});
|
|
|
|
// Logout confirmation
|
|
function confirmLogout() {
|
|
if (confirm('Apakah Anda yakin ingin logout?')) {
|
|
document.createElement('form').submit();
|
|
}
|
|
}
|
|
|
|
// Auto-format KTP input
|
|
document.getElementById('no_ktp').addEventListener('input', function(e) {
|
|
this.value = this.value.replace(/[^0-9]/g, '');
|
|
});
|
|
|
|
// Show SweetAlert2 for session errors
|
|
@if (session('error'))
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error!',
|
|
text: '{{ session('error') }}',
|
|
confirmButtonColor: '#d33',
|
|
});
|
|
@endif
|
|
|
|
// Show SweetAlert2 for session success
|
|
@if (session('success'))
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil!',
|
|
text: '{{ session('success') }}',
|
|
confirmButtonColor: '#28a745',
|
|
});
|
|
@endif
|
|
</script>
|
|
@endsection
|