feat: complete master satpam with ID, Regu 1/2/3, Penempatan, and auto-generated guard login accounts
This commit is contained in:
@@ -21,6 +21,7 @@ class GateInspectionController extends Controller
|
|||||||
{
|
{
|
||||||
// Ambil gerbang yang terikat pada akun petugas pos jaga yang sedang login
|
// Ambil gerbang yang terikat pada akun petugas pos jaga yang sedang login
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
$currentGuard = $user ? $user->securityGuard : null;
|
||||||
$gateId = $user ? $user->gate_id : $request->query('gate_id');
|
$gateId = $user ? $user->gate_id : $request->query('gate_id');
|
||||||
|
|
||||||
// Jika tidak ada gate_id terikat, ambil gerbang pertama sebagai fallback
|
// Jika tidak ada gate_id terikat, ambil gerbang pertama sebagai fallback
|
||||||
@@ -35,10 +36,10 @@ class GateInspectionController extends Controller
|
|||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daftar satpam aktif untuk dipilih saat verifikasi
|
// Daftar satpam aktif untuk fallback pilihan
|
||||||
$guards = SecurityGuard::where('is_active', true)->orderBy('name')->get();
|
$guards = SecurityGuard::where('is_active', true)->orderBy('name')->get();
|
||||||
|
|
||||||
return view('pg.gate_inspection', compact('gate', 'pendingActivities', 'guards'));
|
return view('pg.gate_inspection', compact('gate', 'pendingActivities', 'guards', 'currentGuard'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,11 +47,18 @@ class GateInspectionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function approve(Request $request, int $id): RedirectResponse
|
public function approve(Request $request, int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$user = $request->user();
|
||||||
'security_guard_id' => ['required', 'exists:security_guards,id'],
|
$currentGuard = $user ? $user->securityGuard : null;
|
||||||
], [
|
$guardId = $request->input('security_guard_id') ?? ($currentGuard ? $currentGuard->id : null);
|
||||||
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam yang melakukan pemeriksaan.',
|
|
||||||
]);
|
if (!$guardId) {
|
||||||
|
$request->validate([
|
||||||
|
'security_guard_id' => ['required', 'exists:security_guards,id'],
|
||||||
|
], [
|
||||||
|
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam yang melakukan pemeriksaan.',
|
||||||
|
]);
|
||||||
|
$guardId = $request->input('security_guard_id');
|
||||||
|
}
|
||||||
|
|
||||||
$activity = VehicleActivity::with('vehicle')->findOrFail($id);
|
$activity = VehicleActivity::with('vehicle')->findOrFail($id);
|
||||||
|
|
||||||
@@ -58,9 +66,7 @@ class GateInspectionController extends Controller
|
|||||||
return back()->with('error', 'Aktivitas ini sudah pernah divalidasi sebelumnya.');
|
return back()->with('error', 'Aktivitas ini sudah pernah divalidasi sebelumnya.');
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::transaction(function () use ($request, $activity) {
|
DB::transaction(function () use ($guardId, $activity) {
|
||||||
$guardId = $request->input('security_guard_id');
|
|
||||||
|
|
||||||
// 1. Update status aktivitas menjadi approved
|
// 1. Update status aktivitas menjadi approved
|
||||||
$activity->update([
|
$activity->update([
|
||||||
'validation_status' => 'approved',
|
'validation_status' => 'approved',
|
||||||
@@ -82,11 +88,22 @@ class GateInspectionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function reject(Request $request, int $id): RedirectResponse
|
public function reject(Request $request, int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
$currentGuard = $user ? $user->securityGuard : null;
|
||||||
|
$guardId = $request->input('security_guard_id') ?? ($currentGuard ? $currentGuard->id : null);
|
||||||
|
|
||||||
|
if (!$guardId) {
|
||||||
|
$request->validate([
|
||||||
|
'security_guard_id' => ['required', 'exists:security_guards,id'],
|
||||||
|
], [
|
||||||
|
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam.',
|
||||||
|
]);
|
||||||
|
$guardId = $request->input('security_guard_id');
|
||||||
|
}
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'security_guard_id' => ['required', 'exists:security_guards,id'],
|
|
||||||
'rejection_note' => ['required', 'string', 'max:500'],
|
'rejection_note' => ['required', 'string', 'max:500'],
|
||||||
], [
|
], [
|
||||||
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam.',
|
|
||||||
'rejection_note.required' => 'Alasan penolakan wajib diisi.',
|
'rejection_note.required' => 'Alasan penolakan wajib diisi.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -98,7 +115,7 @@ class GateInspectionController extends Controller
|
|||||||
|
|
||||||
$activity->update([
|
$activity->update([
|
||||||
'validation_status' => 'rejected',
|
'validation_status' => 'rejected',
|
||||||
'security_guard_id' => $request->input('security_guard_id'),
|
'security_guard_id' => $guardId,
|
||||||
'rejection_note' => $request->input('rejection_note'),
|
'rejection_note' => $request->input('rejection_note'),
|
||||||
'validated_at' => Carbon::now(),
|
'validated_at' => Carbon::now(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -3,39 +3,122 @@
|
|||||||
namespace App\Http\Controllers\Pg;
|
namespace App\Http\Controllers\Pg;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Gate;
|
||||||
use App\Models\SecurityGuard;
|
use App\Models\SecurityGuard;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class SecurityGuardController extends Controller
|
class SecurityGuardController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Tampilkan daftar petugas Satpam.
|
* Tampilkan daftar petugas Satpam beserta daftar pos gerbang.
|
||||||
*/
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
$guards = SecurityGuard::orderBy('name')->get();
|
$guards = SecurityGuard::with(['gate', 'user'])
|
||||||
return view('pg.guards_index', compact('guards'));
|
->orderBy('team')
|
||||||
|
->orderBy('name')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$gates = Gate::where('is_active', true)->orderBy('name')->get();
|
||||||
|
|
||||||
|
return view('pg.guards_index', compact('guards', 'gates'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simpan data petugas Satpam baru.
|
* Simpan data petugas Satpam baru dan otomatis buatkan akun login pos.
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
|
'badge_id' => ['required', 'string', 'max:50', 'unique:security_guards,badge_id', 'unique:users,username'],
|
||||||
'name' => ['required', 'string', 'max:100'],
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'team' => ['required', 'integer', 'in:1,2,3'],
|
||||||
|
'gate_id' => ['required', 'exists:gates,id'],
|
||||||
|
'password' => ['required', 'string', 'min:4'],
|
||||||
], [
|
], [
|
||||||
'name.required' => 'Nama petugas Satpam wajib diisi.',
|
'badge_id.required' => 'ID Satpam wajib diisi.',
|
||||||
|
'badge_id.unique' => 'ID Satpam ini sudah digunakan oleh petugas lain.',
|
||||||
|
'name.required' => 'Nama lengkap Satpam wajib diisi.',
|
||||||
|
'team.required' => 'Silakan pilih Regu Satpam (1, 2, atau 3).',
|
||||||
|
'team.in' => 'Regu Satpam harus bernilai 1, 2, atau 3.',
|
||||||
|
'gate_id.required' => 'Silakan tentukan penempatan Pos Gerbang.',
|
||||||
|
'password.required' => 'Password akun login Satpam wajib diisi.',
|
||||||
|
'password.min' => 'Password minimal terdiri dari 4 karakter.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
SecurityGuard::create([
|
DB::transaction(function () use ($request) {
|
||||||
'name' => $request->input('name'),
|
$badgeId = strtoupper(trim($request->input('badge_id')));
|
||||||
'is_active' => true,
|
|
||||||
|
// 1. Buat akun User untuk login Satpam di pos jaga
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'username' => $badgeId,
|
||||||
|
'email' => strtolower($badgeId) . '@kmh.co.id',
|
||||||
|
'password' => Hash::make($request->input('password')),
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'gate_id' => $request->input('gate_id'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 2. Simpan master data Satpam
|
||||||
|
SecurityGuard::create([
|
||||||
|
'badge_id' => $badgeId,
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'team' => (int) $request->input('team'),
|
||||||
|
'gate_id' => $request->input('gate_id'),
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return back()->with('success', "Petugas Satpam {$request->input('name')} (ID: {$request->input('badge_id')}) berhasil didaftarkan.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perbarui data Satpam (Nama, Regu, Penempatan Pos, dan Password opsional).
|
||||||
|
*/
|
||||||
|
public function update(Request $request, int $id): RedirectResponse
|
||||||
|
{
|
||||||
|
$guard = SecurityGuard::with('user')->findOrFail($id);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'team' => ['required', 'integer', 'in:1,2,3'],
|
||||||
|
'gate_id' => ['required', 'exists:gates,id'],
|
||||||
|
'password' => ['nullable', 'string', 'min:4'],
|
||||||
|
], [
|
||||||
|
'name.required' => 'Nama lengkap Satpam wajib diisi.',
|
||||||
|
'team.required' => 'Silakan pilih Regu Satpam (1, 2, atau 3).',
|
||||||
|
'gate_id.required' => 'Silakan tentukan penempatan Pos Gerbang.',
|
||||||
|
'password.min' => 'Password minimal terdiri dari 4 karakter.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return back()->with('success', 'Petugas Satpam berhasil ditambahkan ke dalam sistem.');
|
DB::transaction(function () use ($request, $guard) {
|
||||||
|
$guard->update([
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'team' => (int) $request->input('team'),
|
||||||
|
'gate_id' => $request->input('gate_id'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($guard->user) {
|
||||||
|
$userData = [
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'gate_id' => $request->input('gate_id'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->filled('password')) {
|
||||||
|
$userData['password'] = Hash::make($request->input('password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$guard->user->update($userData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return back()->with('success', "Data petugas Satpam {$guard->name} berhasil diperbarui.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,12 +126,16 @@ class SecurityGuardController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function toggleStatus(int $id): RedirectResponse
|
public function toggleStatus(int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
$guard = SecurityGuard::findOrFail($id);
|
$guard = SecurityGuard::with('user')->findOrFail($id);
|
||||||
$guard->update([
|
$newStatus = !$guard->is_active;
|
||||||
'is_active' => !$guard->is_active,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$status = $guard->is_active ? 'diaktifkan' : 'dinonaktifkan';
|
DB::transaction(function () use ($guard, $newStatus) {
|
||||||
return back()->with('success', "Status petugas Satpam ({$guard->name}) berhasil {$status}.");
|
$guard->update([
|
||||||
|
'is_active' => $newStatus,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$statusText = $newStatus ? 'diaktifkan' : 'dinonaktifkan';
|
||||||
|
return back()->with('success', "Status petugas Satpam ({$guard->name}) berhasil {$statusText}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,29 @@ class SecurityGuard extends Model
|
|||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'badge_id',
|
||||||
'name',
|
'name',
|
||||||
|
'team',
|
||||||
|
'gate_id',
|
||||||
|
'user_id',
|
||||||
'is_active',
|
'is_active',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'is_active' => 'boolean',
|
'is_active' => 'boolean',
|
||||||
|
'team' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function gate()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Gate::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function activities(): HasMany
|
public function activities(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(VehicleActivity::class);
|
return $this->hasMany(VehicleActivity::class);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Models;
|
|||||||
use Database\Factories\UserFactory;
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
@@ -56,6 +57,11 @@ class User extends Authenticatable
|
|||||||
return $this->belongsTo(Gate::class);
|
return $this->belongsTo(Gate::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function securityGuard(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(SecurityGuard::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function isGateOfficer(): bool
|
public function isGateOfficer(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'gate_officer';
|
return $this->role === 'gate_officer';
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('security_guards', function (Blueprint $table) {
|
||||||
|
$table->string('badge_id', 50)->nullable()->unique()->after('id');
|
||||||
|
$table->unsignedTinyInteger('team')->default(1)->after('name'); // Regu 1, 2, 3
|
||||||
|
$table->foreignId('gate_id')->nullable()->constrained('gates')->nullOnDelete()->after('team');
|
||||||
|
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete()->after('gate_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('security_guards', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['gate_id']);
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropColumn(['badge_id', 'team', 'gate_id', 'user_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -46,16 +46,34 @@ class DatabaseSeeder extends Seeder
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Seed Master Security Guards (Satpam PG)
|
// 2. Seed Master Security Guards (Satpam PG Lengkap dengan Akun Login)
|
||||||
$guards = [
|
$guardData = [
|
||||||
['name' => 'Ahmad Fauzi', 'is_active' => true],
|
['badge_id' => 'SEC-001', 'name' => 'Ahmad Fauzi', 'team' => 1, 'gate' => 'BTUNGGAL'],
|
||||||
['name' => 'Budi Santoso', 'is_active' => true],
|
['badge_id' => 'SEC-002', 'name' => 'Budi Santoso', 'team' => 2, 'gate' => 'ADIT1'],
|
||||||
['name' => 'Hendra Pratama', 'is_active' => true],
|
['badge_id' => 'SEC-003', 'name' => 'Hendra Pratama', 'team' => 3, 'gate' => 'REGWEIR'],
|
||||||
['name' => 'Rusli Efendi', 'is_active' => true],
|
['badge_id' => 'SEC-004', 'name' => 'Rusli Efendi', 'team' => 1, 'gate' => 'ADIT2'],
|
||||||
['name' => 'Slamet Widodo', 'is_active' => true],
|
['badge_id' => 'SEC-005', 'name' => 'Slamet Widodo', 'team' => 2, 'gate' => 'ADIT3'],
|
||||||
];
|
];
|
||||||
foreach ($guards as $guard) {
|
|
||||||
SecurityGuard::create($guard);
|
foreach ($guardData as $g) {
|
||||||
|
$gateModel = $createdGates[$g['gate']];
|
||||||
|
$guardUser = User::create([
|
||||||
|
'name' => $g['name'],
|
||||||
|
'username' => $g['badge_id'],
|
||||||
|
'email' => strtolower($g['badge_id']) . '@kmh.co.id',
|
||||||
|
'password' => Hash::make('password'),
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'gate_id' => $gateModel->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
SecurityGuard::create([
|
||||||
|
'badge_id' => $g['badge_id'],
|
||||||
|
'name' => $g['name'],
|
||||||
|
'team' => $g['team'],
|
||||||
|
'gate_id' => $gateModel->id,
|
||||||
|
'user_id' => $guardUser->id,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Seed Users (Admin & Shared Gate Accounts)
|
// 3. Seed Users (Admin & Shared Gate Accounts)
|
||||||
|
|||||||
@@ -5,79 +5,89 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<!-- Header Pos Gerbang -->
|
<!-- Header Pos Gerbang -->
|
||||||
<div class="bg-gradient-to-r from-slate-900 to-slate-800 text-white p-5 rounded-xl shadow-md border border-slate-700 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
<div class="bg-gradient-to-r from-slate-900 to-slate-800 text-white p-5 rounded-2xl shadow-md border border-slate-700 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-xs font-semibold bg-blue-500/20 text-blue-300 border border-blue-500/30">
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-lg text-xs font-bold bg-blue-500/20 text-blue-300 border border-blue-500/30">
|
||||||
<i class="fa-solid fa-shield-halved mr-1"></i> Pos Gerbang Aktif
|
<i class="fa-solid fa-shield-halved mr-1.5 text-blue-400"></i> Pos Gerbang Aktif
|
||||||
</span>
|
</span>
|
||||||
<span class="text-xs text-slate-400">Akun Bersama Pos Jaga</span>
|
|
||||||
|
@if($currentGuard)
|
||||||
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-lg text-xs font-bold bg-emerald-500/20 text-emerald-300 border border-emerald-500/30">
|
||||||
|
<i class="fa-solid fa-user-check mr-1.5 text-emerald-400"></i>
|
||||||
|
Petugas: {{ $currentGuard->name }} (ID: {{ $currentGuard->badge_id }}) • Regu {{ $currentGuard->team }}
|
||||||
|
</span>
|
||||||
|
@else
|
||||||
|
<span class="text-xs text-slate-400">Akun Pengawas / Bersama</span>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<h2 class="text-2xl font-black text-white tracking-tight mt-1">
|
|
||||||
|
<h2 class="text-2xl font-black text-white tracking-tight mt-1.5">
|
||||||
{{ $gate ? $gate->name : 'Pos Gerbang Belum Dipilih' }}
|
{{ $gate ? $gate->name : 'Pos Gerbang Belum Dipilih' }}
|
||||||
</h2>
|
</h2>
|
||||||
<p class="text-xs text-slate-300 mt-1">
|
<p class="text-xs text-slate-300 mt-1">
|
||||||
Petugas Satpam yang sedang piket wajib memverifikasi kondisi fisik kendaraan dan angka odometer riil sebelum membuka portal.
|
Petugas Satpam yang sedang piket wajib memverifikasi kondisi fisik kendaraan dan angka odometer riil sebelum membuka portal.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span class="bg-amber-500/20 text-amber-300 border border-amber-500/30 font-bold px-3 py-1.5 rounded-lg text-sm flex items-center">
|
<span class="bg-amber-500/20 text-amber-300 border border-amber-500/30 font-bold px-3.5 py-2 rounded-xl text-xs flex items-center shadow-sm">
|
||||||
<i class="fa-solid fa-clock-rotate-left mr-2 animate-spin"></i>
|
<i class="fa-solid fa-clock-rotate-left mr-2 animate-spin text-amber-400"></i>
|
||||||
Antrean: {{ $pendingActivities->count() }} Kendaraan
|
Antrean: {{ $pendingActivities->count() }} Kendaraan
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Antrean Validasi Kendaraan -->
|
<!-- Antrean Validasi Kendaraan -->
|
||||||
<div class="bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
|
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
|
||||||
<div class="p-4 bg-slate-50 border-b border-slate-200 flex justify-between items-center">
|
<div class="p-4 bg-slate-50 border-b border-slate-100 flex justify-between items-center">
|
||||||
<h3 class="text-sm font-bold text-slate-800 uppercase tracking-wider flex items-center">
|
<h3 class="text-xs font-bold text-slate-800 uppercase tracking-wider flex items-center">
|
||||||
<i class="fa-solid fa-car-side text-emerald-600 mr-2"></i> Kendaraan Menunggu Verifikasi Fisik
|
<i class="fa-solid fa-car-side text-emerald-600 mr-2"></i> Kendaraan Menunggu Verifikasi Fisik
|
||||||
</h3>
|
</h3>
|
||||||
<span class="text-xs text-slate-500">Auto-refresh saat halaman dimuat ulang</span>
|
<span class="text-xs text-slate-500">Auto-refresh saat halaman dimuat ulang</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divide-y divide-slate-200">
|
<div class="divide-y divide-slate-100">
|
||||||
@forelse($pendingActivities as $act)
|
@forelse($pendingActivities as $act)
|
||||||
<div class="p-5 hover:bg-slate-50 transition flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4">
|
<div class="p-5 hover:bg-slate-50/70 transition flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4">
|
||||||
<div class="space-y-2 flex-1">
|
<div class="space-y-2 flex-1">
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
<span class="text-sm font-black font-mono bg-slate-900 text-white px-2.5 py-1 rounded">
|
<span class="text-sm font-black font-mono bg-slate-900 text-white px-2.5 py-1 rounded-lg">
|
||||||
{{ $act->vehicle->code }}
|
{{ $act->vehicle->code }}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-xs font-bold text-amber-600 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded">
|
<span class="text-xs font-bold text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded font-mono">
|
||||||
{{ $act->vehicle->license_plate ?? 'Tanpa Plat' }}
|
{{ $act->vehicle->license_plate ?? 'Tanpa Plat' }}
|
||||||
</span>
|
</span>
|
||||||
@if($act->direction === 'in')
|
@if($act->direction === 'in')
|
||||||
<span class="text-xs font-bold bg-emerald-100 text-emerald-800 px-2.5 py-0.5 rounded-full border border-emerald-300">
|
<span class="text-xs font-bold bg-emerald-50 text-emerald-700 px-2.5 py-0.5 rounded-full border border-emerald-200">
|
||||||
<i class="fa-solid fa-arrow-right-to-bracket mr-1"></i> MASUK (In)
|
<i class="fa-solid fa-arrow-right-to-bracket mr-1 text-emerald-600"></i> MASUK (In)
|
||||||
</span>
|
</span>
|
||||||
@else
|
@else
|
||||||
<span class="text-xs font-bold bg-blue-100 text-blue-800 px-2.5 py-0.5 rounded-full border border-blue-300">
|
<span class="text-xs font-bold bg-blue-50 text-blue-700 px-2.5 py-0.5 rounded-full border border-blue-200">
|
||||||
<i class="fa-solid fa-arrow-right-from-bracket mr-1"></i> KELUAR (Out)
|
<i class="fa-solid fa-arrow-right-from-bracket mr-1 text-blue-600"></i> KELUAR (Out)
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
<span class="text-xs text-slate-500 font-mono">
|
<span class="text-xs text-slate-400 font-mono">
|
||||||
Diinput: {{ $act->recorded_at->format('H:i:s d/m/Y') }}
|
Diinput: {{ $act->recorded_at->format('H:i:s d/m/Y') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-3 text-xs text-slate-600 pt-1">
|
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-3 text-xs text-slate-600 pt-1">
|
||||||
<div><span class="text-slate-400 block">Unit:</span> <strong class="text-slate-800">{{ $act->vehicle->brand_type }}</strong></div>
|
<div><span class="text-slate-400 block text-[11px]">Unit:</span> <strong class="text-slate-800">{{ $act->vehicle->brand_type }}</strong></div>
|
||||||
<div><span class="text-slate-400 block">Pengemudi:</span> <strong class="text-slate-800">{{ $act->driver->name }}</strong> ({{ $act->driver->division ?? '-' }})</div>
|
<div><span class="text-slate-400 block text-[11px]">Pengemudi:</span> <strong class="text-slate-800">{{ $act->driver->name }}</strong> ({{ $act->driver->division ?? '-' }})</div>
|
||||||
<div><span class="text-slate-400 block">KM Input (Odometer):</span> <strong class="text-emerald-700 text-sm font-mono">{{ number_format($act->current_km, 0, ',', '.') }} KM</strong></div>
|
<div><span class="text-slate-400 block text-[11px]">KM Odometer Input:</span> <strong class="text-emerald-700 text-sm font-mono font-bold">{{ number_format($act->current_km, 0, ',', '.') }} KM</strong></div>
|
||||||
<div><span class="text-slate-400 block">Jarak Sesi Ini:</span> <strong class="text-slate-800 font-mono">+{{ number_format($act->distance, 0, ',', '.') }} KM</strong></div>
|
<div><span class="text-slate-400 block text-[11px]">Jarak Sesi Ini:</span> <strong class="text-slate-800 font-mono">+{{ number_format($act->distance, 0, ',', '.') }} KM</strong></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-xs bg-slate-100 p-2.5 rounded-lg border border-slate-200 text-slate-700">
|
<div class="text-xs bg-slate-50 p-2.5 rounded-xl border border-slate-200 text-slate-700">
|
||||||
<span class="font-bold text-slate-800">Rencana Kerja:</span> {{ $act->purpose }}
|
<span class="font-bold text-slate-800">Keperluan Kerja:</span> {{ $act->purpose }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tombol Aksi Verifikasi Satpam -->
|
<!-- Tombol Aksi Verifikasi Satpam -->
|
||||||
<div class="flex items-center space-x-2 self-end lg:self-center">
|
<div class="flex items-center space-x-2 self-end lg:self-center">
|
||||||
<button onclick="openVerificationModal({{ $act->id }}, '{{ $act->vehicle->code }}', '{{ $act->current_km }}', '{{ $act->driver->name }}')"
|
<button onclick="openVerificationModal({{ $act->id }}, '{{ $act->vehicle->code }}', '{{ $act->current_km }}', '{{ $act->driver->name }}')"
|
||||||
class="bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-lg shadow-sm transition flex items-center space-x-1.5">
|
class="bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-xl shadow-sm transition flex items-center space-x-1.5">
|
||||||
<i class="fa-solid fa-clipboard-check"></i>
|
<i class="fa-solid fa-clipboard-check"></i>
|
||||||
<span>Verifikasi Satpam</span>
|
<span>Verifikasi Satpam</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -86,8 +96,8 @@
|
|||||||
@empty
|
@empty
|
||||||
<div class="p-12 text-center text-slate-400">
|
<div class="p-12 text-center text-slate-400">
|
||||||
<i class="fa-solid fa-circle-check text-4xl text-emerald-400 mb-2 block"></i>
|
<i class="fa-solid fa-circle-check text-4xl text-emerald-400 mb-2 block"></i>
|
||||||
<p class="text-sm font-medium text-slate-600">Tidak ada kendaraan yang menunggu verifikasi di gerbang ini saat ini.</p>
|
<p class="text-sm font-bold text-slate-700">Tidak ada kendaraan yang menunggu verifikasi saat ini.</p>
|
||||||
<span class="text-xs text-slate-400">Semua aktivitas kendaraan telah diperiksa atau belum ada pemindaian baru.</span>
|
<span class="text-xs text-slate-400">Semua aktivitas kendaraan di pos gerbang ini telah diperiksa.</span>
|
||||||
</div>
|
</div>
|
||||||
@endforelse
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
@@ -96,57 +106,80 @@
|
|||||||
|
|
||||||
<!-- Modal Dialog Verifikasi Satpam -->
|
<!-- Modal Dialog Verifikasi Satpam -->
|
||||||
<div id="verificationModal" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
<div id="verificationModal" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
<div class="bg-white rounded-xl shadow-2xl max-w-md w-full overflow-hidden border border-slate-200 animate-in fade-in zoom-in duration-150">
|
<div class="bg-white rounded-2xl shadow-2xl max-w-md w-full overflow-hidden border border-slate-200 animate-in fade-in zoom-in duration-150">
|
||||||
<div class="bg-slate-900 text-white p-4 flex justify-between items-center">
|
<div class="bg-[#06213f] text-white p-4 flex justify-between items-center">
|
||||||
<h3 class="text-sm font-bold flex items-center">
|
<h3 class="text-sm font-bold flex items-center">
|
||||||
<i class="fa-solid fa-user-shield text-emerald-400 mr-2"></i> Pemeriksaan Fisik Satpam
|
<i class="fa-solid fa-user-shield text-emerald-400 mr-2"></i> Pemeriksaan Fisik Satpam
|
||||||
</h3>
|
</h3>
|
||||||
<button onclick="closeVerificationModal()" class="text-slate-400 hover:text-white"><i class="fa-solid fa-xmark"></i></button>
|
<button onclick="closeVerificationModal()" class="text-slate-400 hover:text-white transition">
|
||||||
|
<i class="fa-solid fa-xmark text-base"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-5 space-y-4">
|
<div class="p-5 space-y-4">
|
||||||
<div class="bg-slate-50 p-3 rounded-lg border border-slate-200 text-xs space-y-1">
|
<div class="bg-slate-50 p-3.5 rounded-xl border border-slate-200 text-xs space-y-1.5">
|
||||||
<div><span class="text-slate-500">Unit:</span> <strong id="modalUnitCode" class="text-slate-800 font-mono"></strong></div>
|
<div><span class="text-slate-500">Unit:</span> <strong id="modalUnitCode" class="text-slate-800 font-mono font-bold"></strong></div>
|
||||||
<div><span class="text-slate-500">Driver:</span> <strong id="modalDriverName" class="text-slate-800"></strong></div>
|
<div><span class="text-slate-500">Driver:</span> <strong id="modalDriverName" class="text-slate-800 font-bold"></strong></div>
|
||||||
<div><span class="text-slate-500">KM Odometer Input:</span> <strong id="modalKmInput" class="text-emerald-700 font-mono text-sm"></strong> KM</div>
|
<div><span class="text-slate-500">KM Odometer Input:</span> <strong id="modalKmInput" class="text-emerald-700 font-mono text-sm font-bold"></strong> KM</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Identitas Petugas Satpam Pemeriksa -->
|
||||||
|
@if($currentGuard)
|
||||||
|
<div class="p-3 bg-emerald-50 rounded-xl border border-emerald-200 text-xs flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<span class="text-slate-500 block text-[10px] font-semibold uppercase tracking-wider">Petugas Pemeriksa:</span>
|
||||||
|
<strong class="text-emerald-800 font-bold text-sm">{{ $currentGuard->name }}</strong>
|
||||||
|
<div class="text-slate-600 text-[11px] font-mono mt-0.5">
|
||||||
|
ID: {{ $currentGuard->badge_id }} • Regu {{ $currentGuard->team }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="w-8 h-8 rounded-full bg-emerald-100 flex items-center justify-center text-emerald-600">
|
||||||
|
<i class="fa-solid fa-circle-check text-base"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Form Approve -->
|
<!-- Form Approve -->
|
||||||
<form id="approveForm" method="POST" action="">
|
<form id="approveForm" method="POST" action="">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="mb-4">
|
|
||||||
<label for="security_guard_id" class="block text-xs font-semibold text-slate-700 mb-1">
|
@if(!$currentGuard)
|
||||||
Pilih Nama Satpam yang Bertugas <span class="text-rose-500">*</span>
|
<div class="mb-4">
|
||||||
</label>
|
<label for="security_guard_id" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
<select name="security_guard_id" id="security_guard_id" required class="w-full text-xs rounded-lg border-slate-300 border p-2.5 focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500">
|
Pilih Nama Satpam Pemeriksa <span class="text-rose-500">*</span>
|
||||||
<option value="" disabled selected>-- Pilih Nama Anda (Satpam) --</option>
|
</label>
|
||||||
@foreach($guards as $guard)
|
<select name="security_guard_id" id="security_guard_id" required class="w-full text-xs rounded-xl border-slate-200 border p-2.5 bg-slate-50/50 hover:bg-white focus:bg-white">
|
||||||
<option value="{{ $guard->id }}">{{ $guard->name }}</option>
|
<option value="" disabled selected>-- Pilih Petugas Satpam --</option>
|
||||||
@endforeach
|
@foreach($guards as $guard)
|
||||||
</select>
|
<option value="{{ $guard->id }}">{{ $guard->name }} (Regu {{ $guard->team }})</option>
|
||||||
</div>
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="flex items-center space-x-2 pt-2 border-t border-slate-200">
|
<div class="flex items-center space-x-2 pt-2 border-t border-slate-100">
|
||||||
<button type="submit" class="flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-lg transition flex items-center justify-center space-x-1">
|
<button type="submit" class="flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs py-2.5 px-4 rounded-xl transition flex items-center justify-center space-x-1.5 shadow-sm">
|
||||||
<i class="fa-solid fa-check"></i>
|
<i class="fa-solid fa-check"></i>
|
||||||
<span>Setujui (Buka Portal)</span>
|
<span>Setujui (Buka Portal)</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onclick="showRejectSection()" class="bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-300 font-bold text-xs py-2.5 px-3 rounded-lg transition">
|
<button type="button" onclick="showRejectSection()" class="bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200 font-bold text-xs py-2.5 px-3.5 rounded-xl transition">
|
||||||
Tolak
|
Tolak
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Section Form Reject (Hidden by default) -->
|
<!-- Section Form Reject (Hidden by default) -->
|
||||||
<form id="rejectForm" method="POST" action="" class="hidden border-t border-rose-200 pt-3">
|
<form id="rejectForm" method="POST" action="" class="hidden border-t border-rose-100 pt-3">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-rose-800 mb-1">Alasan Penolakan <span class="text-rose-500">*</span></label>
|
<label class="block text-xs font-bold text-rose-800 mb-1">Alasan Penolakan <span class="text-rose-500">*</span></label>
|
||||||
<textarea name="rejection_note" required rows="2" placeholder="Contoh: Angka KM di dashboard tidak cocok, driver tidak memiliki izin membawa penumpang..." class="w-full text-xs rounded-lg border-rose-300 border p-2 focus:ring-rose-500 focus:border-rose-500"></textarea>
|
<textarea name="rejection_note" required rows="2" placeholder="Contoh: Angka KM di dashboard tidak cocok, driver tidak memiliki SIMPER aktif..." class="w-full text-xs rounded-xl border-rose-300 border p-2.5 focus:ring-rose-500 focus:border-rose-500 bg-rose-50/20"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="security_guard_id" id="rejectGuardId">
|
@if(!$currentGuard)
|
||||||
<button type="submit" class="w-full bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs py-2 px-3 rounded-lg transition">
|
<input type="hidden" name="security_guard_id" id="rejectGuardId">
|
||||||
|
@endif
|
||||||
|
<button type="submit" class="w-full bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs py-2.5 px-3 rounded-xl transition shadow-sm">
|
||||||
Konfirmasi Tolak Kendaraan
|
Konfirmasi Tolak Kendaraan
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,14 +187,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
|
||||||
|
|
||||||
@section('scripts')
|
|
||||||
<script>
|
<script>
|
||||||
|
let currentActivityId = null;
|
||||||
|
|
||||||
function openVerificationModal(activityId, unitCode, kmInput, driverName) {
|
function openVerificationModal(activityId, unitCode, kmInput, driverName) {
|
||||||
|
currentActivityId = activityId;
|
||||||
document.getElementById('modalUnitCode').textContent = unitCode;
|
document.getElementById('modalUnitCode').textContent = unitCode;
|
||||||
|
document.getElementById('modalKmInput').textContent = Number(kmInput).toLocaleString('id-ID');
|
||||||
document.getElementById('modalDriverName').textContent = driverName;
|
document.getElementById('modalDriverName').textContent = driverName;
|
||||||
document.getElementById('modalKmInput').textContent = parseFloat(kmInput).toLocaleString('id-ID');
|
|
||||||
|
|
||||||
document.getElementById('approveForm').action = `/pg/gate-inspection/${activityId}/approve`;
|
document.getElementById('approveForm').action = `/pg/gate-inspection/${activityId}/approve`;
|
||||||
document.getElementById('rejectForm').action = `/pg/gate-inspection/${activityId}/reject`;
|
document.getElementById('rejectForm').action = `/pg/gate-inspection/${activityId}/reject`;
|
||||||
@@ -176,12 +210,17 @@
|
|||||||
|
|
||||||
function showRejectSection() {
|
function showRejectSection() {
|
||||||
const guardSelect = document.getElementById('security_guard_id');
|
const guardSelect = document.getElementById('security_guard_id');
|
||||||
if (!guardSelect.value) {
|
const rejectGuardInput = document.getElementById('rejectGuardId');
|
||||||
alert('Silakan pilih nama Satpam terlebih dahulu sebelum menolak.');
|
|
||||||
guardSelect.focus();
|
if (guardSelect && rejectGuardInput) {
|
||||||
return;
|
if (!guardSelect.value) {
|
||||||
|
alert('Silakan pilih nama petugas Satpam terlebih dahulu sebelum menolak!');
|
||||||
|
guardSelect.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rejectGuardInput.value = guardSelect.value;
|
||||||
}
|
}
|
||||||
document.getElementById('rejectGuardId').value = guardSelect.value;
|
|
||||||
document.getElementById('rejectForm').classList.toggle('hidden');
|
document.getElementById('rejectForm').classList.toggle('hidden');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,82 +4,237 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 bg-white p-5 rounded-xl border border-slate-200 shadow-sm">
|
<!-- Header Halaman -->
|
||||||
|
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-xl font-bold text-slate-900 tracking-tight flex items-center">
|
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
|
||||||
<i class="fa-solid fa-user-shield text-emerald-600 mr-2.5"></i> Master Data Satpam (Private Guard)
|
MANAJEMEN SISTEM
|
||||||
</h2>
|
</span>
|
||||||
|
<div class="flex items-center space-x-3">
|
||||||
|
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
|
||||||
|
Master Data Satpam (PG)
|
||||||
|
</h2>
|
||||||
|
<span class="w-6 h-6 rounded-full bg-slate-200/90 text-slate-500 text-xs inline-flex items-center justify-center font-bold shadow-sm" title="Kelola data petugas keamanan, regu tugas, dan akun login penempatan pos gerbang">
|
||||||
|
<i class="fa-solid fa-user-shield"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<p class="text-xs text-slate-500 mt-1">
|
<p class="text-xs text-slate-500 mt-1">
|
||||||
Kelola data petugas keamanan yang bertugas melakukan verifikasi kendaraan di pos gerbang proyek.
|
Data petugas keamanan, pembagian regu kerja (1, 2, 3), dan hak akses verifikasi pos gerbang.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Metric Counter Badges -->
|
||||||
|
<div class="flex items-center space-x-2 w-full sm:w-auto">
|
||||||
|
<span class="inline-flex items-center px-3.5 py-2 rounded-xl text-xs font-bold bg-emerald-50 text-emerald-800 border border-emerald-200 shadow-sm">
|
||||||
|
<i class="fa-solid fa-users-gear mr-1.5 text-emerald-600"></i> Total: {{ $guards->count() }} Petugas
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
<!-- Layout Grid: Form Tambah & Tabel Satpam -->
|
||||||
<!-- Form Tambah Satpam Baru -->
|
<div class="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start">
|
||||||
<div class="bg-white p-5 rounded-xl border border-slate-200 shadow-sm h-fit">
|
<!-- Form Tambah Petugas Satpam (Kiri - 4 Kolom) -->
|
||||||
<h3 class="text-sm font-bold text-slate-800 uppercase tracking-wider mb-4 flex items-center">
|
<div class="lg:col-span-4 bg-white p-5 rounded-2xl border border-slate-200 shadow-sm">
|
||||||
<i class="fa-solid fa-user-plus text-emerald-600 mr-2"></i> Tambah Petugas Satpam
|
<div class="flex items-center space-x-2 pb-3 mb-4 border-b border-slate-100">
|
||||||
</h3>
|
<i class="fa-solid fa-user-plus text-[#1b5e20]"></i>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 uppercase tracking-wider">
|
||||||
|
Tambah Petugas Satpam
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form action="{{ route('pg.guards.store') }}" method="POST" class="space-y-4">
|
<form action="{{ route('pg.guards.store') }}" method="POST" class="space-y-4">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
|
<!-- ID Satpam -->
|
||||||
<div>
|
<div>
|
||||||
<label for="name" class="block text-xs font-semibold text-slate-700 mb-1">
|
<label for="badge_id" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
Nama Lengkap Satpam <span class="text-rose-500">*</span>
|
ID Satpam <span class="text-rose-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" name="name" id="name" required placeholder="Contoh: Budi Santoso" class="w-full text-xs rounded-lg border-slate-300 border p-2.5 focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500">
|
<input type="text"
|
||||||
|
name="badge_id"
|
||||||
|
id="badge_id"
|
||||||
|
value="{{ old('badge_id') }}"
|
||||||
|
required
|
||||||
|
placeholder="Contoh: SEC-006 atau PG-06"
|
||||||
|
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 uppercase font-mono focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">ID ini akan digunakan satpam sebagai username login.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Nama Lengkap -->
|
||||||
|
<div>
|
||||||
|
<label for="name" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Nama Lengkap <span class="text-rose-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text"
|
||||||
|
name="name"
|
||||||
|
id="name"
|
||||||
|
value="{{ old('name') }}"
|
||||||
|
required
|
||||||
|
placeholder="Contoh: Budi Santoso"
|
||||||
|
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Regu Satpam (1, 2, 3) -->
|
||||||
|
<div>
|
||||||
|
<label for="team" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Regu Tugas <span class="text-rose-500">*</span>
|
||||||
|
</label>
|
||||||
|
<select name="team"
|
||||||
|
id="team"
|
||||||
|
required
|
||||||
|
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
<option value="" disabled selected>-- Pilih Regu (1, 2, atau 3) --</option>
|
||||||
|
<option value="1" {{ old('team') == 1 ? 'selected' : '' }}>Regu 1</option>
|
||||||
|
<option value="2" {{ old('team') == 2 ? 'selected' : '' }}>Regu 2</option>
|
||||||
|
<option value="3" {{ old('team') == 3 ? 'selected' : '' }}>Regu 3</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Penempatan Pos Gerbang -->
|
||||||
|
<div>
|
||||||
|
<label for="gate_id" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Penempatan Pos Gerbang <span class="text-rose-500">*</span>
|
||||||
|
</label>
|
||||||
|
<select name="gate_id"
|
||||||
|
id="gate_id"
|
||||||
|
required
|
||||||
|
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
<option value="" disabled selected>-- Pilih Pos Gerbang Penempatan --</option>
|
||||||
|
@foreach($gates as $gate)
|
||||||
|
<option value="{{ $gate->id }}" {{ old('gate_id') == $gate->id ? 'selected' : '' }}>
|
||||||
|
{{ $gate->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Password Akun Login -->
|
||||||
|
<div>
|
||||||
|
<label for="password" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Password Akun Login <span class="text-rose-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
id="password"
|
||||||
|
required
|
||||||
|
placeholder="Minimal 4 karakter"
|
||||||
|
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-2">
|
||||||
|
<button type="submit" class="w-full bg-[#06213f] hover:bg-[#0b315b] text-white font-bold text-xs py-2.5 px-4 rounded-xl shadow-sm transition flex items-center justify-center space-x-2">
|
||||||
|
<i class="fa-solid fa-floppy-disk text-[11px]"></i>
|
||||||
|
<span>Simpan Data Satpam</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="w-full bg-slate-900 hover:bg-slate-800 text-white font-bold text-xs py-2.5 px-4 rounded-lg shadow-sm transition">
|
|
||||||
<i class="fa-solid fa-floppy-disk mr-1"></i> Simpan Data Satpam
|
|
||||||
</button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tabel Daftar Satpam -->
|
<!-- Tabel Daftar Petugas Satpam (Kanan - 8 Kolom) -->
|
||||||
<div class="md:col-span-2 bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
|
<div class="lg:col-span-8 bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
|
||||||
<div class="p-4 bg-slate-50 border-b border-slate-200">
|
<div class="p-4 bg-slate-50 border-b border-slate-100 flex items-center justify-between">
|
||||||
<h3 class="text-xs font-bold text-slate-700 uppercase tracking-wider">
|
<div class="flex items-center space-x-2">
|
||||||
Daftar Petugas Satpam Aktif & Nonaktif
|
<i class="fa-solid fa-id-card-clip text-slate-500"></i>
|
||||||
</h3>
|
<h3 class="text-xs font-bold text-slate-800 uppercase tracking-wider">
|
||||||
|
Daftar Petugas Satpam Terdaftar
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-slate-200 text-xs text-left">
|
<table class="min-w-full text-xs text-left border-collapse">
|
||||||
<thead class="bg-slate-100 font-semibold text-slate-600 uppercase tracking-wider">
|
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="py-3 px-4 text-center">No</th>
|
<th class="py-3.5 px-4 text-center whitespace-nowrap">ID Satpam</th>
|
||||||
<th class="py-3 px-4">Nama Lengkap</th>
|
<th class="py-3.5 px-4 whitespace-nowrap">Nama Lengkap</th>
|
||||||
<th class="py-3 px-4 text-center">Status Piket</th>
|
<th class="py-3.5 px-4 text-center whitespace-nowrap">Regu</th>
|
||||||
<th class="py-3 px-4 text-center">Aksi</th>
|
<th class="py-3.5 px-4 whitespace-nowrap">Penempatan</th>
|
||||||
|
<th class="py-3.5 px-4 text-center whitespace-nowrap">Status</th>
|
||||||
|
<th class="py-3.5 px-4 text-center whitespace-nowrap">Aksi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-slate-200 text-slate-700">
|
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
|
||||||
@forelse($guards as $index => $g)
|
@forelse($guards as $g)
|
||||||
<tr class="hover:bg-slate-50 transition">
|
<tr class="hover:bg-slate-50/70 transition">
|
||||||
<td class="py-3 px-4 text-center text-slate-400">{{ $index + 1 }}</td>
|
<!-- ID Satpam -->
|
||||||
<td class="py-3 px-4 font-bold text-slate-800">{{ $g->name }}</td>
|
<td class="py-3.5 px-4 text-center whitespace-nowrap font-mono">
|
||||||
<td class="py-3 px-4 text-center">
|
<span class="inline-block bg-slate-100 text-slate-800 font-bold px-2 py-0.5 rounded border border-slate-200">
|
||||||
|
{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- Nama Lengkap -->
|
||||||
|
<td class="py-3.5 px-4">
|
||||||
|
<div class="font-bold text-slate-900">{{ $g->name }}</div>
|
||||||
|
<div class="text-[10px] text-slate-400 font-mono">User: {{ $g->badge_id ?? '-' }}</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- Regu (1, 2, 3) -->
|
||||||
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
|
@if($g->team == 1)
|
||||||
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-blue-50 text-blue-700 border border-blue-200">
|
||||||
|
Regu 1
|
||||||
|
</span>
|
||||||
|
@elseif($g->team == 2)
|
||||||
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
|
||||||
|
Regu 2
|
||||||
|
</span>
|
||||||
|
@else
|
||||||
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-purple-50 text-purple-700 border border-purple-200">
|
||||||
|
Regu 3
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- Penempatan Pos Gerbang -->
|
||||||
|
<td class="py-3.5 px-4 whitespace-nowrap">
|
||||||
|
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-semibold bg-slate-100 text-slate-700 border border-slate-200">
|
||||||
|
<i class="fa-solid fa-torii-gate mr-1.5 text-slate-400 text-[10px]"></i>
|
||||||
|
{{ $g->gate->name ?? 'Belum Ditentukan' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- Status Aktif / Nonaktif -->
|
||||||
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
@if($g->is_active)
|
@if($g->is_active)
|
||||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-emerald-100 text-emerald-800">
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
|
||||||
Aktif
|
Aktif
|
||||||
</span>
|
</span>
|
||||||
@else
|
@else
|
||||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-slate-100 text-slate-500">
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-slate-100 text-slate-500 border border-slate-200">
|
||||||
Nonaktif
|
Nonaktif
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="py-3 px-4 text-center">
|
|
||||||
<form action="{{ route('pg.guards.toggle', $g->id) }}" method="POST" class="inline">
|
<!-- Aksi (Edit & Toggle) -->
|
||||||
@csrf
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
<button type="submit" class="text-[11px] font-medium text-slate-600 hover:text-slate-900 underline">
|
<div class="flex items-center justify-center space-x-2">
|
||||||
{{ $g->is_active ? 'Nonaktifkan' : 'Aktifkan' }}
|
<!-- Tombol Edit -->
|
||||||
|
<button type="button"
|
||||||
|
onclick="openEditGuardModal({{ json_encode($g) }})"
|
||||||
|
class="px-2.5 py-1 text-[11px] font-bold text-slate-700 bg-slate-100 hover:bg-slate-200 border border-slate-200 rounded-lg transition"
|
||||||
|
title="Edit Data / Reset Password">
|
||||||
|
<i class="fa-solid fa-pen-to-square"></i>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
|
||||||
|
<!-- Tombol Toggle Status -->
|
||||||
|
<form action="{{ route('pg.guards.toggle', $g->id) }}" method="POST" class="inline">
|
||||||
|
@csrf
|
||||||
|
<button type="submit"
|
||||||
|
class="px-2.5 py-1 text-[11px] font-semibold {{ $g->is_active ? 'text-rose-600 hover:bg-rose-50 border border-rose-200' : 'text-emerald-700 hover:bg-emerald-50 border border-emerald-200' }} rounded-lg transition">
|
||||||
|
{{ $g->is_active ? 'Nonaktifkan' : 'Aktifkan' }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@empty
|
@empty
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="py-6 text-center text-slate-400">Belum ada data petugas Satpam.</td>
|
<td colspan="6" class="py-10 text-center text-slate-400">
|
||||||
|
<i class="fa-solid fa-user-slash text-3xl mb-2 block"></i>
|
||||||
|
Belum ada data petugas Satpam terdaftar.
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforelse
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -88,4 +243,92 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Edit Data Petugas Satpam -->
|
||||||
|
<div id="editGuardModal" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl shadow-2xl max-w-md w-full overflow-hidden border border-slate-200 animate-in fade-in zoom-in duration-150">
|
||||||
|
<div class="bg-[#06213f] text-white p-4 flex justify-between items-center">
|
||||||
|
<h3 class="text-sm font-bold flex items-center">
|
||||||
|
<i class="fa-solid fa-user-pen mr-2 text-emerald-400"></i> Edit Data Petugas Satpam
|
||||||
|
</h3>
|
||||||
|
<button onclick="closeEditGuardModal()" class="text-slate-400 hover:text-white transition">
|
||||||
|
<i class="fa-solid fa-xmark text-base"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="editGuardForm" method="POST" action="" class="p-5 space-y-4">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<!-- ID Satpam (Readonly) -->
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">ID Satpam (Username Login)</label>
|
||||||
|
<input type="text" id="editBadgeId" disabled class="w-full text-xs rounded-xl border border-slate-200 bg-slate-100 px-3.5 py-2.5 text-slate-500 font-mono font-bold">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Nama Lengkap -->
|
||||||
|
<div>
|
||||||
|
<label for="editName" class="block text-xs font-bold text-slate-700 mb-1">Nama Lengkap <span class="text-rose-500">*</span></label>
|
||||||
|
<input type="text" name="name" id="editName" required class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Regu (1, 2, 3) -->
|
||||||
|
<div>
|
||||||
|
<label for="editTeam" class="block text-xs font-bold text-slate-700 mb-1">Regu Tugas <span class="text-rose-500">*</span></label>
|
||||||
|
<select name="team" id="editTeam" required class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
<option value="1">Regu 1</option>
|
||||||
|
<option value="2">Regu 2</option>
|
||||||
|
<option value="3">Regu 3</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Penempatan Pos Gerbang -->
|
||||||
|
<div>
|
||||||
|
<label for="editGateId" class="block text-xs font-bold text-slate-700 mb-1">Penempatan Pos Gerbang <span class="text-rose-500">*</span></label>
|
||||||
|
<select name="gate_id" id="editGateId" required class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
@foreach($gates as $gate)
|
||||||
|
<option value="{{ $gate->id }}">{{ $gate->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Reset Password (Opsional) -->
|
||||||
|
<div>
|
||||||
|
<label for="editPassword" class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Ganti Password Baru <span class="text-slate-400 font-normal">(Kosongkan jika tidak ingin diubah)</span>
|
||||||
|
</label>
|
||||||
|
<input type="password" name="password" id="editPassword" placeholder="Minimal 4 karakter" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tombol Aksi Modal -->
|
||||||
|
<div class="flex items-center justify-end space-x-2 pt-3 border-t border-slate-100">
|
||||||
|
<button type="button" onclick="closeEditGuardModal()" class="px-4 py-2 text-xs font-semibold text-slate-600 bg-slate-100 hover:bg-slate-200 rounded-xl transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-5 py-2 text-xs font-bold text-white bg-[#06213f] hover:bg-[#0b315b] rounded-xl shadow-sm transition">
|
||||||
|
Simpan Perubahan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openEditGuardModal(guard) {
|
||||||
|
const modal = document.getElementById('editGuardModal');
|
||||||
|
const form = document.getElementById('editGuardForm');
|
||||||
|
|
||||||
|
form.action = `/pg/guards/${guard.id}`;
|
||||||
|
document.getElementById('editBadgeId').value = guard.badge_id || ('SEC-' + String(guard.id).padStart(3, '0'));
|
||||||
|
document.getElementById('editName').value = guard.name || '';
|
||||||
|
document.getElementById('editTeam').value = guard.team || 1;
|
||||||
|
document.getElementById('editGateId').value = guard.gate_id || '';
|
||||||
|
document.getElementById('editPassword').value = '';
|
||||||
|
|
||||||
|
modal.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEditGuardModal() {
|
||||||
|
document.getElementById('editGuardModal').classList.add('hidden');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ Route::middleware('auth')->group(function () {
|
|||||||
Route::middleware('role:pg_admin')->group(function () {
|
Route::middleware('role:pg_admin')->group(function () {
|
||||||
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index');
|
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index');
|
||||||
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store');
|
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store');
|
||||||
|
Route::post('/guards/{id}', [SecurityGuardController::class, 'update'])->name('guards.update');
|
||||||
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle');
|
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -182,4 +182,73 @@ class VehicleActivityTest extends TestCase
|
|||||||
$response->assertSee('KM Berjalan');
|
$response->assertSee('KM Berjalan');
|
||||||
$response->assertSee('Aktivitas');
|
$response->assertSee('Aktivitas');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_admin_pg_can_store_security_guard_and_creates_login_account(): void
|
||||||
|
{
|
||||||
|
$adminPg = User::where('role', 'pg_admin')->first();
|
||||||
|
$gate = Gate::first();
|
||||||
|
|
||||||
|
$response = $this->actingAs($adminPg)->post('/pg/guards', [
|
||||||
|
'badge_id' => 'SEC-999',
|
||||||
|
'name' => 'Kurniawan Pratama',
|
||||||
|
'team' => 2,
|
||||||
|
'gate_id' => $gate->id,
|
||||||
|
'password' => 'satpam123',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('security_guards', [
|
||||||
|
'badge_id' => 'SEC-999',
|
||||||
|
'name' => 'Kurniawan Pratama',
|
||||||
|
'team' => 2,
|
||||||
|
'gate_id' => $gate->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'username' => 'SEC-999',
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'gate_id' => $gate->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_guard_can_login_with_badge_id_and_auto_approve_without_manual_guard_id(): void
|
||||||
|
{
|
||||||
|
// Login with satpam SEC-001
|
||||||
|
$loginResponse = $this->post('/login', [
|
||||||
|
'username' => 'SEC-001',
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$loginResponse->assertRedirect(route('pg.gate.inspection'));
|
||||||
|
|
||||||
|
$guard = SecurityGuard::where('badge_id', 'SEC-001')->first();
|
||||||
|
$vehicle = Vehicle::first();
|
||||||
|
$driver = Employee::first();
|
||||||
|
|
||||||
|
$activity = VehicleActivity::create([
|
||||||
|
'transaction_no' => 'TRX-TEST-AUTO-01',
|
||||||
|
'vehicle_id' => $vehicle->id,
|
||||||
|
'driver_id' => $driver->id,
|
||||||
|
'gate_id' => $guard->gate_id,
|
||||||
|
'direction' => 'out',
|
||||||
|
'previous_km' => $vehicle->current_km,
|
||||||
|
'current_km' => $vehicle->current_km + 15,
|
||||||
|
'distance' => 15,
|
||||||
|
'purpose' => 'Uji Verifikasi Otomatis',
|
||||||
|
'recorded_at' => Carbon::now(),
|
||||||
|
'validation_status' => 'pending',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$guardUser = $guard->user;
|
||||||
|
$approveResponse = $this->actingAs($guardUser)->post("/pg/gate-inspection/{$activity->id}/approve");
|
||||||
|
|
||||||
|
$approveResponse->assertRedirect();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('vehicle_activities', [
|
||||||
|
'id' => $activity->id,
|
||||||
|
'validation_status' => 'approved',
|
||||||
|
'security_guard_id' => $guard->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user