feat: initial commit Sistem RKM Laravel (HSE, QMA, Pos Gerbang, QR Activity)

This commit is contained in:
Wahyudin
2026-10-12 23:47:41 +07:00
commit 21ce908199
94 changed files with 17600 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[compose.yaml]
indent_size = 4
+65
View File
@@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
# PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
+11
View File
@@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
+24
View File
@@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db
+59
View File
@@ -0,0 +1,59 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
### Premium Partners
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class LoginController extends Controller
{
/**
* Tampilkan halaman login sistem.
*/
public function showLoginForm(): View|RedirectResponse
{
if (Auth::check()) {
return $this->redirectBasedOnRole(Auth::user());
}
return view('auth.login');
}
/**
* Proses autentikasi pengguna menggunakan username & password.
*/
public function login(Request $request): RedirectResponse
{
$credentials = $request->validate([
'username' => ['required', 'string'],
'password' => ['required', 'string'],
], [
'username.required' => 'Username atau email wajib diisi.',
'password.required' => 'Password wajib diisi.',
]);
$remember = $request->boolean('remember');
$loginField = filter_var($credentials['username'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
if (Auth::attempt([$loginField => $credentials['username'], 'password' => $credentials['password']], $remember)) {
$request->session()->regenerate();
/** @var \App\Models\User $user */
$user = Auth::user();
return $this->redirectBasedOnRole($user)
->with('success', "Selamat datang kembali, {$user->name}!");
}
return back()->withErrors([
'username' => 'Username atau password yang Anda masukkan salah.',
])->onlyInput('username');
}
/**
* Logout pengguna dari sistem.
*/
public function logout(Request $request): RedirectResponse
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('login')->with('success', 'Anda telah berhasil logout.');
}
/**
* Redirect cerdas berdasarkan role pengguna setelah login.
*/
private function redirectBasedOnRole($user): RedirectResponse
{
return match ($user->role) {
'hse_admin' => redirect()->route('hse.dashboard'),
'qma_admin' => redirect()->route('qma.dashboard'),
'pg_admin' => redirect()->route('pg.guards.index'),
'gate_officer' => redirect()->route('pg.gate.inspection'),
default => redirect()->route('qma.dashboard'),
};
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}
@@ -0,0 +1,146 @@
<?php
namespace App\Http\Controllers\Hse;
use App\Http\Controllers\Controller;
use App\Models\Employee;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class EmployeeController extends Controller
{
/**
* Tampilkan halaman dashboard Admin HSE (Format referensi enterprise IT KMH).
*/
public function dashboard(): View
{
$totalEmployees = Employee::count();
$totalDrivers = Employee::where('is_operator', true)->count();
$validSimperCount = Employee::where('is_operator', true)
->whereNotNull('simper_expired_at')
->where('simper_expired_at', '>=', now()->toDateString())
->count();
$expiredSimperCount = Employee::where('is_operator', true)
->where(function ($q) {
$q->whereNull('simper_expired_at')
->orWhere('simper_expired_at', '<', now()->toDateString());
})
->count();
$nonDriversCount = Employee::where('is_operator', false)->count();
// 1. Log Driver Terkini (Driver Aktif)
$recentDrivers = Employee::where('is_operator', true)
->orderByDesc('updated_at')
->take(5)
->get();
// 2. Log Status & Masa Berlaku SIMPER (Semua Driver dengan status SIMPER)
$simperLogs = Employee::where('is_operator', true)
->orderBy('simper_expired_at', 'asc')
->take(5)
->get();
// 3. Log Karyawan Non-Driver (Staf Administrasi & Teknis Lainnya)
$nonDrivers = Employee::where('is_operator', false)
->orderByDesc('updated_at')
->take(4)
->get();
return view('hse.dashboard', compact(
'totalEmployees',
'totalDrivers',
'validSimperCount',
'expiredSimperCount',
'nonDriversCount',
'recentDrivers',
'simperLogs',
'nonDrivers'
));
}
/**
* Tampilkan daftar master karyawan HSE & status SIMPER.
*/
public function index(): View
{
$employees = Employee::orderBy('name')->get();
return view('hse.employees_index', compact('employees'));
}
/**
* Simpan data karyawan baru beserta izin SIMPER (Form modal gambar 3).
*/
public function store(Request $request): RedirectResponse
{
$validated = $request->validate([
'nik' => ['required', 'string', 'max:50', 'unique:employees,nik'],
'name' => ['required', 'string', 'max:100'],
'unit_kerja' => ['required', 'string'],
'division' => ['required', 'string'],
'position' => ['required', 'string'],
'is_operator' => ['required', 'in:1,0'],
'simper_expired_at' => ['nullable', 'date'],
], [
'nik.required' => 'NIK wajib diisi.',
'nik.unique' => 'NIK sudah terdaftar dalam sistem.',
'name.required' => 'Nama karyawan wajib diisi.',
'unit_kerja.required' => 'Unit kerja wajib dipilih.',
'division.required' => 'Divisi wajib dipilih.',
'position.required' => 'Posisi / Jabatan wajib diisi.',
'is_operator.required' => 'Pilih apakah karyawan berstatus Operator / Driver.',
]);
$isOperator = (bool) $validated['is_operator'];
$simperExpiredAt = $isOperator ? ($validated['simper_expired_at'] ?? null) : null;
Employee::create([
'nik' => $validated['nik'],
'name' => $validated['name'],
'unit_kerja' => $validated['unit_kerja'],
'division' => $validated['division'],
'position' => $validated['position'],
'is_operator' => $isOperator,
'simper_expired_at' => $simperExpiredAt,
]);
return back()->with('success', "Data karyawan {$validated['name']} berhasil ditambahkan.");
}
/**
* Perpanjang atau perbarui data karyawan & SIMPER.
*/
public function update(Request $request, int $id): RedirectResponse
{
$employee = Employee::findOrFail($id);
$validated = $request->validate([
'nik' => ['sometimes', 'required', 'string', 'max:50', 'unique:employees,nik,' . $employee->id],
'name' => ['sometimes', 'required', 'string', 'max:100'],
'unit_kerja' => ['sometimes', 'required', 'string'],
'division' => ['sometimes', 'required', 'string'],
'position' => ['sometimes', 'required', 'string'],
'is_operator' => ['required', 'in:1,0'],
'simper_expired_at' => ['nullable', 'date'],
], [
'nik.unique' => 'NIK sudah digunakan oleh karyawan lain.',
'name.required' => 'Nama lengkap wajib diisi.',
'is_operator.required' => 'Status driver wajib dipilih.',
]);
$isOperator = (bool) $validated['is_operator'];
$simperExpiredAt = $isOperator ? ($validated['simper_expired_at'] ?? $employee->simper_expired_at) : null;
$employee->update([
'nik' => $validated['nik'] ?? $employee->nik,
'name' => $validated['name'] ?? $employee->name,
'unit_kerja' => $validated['unit_kerja'] ?? $employee->unit_kerja,
'division' => $validated['division'] ?? $employee->division,
'position' => $validated['position'] ?? $employee->position,
'is_operator' => $isOperator,
'simper_expired_at' => $simperExpiredAt,
]);
return back()->with('success', "Data SIMPER untuk {$employee->name} berhasil diperbarui.");
}
}
@@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers\Pg;
use App\Http\Controllers\Controller;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;
class GateInspectionController extends Controller
{
/**
* Dashboard antrean validasi di pos gerbang bersangkutan.
*/
public function index(Request $request): View
{
// Ambil gerbang yang terikat pada akun petugas pos jaga yang sedang login
$user = $request->user();
$gateId = $user ? $user->gate_id : $request->query('gate_id');
// Jika tidak ada gate_id terikat, ambil gerbang pertama sebagai fallback
$gate = $gateId ? Gate::find($gateId) : Gate::first();
$pendingActivities = collect();
if ($gate) {
$pendingActivities = VehicleActivity::where('gate_id', $gate->id)
->where('validation_status', 'pending')
->with(['vehicle', 'driver'])
->orderBy('recorded_at', 'asc')
->get();
}
// Daftar satpam aktif untuk dipilih saat verifikasi
$guards = SecurityGuard::where('is_active', true)->orderBy('name')->get();
return view('pg.gate_inspection', compact('gate', 'pendingActivities', 'guards'));
}
/**
* Setujui aktivitas kendaraan oleh Satpam di pos gerbang.
*/
public function approve(Request $request, int $id): RedirectResponse
{
$request->validate([
'security_guard_id' => ['required', 'exists:security_guards,id'],
], [
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam yang melakukan pemeriksaan.',
]);
$activity = VehicleActivity::with('vehicle')->findOrFail($id);
if ($activity->validation_status !== 'pending') {
return back()->with('error', 'Aktivitas ini sudah pernah divalidasi sebelumnya.');
}
DB::transaction(function () use ($request, $activity) {
$guardId = $request->input('security_guard_id');
// 1. Update status aktivitas menjadi approved
$activity->update([
'validation_status' => 'approved',
'security_guard_id' => $guardId,
'validated_at' => Carbon::now(),
]);
// 2. Update odometer master kendaraan
$activity->vehicle->update([
'current_km' => $activity->current_km,
]);
});
return back()->with('success', "Kendaraan {$activity->vehicle->code} berhasil disetujui untuk melintas gerbang.");
}
/**
* Tolak aktivitas kendaraan oleh Satpam.
*/
public function reject(Request $request, int $id): RedirectResponse
{
$request->validate([
'security_guard_id' => ['required', 'exists:security_guards,id'],
'rejection_note' => ['required', 'string', 'max:500'],
], [
'security_guard_id.required' => 'Silakan pilih nama petugas Satpam.',
'rejection_note.required' => 'Alasan penolakan wajib diisi.',
]);
$activity = VehicleActivity::with('vehicle')->findOrFail($id);
if ($activity->validation_status !== 'pending') {
return back()->with('error', 'Aktivitas ini sudah pernah divalidasi sebelumnya.');
}
$activity->update([
'validation_status' => 'rejected',
'security_guard_id' => $request->input('security_guard_id'),
'rejection_note' => $request->input('rejection_note'),
'validated_at' => Carbon::now(),
]);
return back()->with('success', "Aktivitas kendaraan {$activity->vehicle->code} telah ditolak.");
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\Pg;
use App\Http\Controllers\Controller;
use App\Models\SecurityGuard;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class SecurityGuardController extends Controller
{
/**
* Tampilkan daftar petugas Satpam.
*/
public function index(): View
{
$guards = SecurityGuard::orderBy('name')->get();
return view('pg.guards_index', compact('guards'));
}
/**
* Simpan data petugas Satpam baru.
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'name' => ['required', 'string', 'max:100'],
], [
'name.required' => 'Nama petugas Satpam wajib diisi.',
]);
SecurityGuard::create([
'name' => $request->input('name'),
'is_active' => true,
]);
return back()->with('success', 'Petugas Satpam berhasil ditambahkan ke dalam sistem.');
}
/**
* Ubah status aktif/nonaktif Satpam.
*/
public function toggleStatus(int $id): RedirectResponse
{
$guard = SecurityGuard::findOrFail($id);
$guard->update([
'is_active' => !$guard->is_active,
]);
$status = $guard->is_active ? 'diaktifkan' : 'dinonaktifkan';
return back()->with('success', "Status petugas Satpam ({$guard->name}) berhasil {$status}.");
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rule;
use Illuminate\View\View;
class ProfileController extends Controller
{
/**
* Tampilkan halaman profil pengguna yang sedang login.
*/
public function index(): View
{
$user = Auth::user();
return view('profile.index', compact('user'));
}
/**
* Perbarui data profil dan kata sandi pengguna.
*/
public function update(Request $request): RedirectResponse
{
/** @var \App\Models\User $user */
$user = Auth::user();
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => [
'nullable',
'string',
'email',
'max:255',
Rule::unique('users')->ignore($user->id),
],
'password' => ['nullable', 'string', 'min:6', 'confirmed'],
], [
'name.required' => 'Nama lengkap wajib diisi.',
'email.email' => 'Format email tidak valid.',
'email.unique' => 'Email ini sudah digunakan oleh akun lain.',
'password.min' => 'Kata sandi minimal terdiri dari 6 karakter.',
'password.confirmed' => 'Konfirmasi kata sandi tidak cocok.',
]);
$user->name = $validated['name'];
if (array_key_exists('email', $validated)) {
$user->email = $validated['email'] ?: $user->email;
}
if (!empty($validated['password'])) {
$user->password = Hash::make($validated['password']);
}
$user->save();
return redirect()->route('profile.index')->with('success', 'Data profil Anda berhasil diperbarui.');
}
}
@@ -0,0 +1,80 @@
<?php
namespace App\Http\Controllers\Public;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreVehicleActivityRequest;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\Vehicle;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\View\View;
class VehicleActivityFormController extends Controller
{
/**
* Tampilkan form pencatatan aktivitas kendaraan saat scan QR code.
*/
public function show(string $code): View
{
$vehicle = Vehicle::where('code', $code)
->where('category', 'light_vehicle')
->firstOrFail();
// Ambil semua driver/operator aktif
$drivers = Employee::operators()
->orderBy('name')
->get();
// Ambil daftar gerbang aktif
$gates = Gate::where('is_active', true)
->orderBy('name')
->get();
// Tentukan arah yang diperbolehkan berdasarkan riwayat terakhir
$allowedDirection = $vehicle->determineNextAllowedDirection();
return view('public.vehicle_activity_form', compact('vehicle', 'drivers', 'gates', 'allowedDirection'));
}
/**
* Simpan aktivitas kendaraan baru ke database.
*/
public function store(StoreVehicleActivityRequest $request, string $code): RedirectResponse
{
$vehicle = Vehicle::where('code', $code)
->where('category', 'light_vehicle')
->firstOrFail();
$previousKm = (float) $vehicle->current_km;
$currentKm = (float) $request->input('current_km');
$distance = max(0, $currentKm - $previousKm);
DB::transaction(function () use ($request, $vehicle, $previousKm, $currentKm, $distance) {
// Generate nomor transaksi unik
$trxNo = 'TRX-' . Carbon::now()->format('Ymd') . '-' . strtoupper(Str::random(5));
VehicleActivity::create([
'transaction_no' => $trxNo,
'vehicle_id' => $vehicle->id,
'driver_id' => $request->input('driver_id'),
'gate_id' => $request->input('gate_id'),
'direction' => $request->input('direction'),
'previous_km' => $previousKm,
'current_km' => $currentKm,
'distance' => $distance,
'purpose' => $request->input('purpose'),
'recorded_at' => Carbon::now(),
'validation_status' => 'pending',
]);
});
return redirect()
->route('vehicle.activity.form', ['code' => $code])
->with('success', 'Aktivitas kendaraan berhasil dicatat! Silakan lapor ke petugas Satpam di pos gerbang untuk verifikasi fisik.');
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller;
use App\Models\Gate;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\View\View;
class ActivityLogController extends Controller
{
/**
* Tampilkan Log Aktivitas QMA 10 Kolom lengkap dengan filter tanggal dan gate.
*/
public function index(Request $request): View
{
$query = VehicleActivity::with(['vehicle', 'driver', 'gate', 'securityGuard'])
->latest('recorded_at');
// Filter Rentang Tanggal
if ($request->filled('start_date') && $request->filled('end_date')) {
$startDate = Carbon::parse($request->input('start_date'))->startOfDay();
$endDate = Carbon::parse($request->input('end_date'))->endOfDay();
$query->whereBetween('recorded_at', [$startDate, $endDate]);
}
// Filter Gerbang
if ($request->filled('gate_id')) {
$query->where('gate_id', $request->input('gate_id'));
}
// Filter Arah Gerbang (in/out)
if ($request->filled('direction')) {
$query->where('direction', $request->input('direction'));
}
// Filter Status Validasi (pending, approved, rejected)
if ($request->filled('status')) {
$query->where('validation_status', $request->input('status'));
}
$activities = $query->paginate(20)->withQueryString();
$gates = Gate::where('is_active', true)->orderBy('name')->get();
return view('qma.activity_log', compact('activities', 'gates'));
}
}
@@ -0,0 +1,248 @@
<?php
namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller;
use App\Models\Vehicle;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\View\View;
class VehicleController extends Controller
{
/**
* Tampilkan halaman dashboard utama Admin QMA (Quality Management Asset).
*/
public function dashboard(): View
{
$totalLv = Vehicle::lightVehicles()->count();
$totalSupport = Vehicle::unitSupports()->count();
$totalVehicles = Vehicle::count();
return view('qma.dashboard', compact('totalLv', 'totalSupport', 'totalVehicles'));
}
/**
* Fallback atau redirect dari route index umum ke halaman Light Vehicle.
*/
public function index(): RedirectResponse
{
return redirect()->route('qma.vehicles.lv');
}
/**
* Halaman khusus pengelolaan armada Kendaraan Ringan (Light Vehicle / LV).
*/
public function indexLv(Request $request): View
{
$query = Vehicle::lightVehicles();
// Filter Status Operasional
if ($request->filled('status')) {
$query->where('status', $request->input('status'));
}
// Filter Pencarian Keyword LV
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$q->where('code', 'like', "%{$search}%")
->orWhere('brand_type', 'like', "%{$search}%")
->orWhere('license_plate', 'like', "%{$search}%")
->orWhere('ownership', 'like', "%{$search}%")
->orWhere('division', 'like', "%{$search}%");
});
}
$vehicles = $query->orderBy('code')->paginate(15)->withQueryString();
// Statistik Ringkasan Khusus LV
$totalLv = Vehicle::lightVehicles()->count();
$totalOperation = Vehicle::lightVehicles()->where('status', 'Operation')->count();
$totalStandby = Vehicle::lightVehicles()->where('status', 'Standby')->count();
$totalBreakdown = Vehicle::lightVehicles()->where('status', 'Breakdown')->count();
// Daftar semua kode kendaraan LV untuk validasi unik langsung di form
$existingCodes = Vehicle::lightVehicles()->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
return view('qma.vehicles_lv', compact(
'vehicles',
'totalLv',
'totalOperation',
'totalStandby',
'totalBreakdown',
'existingCodes'
));
}
/**
* Halaman khusus pengelolaan armada Kendaraan Berat (Unit Support / Alat Berat).
*/
public function indexSupport(Request $request): View
{
$query = Vehicle::unitSupports();
// Filter Status Operasional
if ($request->filled('status')) {
$query->where('status', $request->input('status'));
}
// Filter Kategori Unit Support (Excavator, Crane, Bulldozer, dll)
if ($request->filled('unit_category')) {
$query->where('unit_category', $request->input('unit_category'));
}
// Filter Pencarian Keyword Unit Support
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$q->where('code', 'like', "%{$search}%")
->orWhere('brand_type', 'like', "%{$search}%")
->orWhere('unit_category', 'like', "%{$search}%")
->orWhere('unit_type', 'like', "%{$search}%")
->orWhere('brand', 'like', "%{$search}%")
->orWhere('model_number', 'like', "%{$search}%")
->orWhere('location', 'like', "%{$search}%")
->orWhere('ownership', 'like', "%{$search}%")
->orWhere('division', 'like', "%{$search}%");
});
}
$vehicles = $query->orderBy('code')->paginate(15)->withQueryString();
// Statistik Ringkasan Khusus Unit Support
$totalSupport = Vehicle::unitSupports()->count();
$totalOperation = Vehicle::unitSupports()->where('status', 'Operation')->count();
$totalStandby = Vehicle::unitSupports()->where('status', 'Standby')->count();
$totalBreakdown = Vehicle::unitSupports()->where('status', 'Breakdown')->count();
// Daftar kategori alat berat yang terdaftar untuk opsi filter
$availableCategories = Vehicle::unitSupports()
->whereNotNull('unit_category')
->distinct()
->pluck('unit_category');
// Daftar semua kode unit support untuk validasi unik langsung di form
$existingCodes = Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
return view('qma.vehicles_support', compact(
'vehicles',
'totalSupport',
'totalOperation',
'totalStandby',
'totalBreakdown',
'availableCategories',
'existingCodes'
));
}
/**
* Simpan data aset kendaraan baru (Kendaraan Ringan atau Kendaraan Berat).
*/
public function store(Request $request): RedirectResponse
{
$category = $request->input('category', 'light_vehicle');
$rules = [
'code' => ['required', 'string', 'max:50', 'unique:vehicles,code'],
'category' => ['required', 'in:light_vehicle,unit_support'],
'brand_type' => ['required', 'string', 'max:150'],
'license_plate' => ['nullable', 'string', 'max:30'],
'ownership' => ['nullable', 'string', 'max:150'],
'division' => ['nullable', 'string', 'max:100'],
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
'current_km' => ['required', 'numeric', 'min:0'],
];
// Atribut opsional spesifik Unit Support (Kendaraan Berat)
if ($category === 'unit_support') {
$rules = array_merge($rules, [
'unit_category' => ['nullable', 'string', 'max:100'],
'unit_type' => ['nullable', 'string', 'max:100'],
'brand' => ['nullable', 'string', 'max:100'],
'model_number' => ['nullable', 'string', 'max:100'],
'production_year' => ['nullable', 'integer', 'min:1980', 'max:' . (date('Y') + 1)],
'location' => ['nullable', 'string', 'max:150'],
'fuel_consumption' => ['nullable', 'numeric', 'min:0'],
'silo_document' => ['nullable', 'string', 'max:150'],
'stnk_document' => ['nullable', 'string', 'max:150'],
'pajak_document' => ['nullable', 'string', 'max:150'],
'kir_document' => ['nullable', 'string', 'max:150'],
]);
}
$validated = $request->validate($rules, [
'code.required' => 'Kode kendaraan wajib diisi.',
'code.unique' => 'Kode sudah ada, silakan gunakan kode lain.',
'brand_type.required' => 'Merek dan spesifikasi/tipe wajib diisi.',
'current_km.required' => 'Nilai KM / HM awal wajib diisi.',
'status.required' => 'Status operasional wajib dipilih.',
]);
$vehicle = Vehicle::create($validated);
$categoryLabel = $vehicle->isLightVehicle() ? 'Light Vehicle (LV)' : 'Unit Support';
return back()->with('success', "Data {$categoryLabel} [{$vehicle->code}] berhasil ditambahkan ke sistem.");
}
/**
* Perbarui data aset kendaraan (LV atau Unit Support).
*/
public function update(Request $request, int $id): RedirectResponse
{
$vehicle = Vehicle::findOrFail($id);
$rules = [
'code' => ['required', 'string', 'max:50', Rule::unique('vehicles', 'code')->ignore($vehicle->id)],
'category' => ['required', 'in:light_vehicle,unit_support'],
'brand_type' => ['required', 'string', 'max:150'],
'license_plate' => ['nullable', 'string', 'max:30'],
'ownership' => ['nullable', 'string', 'max:150'],
'division' => ['nullable', 'string', 'max:100'],
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
'current_km' => ['required', 'numeric', 'min:0'],
'unit_category' => ['nullable', 'string', 'max:100'],
'unit_type' => ['nullable', 'string', 'max:100'],
'brand' => ['nullable', 'string', 'max:100'],
'model_number' => ['nullable', 'string', 'max:100'],
'production_year' => ['nullable', 'integer', 'min:1980', 'max:' . (date('Y') + 1)],
'location' => ['nullable', 'string', 'max:150'],
'fuel_consumption' => ['nullable', 'numeric', 'min:0'],
'silo_document' => ['nullable', 'string', 'max:150'],
'stnk_document' => ['nullable', 'string', 'max:150'],
'pajak_document' => ['nullable', 'string', 'max:150'],
'kir_document' => ['nullable', 'string', 'max:150'],
];
$validated = $request->validate($rules, [
'code.required' => 'Kode kendaraan wajib diisi.',
'code.unique' => 'Kode sudah ada, silakan gunakan kode lain.',
'brand_type.required' => 'Merek dan tipe wajib diisi.',
'current_km.required' => 'Nilai KM / HM wajib diisi.',
]);
$vehicle->update($validated);
return back()->with('success', "Data unit kendaraan [{$vehicle->code}] berhasil diperbarui.");
}
/**
* Hapus data aset kendaraan dari sistem.
*/
public function destroy(int $id): RedirectResponse
{
$vehicle = Vehicle::findOrFail($id);
// Cegah penghapusan jika unit sudah tercatat di transaksi pergerakan gerbang
if ($vehicle->activities()->exists()) {
return back()->with('error', "Unit {$vehicle->code} tidak dapat dihapus karena telah memiliki catatan riwayat pergerakan di pos gerbang.");
}
$code = $vehicle->code;
$vehicle->delete();
return back()->with('success', "Unit kendaraan {$code} berhasil dihapus dari sistem.");
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class CheckRole
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, string ...$roles): Response
{
if (!$request->user()) {
return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu untuk mengakses menu ini.');
}
$userRole = $request->user()->role;
// Role 'admin' selalu memiliki hak akses penuh
if ($userRole === 'admin' || in_array($userRole, $roles)) {
return $next($request);
}
abort(403, 'Akses Ditolak: Anda tidak memiliki izin untuk mengakses halaman ini.');
}
}
@@ -0,0 +1,103 @@
<?php
namespace App\Http\Requests;
use App\Models\Employee;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
class StoreVehicleActivityRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true; // Akses form terbuka untuk pengguna/driver via scan QR
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'driver_id' => ['required', 'exists:employees,id'],
'gate_id' => ['required', 'exists:gates,id'],
'direction' => ['required', 'in:in,out'],
'current_km' => ['required', 'numeric', 'min:0'],
'purpose' => ['required', 'string', 'max:1000'],
];
}
public function messages(): array
{
return [
'driver_id.required' => 'Silakan pilih nama pemakai/pengemudi kendaraan.',
'driver_id.exists' => 'Data pengemudi tidak ditemukan dalam sistem.',
'gate_id.required' => 'Silakan pilih lokasi pos gerbang.',
'direction.required' => 'Pilih opsi arah pergerakan gerbang (Masuk / Keluar).',
'direction.in' => 'Arah gerbang harus berupa Masuk (in) atau Keluar (out).',
'current_km.required' => 'Nilai odometer KM saat ini wajib diisi.',
'current_km.numeric' => 'Nilai odometer harus berupa angka.',
'purpose.required' => 'Rencana pekerjaan / aktivitas kendaraan wajib diisi.',
];
}
/**
* Validasi bisnis lanjutan: SIMPER kedaluwarsa, Odometer konsisten, dan Arah In/Out berpasangan.
*/
public function withValidator(Validator $validator): void
{
$validator->after(function ($validator) {
$vehicleCode = $this->route('code');
$vehicle = Vehicle::where('code', $vehicleCode)
->where('category', 'light_vehicle')
->first();
if (!$vehicle) {
$validator->errors()->add('vehicle', 'Kendaraan ringan tidak valid atau tidak terdaftar.');
return;
}
// 1. Validasi SIMPER Pengemudi (BR-01 & BR-02)
$driver = Employee::find($this->input('driver_id'));
if ($driver) {
if (!$driver->hasValidSimper()) {
$expiredText = $driver->simper_expired_at ? $driver->simper_expired_at->format('d/m/Y') : 'Belum Terdaftar';
$validator->errors()->add(
'driver_id',
"Masa berlaku SIMPER pengemudi ({$driver->name}) telah kedaluwarsa pada {$expiredText}. Karyawan wajib memperpanjang SIMPER ke Divisi HSE sebelum mengoperasikan kendaraan."
);
}
}
// 2. Validasi Konsistensi Odometer Maju (BR-03)
$previousKm = (float) $vehicle->current_km;
$currentKm = (float) $this->input('current_km');
if ($currentKm < $previousKm) {
$validator->errors()->add(
'current_km',
"Nilai kilometer input ({$currentKm} KM) tidak boleh lebih kecil dari kilometer sebelumnya ({$previousKm} KM)."
);
}
// 3. Validasi Urutan Arah Gerbang Berpasangan (BR-04 & BR-05)
$allowedDirection = $vehicle->determineNextAllowedDirection();
$inputDirection = $this->input('direction');
if ($allowedDirection !== 'ANY' && $inputDirection !== $allowedDirection) {
$expectedText = ($allowedDirection === 'in') ? 'MASUK (In)' : 'KELUAR (Out)';
$validator->errors()->add(
'direction',
"Arah pergerakan tidak sesuai riwayat terakhir. Kendaraan ini harus tercatat {$expectedText} terlebih dahulu."
);
}
});
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Employee extends Model
{
use HasFactory;
protected $fillable = [
'nik',
'name',
'unit_kerja',
'division',
'position',
'is_operator',
'simper_expired_at',
'photo_path',
];
protected $casts = [
'is_operator' => 'boolean',
'simper_expired_at' => 'date',
];
/**
* Cek apakah SIMPER masih aktif hari ini.
*/
public function hasValidSimper(): bool
{
if (!$this->simper_expired_at) {
return false;
}
return $this->simper_expired_at->isFuture() || $this->simper_expired_at->isToday();
}
/**
* Scope untuk mengambil hanya karyawan yang berstatus operator/driver.
*/
public function scopeOperators(Builder $query): Builder
{
return $query->where('is_operator', true);
}
public function activities(): HasMany
{
return $this->hasMany(VehicleActivity::class, 'driver_id');
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Gate extends Model
{
use HasFactory;
protected $fillable = [
'code',
'name',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
];
public function users(): HasMany
{
return $this->hasMany(User::class);
}
public function activities(): HasMany
{
return $this->hasMany(VehicleActivity::class);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class SecurityGuard extends Model
{
use HasFactory;
protected $fillable = [
'name',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
];
public function activities(): HasMany
{
return $this->hasMany(VehicleActivity::class);
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'username',
'email',
'password',
'role',
'gate_id',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function gate(): BelongsTo
{
return $this->belongsTo(Gate::class);
}
public function isGateOfficer(): bool
{
return $this->role === 'gate_officer';
}
public function isHseAdmin(): bool
{
return $this->role === 'hse_admin';
}
public function isQmaAdmin(): bool
{
return $this->role === 'qma_admin';
}
public function isPgAdmin(): bool
{
return $this->role === 'pg_admin';
}
public function isAdmin(): bool
{
return $this->role === 'admin';
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Vehicle extends Model
{
use HasFactory;
protected $fillable = [
'code',
'category',
'brand_type',
'license_plate',
'ownership',
'division',
'status',
'current_km',
'photo_path',
'unit_category',
'unit_type',
'brand',
'model_number',
'production_year',
'location',
'fuel_consumption',
'silo_document',
'stnk_document',
'pajak_document',
'kir_document',
];
protected $casts = [
'current_km' => 'decimal:2',
'fuel_consumption' => 'decimal:2',
'production_year' => 'integer',
];
public function isLightVehicle(): bool
{
return $this->category === 'light_vehicle';
}
public function isUnitSupport(): bool
{
return $this->category === 'unit_support';
}
public function scopeLightVehicles(Builder $query): Builder
{
return $query->where('category', 'light_vehicle');
}
public function scopeUnitSupports(Builder $query): Builder
{
return $query->where('category', 'unit_support');
}
public function activities(): HasMany
{
return $this->hasMany(VehicleActivity::class);
}
/**
* Aktivitas gerbang terakhir dari kendaraan ini.
*/
public function latestActivity(): HasOne
{
return $this->hasOne(VehicleActivity::class)->latestOfMany('recorded_at');
}
/**
* Tentukan arah gerbang berikutnya yang sah:
* - 'ANY' jika belum pernah ada riwayat (kendaraan baru)
* - 'in' jika aktivitas terakhir adalah 'out'
* - 'out' jika aktivitas terakhir adalah 'in'
*/
public function determineNextAllowedDirection(): string
{
$last = $this->latestActivity;
if (!$last) {
return 'ANY';
}
return ($last->direction === 'out') ? 'in' : 'out';
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class VehicleActivity extends Model
{
use HasFactory;
protected $fillable = [
'transaction_no',
'vehicle_id',
'driver_id',
'gate_id',
'direction',
'previous_km',
'current_km',
'distance',
'purpose',
'recorded_at',
'security_guard_id',
'validation_status',
'rejection_note',
'validated_at',
];
protected $casts = [
'previous_km' => 'decimal:2',
'current_km' => 'decimal:2',
'distance' => 'decimal:2',
'recorded_at' => 'datetime',
'validated_at' => 'datetime',
];
public function vehicle(): BelongsTo
{
return $this->belongsTo(Vehicle::class);
}
public function driver(): BelongsTo
{
return $this->belongsTo(Employee::class, 'driver_id');
}
public function gate(): BelongsTo
{
return $this->belongsTo(Gate::class);
}
public function securityGuard(): BelongsTo
{
return $this->belongsTo(SecurityGuard::class, 'security_guard_id');
}
public function scopePending(Builder $query): Builder
{
return $query->where('validation_status', 'pending');
}
public function scopeApproved(Builder $query): Builder
{
return $query->where('validation_status', 'approved');
}
public function scopeForGate(Builder $query, int $gateId): Builder
{
return $query->where('gate_id', $gateId);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput);
exit($status);
+20
View File
@@ -0,0 +1,20 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->alias([
'role' => \App\Http\Middleware\CheckRole::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+7
View File
@@ -0,0 +1,7 @@
<?php
use App\Providers\AppServiceProvider;
return [
AppServiceProvider::class,
];
@@ -0,0 +1,301 @@
# Brainstorming dan Analisis Sistem RKM untuk Migrasi ke Laravel
## 1. Konteks Proyek
Saya mendapatkan tugas untuk melakukan revisi dan pengembangan ulang terhadap sistem bernama **RKM**, yang akan dimigrasikan ke framework Laravel.
Sebelum memulai migrasi, saya ingin membedah sistem yang sudah ada untuk memahami struktur aplikasi, fungsi setiap modul, relasi antar-data, serta kesesuaiannya dengan kebutuhan bisnis yang baru.
Saya akan memberikan foto, file, dan/atau source code dari sistem lama sebagai bahan analisis.
Fokus utama tahap ini adalah mengevaluasi sistem lama dan menentukan komponen yang perlu dipertahankan, diperbaiki, disederhanakan, atau dihapus. Jangan langsung mengimplementasikan kode Laravel sebelum analisis dan rancangan sistem disepakati.
## 2. Gambaran Umum Sistem RKM
Sistem RKM dirancang untuk mendukung pengelolaan data kendaraan dan pencatatan aktivitas kendaraan perusahaan.
Komponen utama yang menjadi acuan awal adalah:
1. **Master Data HSE**: Mengelola data karyawan yang memiliki SIMPER.
2. **Master Data QMA**: Mengelola data kendaraan ringan perusahaan.
3. **Form Aktivitas Kendaraan**: Digunakan pengguna untuk mencatat aktivitas kendaraan melalui pemindaian QR Code.
4. **Dashboard dan Log Aktivitas QMA**: Digunakan QMA untuk memantau catatan aktivitas kendaraan.
5. **Modul Private Guard (PG)**: Digunakan petugas keamanan untuk memvalidasi aktivitas kendaraan.
Struktur tersebut merupakan gambaran kebutuhan awal dan perlu dicocokkan dengan implementasi sistem lama.
## 3. Master Data HSE
HSE bertanggung jawab mengelola data karyawan yang memiliki SIMPER (Surat Izin Mengemudi Perusahaan).
Atribut data karyawan meliputi:
- NIK
- Nama
- Unit Kerja:
- Pembangkit
- Bendungan
- Teknik
- Umum
- Divisi:
- Audit
- Bendungan (Operasional)
- Bendungan (Operator)
- Civil & Inviro
- Civil Enviro
- Enviro
- GA
- Geomonitoring
- HR
- INFORMATION & TECHNOLOGY
- Inspeksi & Monitoring
- Jaringan 20 Kv & Genset
- K3
- Keuangan
- Logistik
- Manajemen
- Mechanical
- Paramedis
- Pembangkit (Engineering)
- Pembangkit (Operasional)
- Pembangkit (Pemeliharaan)
- Perencanaan Teknik
- PG
- POSO
- Public Relation & CSR
- Quality Management Asset (QMA)
- Regulating Weir
- Sipil
- Sipil & Enviro
- Sipil & Lingkungan
- SUBCON
- Survey
- Posisi/Jabatan
- Operator/Driver
- Masa Berlaku SIMPER
Data karyawan ini menjadi referensi untuk mengidentifikasi pemakai kendaraan ketika aktivitas kendaraan dicatat.
Analisis juga harus mempertimbangkan bagaimana sistem menangani SIMPER yang kedaluwarsa atau data karyawan yang sudah tidak aktif, tanpa menetapkan aturan baru sebelum kebutuhan bisnisnya dikonfirmasi.
## 4. Master Data QMA
QMA (Quality Management Asset) merupakan divisi yang bertanggung jawab atas pengelolaan aset kendaraan dalam sistem RKM.
Pada pengembangan sistem ini, **QMA hanya mengelola kategori Kendaraan Ringan (Light Vehicle/LV)**. Kategori Kendaraan Berat (Unit Support) tidak digunakan dalam modul QMA dan tidak perlu dimasukkan ke dalam rancangan maupun migrasi modul ini.
Setiap kendaraan ringan memiliki atribut:
- LVCode
- LVBrandType
- Ownership
- Divisi
- Status
- Nopol
- HM/KM
Master data kendaraan ini menjadi referensi utama untuk proses pencatatan aktivitas kendaraan melalui QR Code dan penyajian data pada Dashboard serta Log Aktivitas QMA.
Dalam analisis sistem lama, identifikasi seluruh tabel, fitur, relasi, dan kode yang berkaitan dengan pengelolaan kendaraan berat. Tentukan apakah komponen tersebut dapat dikeluarkan dari ruang lingkup QMA tanpa mengganggu fungsi lain yang masih dibutuhkan. Jangan menghapus komponen dari sistem lama secara otomatis sebelum dependensinya diperiksa. Fokuskan rancangan sistem baru pada pengelolaan Kendaraan Ringan (LV).
## 5. Alur Pencatatan Aktivitas Kendaraan
Alur bisnis awal yang menjadi acuan adalah:
1. Pengguna membawa kendaraan yang telah terdaftar di sistem.
2. Pengguna memindai QR Code identitas kendaraan yang ditempelkan pada kendaraan.
3. Sistem mengidentifikasi kendaraan dan menyediakan form pencatatan aktivitas.
4. Pengguna mengisi data yang diperlukan, termasuk nama pemakai, gate, jenis aktivitas In/Out, HM/KM, dan rencana kerja.
5. Sistem menyimpan catatan aktivitas kendaraan.
6. Catatan tersebut ditampilkan pada log aktivitas di dashboard QMA.
7. Aktivitas kemudian masuk ke proses validasi oleh modul PG.
Detail validasi oleh PG, hubungan antara petugas dan gate, serta alur persetujuan atau penolakan akan dibahas pada tahap berikutnya.
## 6. Form Input Aktivitas Kendaraan
Form ini diakses melalui pemindaian QR Code identitas kendaraan.
Data yang diinputkan pengguna meliputi:
### A. Identitas Pemakai
Nama pemakai unit diambil dari master data HSE. Hubungan data harus menggunakan identitas karyawan yang konsisten, bukan hanya mengandalkan teks nama.
### B. Gate/Gerbang
Pilihan gate yang tersedia:
- Adit 1
- Adit 2
- Adit 3
- Bedeng 6
- Beringin Tunggal
- CCR DAM
- Crest DAM
- Dermaga Jakon
- Gudang Induk
- Lainnya
- Mess Kumun
- PH - Office
- PH - Utama
- Regulating Weir
- Vertical Shaft
- VS - TPST
### C. Jenis Aktivitas
- In
- Out
### D. HM/KM
Nilai Hour Meter atau Kilometer kendaraan pada saat aktivitas dicatat.
### E. Rencana Kerja
Keterangan mengenai rencana atau tujuan penggunaan kendaraan.
Identitas kendaraan sebaiknya diperoleh dari QR Code yang dipindai. Analisis perlu menentukan bagaimana data kendaraan tersebut dihubungkan dengan master data QMA dan bagaimana sistem mencegah pencatatan untuk kendaraan yang tidak terdaftar.
## 7. Dashboard dan Log Aktivitas QMA
Berdasarkan tampilan tabel yang diberikan, **Log Aktivitas QMA memiliki 10 kolom utama** dengan susunan sebagai berikut:
| No. | Kolom | Fungsi awal |
|---|---|---|
| 1 | Tanggal | Menampilkan tanggal aktivitas kendaraan. |
| 2 | Kode LV | Menampilkan kode identitas kendaraan ringan. |
| 3 | Unit | Menampilkan unit atau informasi unit kendaraan sesuai definisi pada sistem lama. |
| 4 | Penanggung Jawab | Menampilkan pihak yang bertanggung jawab atas kendaraan atau aktivitas. |
| 5 | Driver | Menampilkan nama pengemudi kendaraan. |
| 6 | Gate | Menampilkan lokasi gerbang tempat aktivitas dicatat. |
| 7 | Akses | Menampilkan informasi akses kendaraan sesuai definisi bisnis sistem lama. |
| 8 | KM Sebelumnya | Menampilkan nilai kilometer sebelumnya sebagai referensi perjalanan atau pencatatan terdahulu. |
| 9 | KM Berjalan | Menampilkan nilai kilometer pada aktivitas saat ini, sesuai definisi sistem lama. |
| 10 | Aktifitas | Menampilkan informasi aktivitas kendaraan. |
**Catatan:** Fungsi di atas merupakan interpretasi awal berdasarkan nama kolom pada gambar. Definisi pasti untuk kolom Unit, Penanggung Jawab, Akses, KM Sebelumnya, KM Berjalan, dan Aktifitas harus diverifikasi melalui sistem lama, source code, atau penjelasan proses bisnis.
### A. Hubungan Log dengan Master Data
Analisis harus menentukan asal data untuk setiap kolom.
- **Kode LV**: Seharusnya mengacu pada identitas kendaraan dalam master data QMA.
- **Unit**: Perlu dipastikan apakah merujuk pada kategori kendaraan, unit kerja, atau atribut lain.
- **Penanggung Jawab**: Perlu dipastikan apakah merupakan pemilik aset, penanggung jawab kendaraan, atau penanggung jawab aktivitas.
- **Driver**: Perlu dipetakan ke data karyawan HSE atau sumber data pengemudi yang digunakan sistem lama.
- **Gate**: Mengacu pada data atau daftar lokasi gerbang.
- **Akses**: Perlu dikonfirmasi apakah menunjukkan status atau jenis akses tertentu.
- **KM Sebelumnya**: Perlu ditentukan sumber nilai sebelumnya dan aturan pengambilannya.
- **KM Berjalan**: Perlu dipastikan apakah berasal dari input pengguna, hasil perhitungan, atau data lain.
- **Aktifitas**: Perlu dipastikan apakah menunjukkan In/Out, rencana kerja, status validasi, atau gabungan informasi aktivitas lainnya.
- **Tanggal**: Perlu dipastikan apakah menampilkan tanggal pencatatan, tanggal aktivitas, atau tanggal data divalidasi.
Jangan langsung membuat kolom baru atau mengubah arti kolom yang sudah ada sebelum fungsi bisnisnya dipastikan.
### B. Perilaku Tabel
Pada gambar, beberapa judul kolom menampilkan ikon pengurutan. Karena itu, periksa apakah tabel mendukung:
- Pengurutan data berdasarkan kolom.
- Pengurutan berdasarkan tanggal atau urutan aktivitas.
- Pencarian dan filter data, jika tersedia atau dibutuhkan.
- Penampilan data aktivitas terbaru dan riwayat aktivitas.
- Pembatasan akses data berdasarkan peran pengguna, jika diperlukan.
Periksa pula apakah data ditampilkan melalui tabel statis, pemrosesan backend, atau mekanisme lain. Jangan mengasumsikan bahwa semua fungsi tersebut sudah tersedia hanya berdasarkan tampilan visual.
### C. Konsistensi Data Kilometer
Salah satu fokus analisis adalah hubungan antara KM Sebelumnya dan KM Berjalan.
Pastikan apakah:
1. KM Sebelumnya diambil dari aktivitas kendaraan terakhir.
2. KM Berjalan merupakan nilai odometer saat aktivitas dicatat.
3. Selisih keduanya digunakan untuk menghitung jarak perjalanan.
4. Data kilometer disimpan pada setiap transaksi atau diperbarui langsung pada master kendaraan.
5. Sistem juga mendukung kendaraan yang menggunakan Hour Meter (HM), bukan odometer kilometer.
Jangan menetapkan rumus atau aturan validasi final sebelum mekanisme yang digunakan sistem lama dan kebutuhan bisnis dikonfirmasi.
## 8. Analisis Sistem Lama
Setelah menerima foto, file, dan source code, lakukan analisis dengan tahapan berikut.
### A. Pemetaan Modul dan Fitur
Identifikasi seluruh modul, halaman, fitur, tabel basis data, relasi, dan alur yang ada.
Kelompokkan komponen menjadi:
- **Dipertahankan**: Masih relevan dengan kebutuhan RKM.
- **Diperbaiki**: Fungsinya masih dibutuhkan tetapi implementasinya perlu diperbarui.
- **Disederhanakan**: Fitur atau struktur yang berlebihan dan dapat diringkas.
- **Dihapus**: Tidak memiliki relevansi dengan kebutuhan baru dan tidak menjadi dependensi fitur lain.
Setiap rekomendasi harus disertai alasan yang jelas.
### B. Pemetaan Struktur Data
Periksa:
- Data master karyawan HSE.
- Data master kendaraan ringan QMA.
- Data aktivitas kendaraan.
- Data referensi gate.
- Data kilometer atau hour meter.
- Relasi antara kendaraan, karyawan, dan aktivitas.
- Sumber data setiap kolom pada Log Aktivitas QMA.
- Data yang duplikat, tidak terpakai, atau masih dibutuhkan modul lain.
Bedakan antara master data, data transaksi, data referensi, dan data hasil perhitungan.
### C. Analisis Kesesuaian dengan Laravel
Setelah struktur sistem lama dipahami, berikan rancangan konseptual yang mencakup:
- Pembagian modul aplikasi.
- Entitas dan relasi basis data.
- Pemisahan master data dan transaksi aktivitas.
- Sumber data yang digunakan untuk mengisi setiap kolom log.
- Alur penyimpanan dan pengambilan data aktivitas.
- Kebutuhan refactoring dan migrasi dari sistem lama.
Pada tahap ini, jangan membuat migration, model, controller, atau kode implementasi Laravel sebelum desain disepakati.
## 9. Batasan Pembahasan Tahap Pertama
Jangan mendalami mekanisme validasi Private Guard (PG), alur persetujuan aktivitas, maupun hubungan operasional petugas dengan gate.
Untuk saat ini, fokuskan analisis pada:
1. Struktur dan fungsi sistem lama.
2. Master data HSE dan QMA.
3. Proses pencatatan aktivitas kendaraan.
4. Struktur serta sumber data Log Aktivitas QMA.
5. Relasi data dan kesesuaian sistem untuk dimigrasikan ke Laravel.
6. Identifikasi komponen yang perlu dipertahankan, diperbaiki, disederhanakan, atau dihapus.
## 10. Hasil Analisis yang Diharapkan
Susun hasil analisis secara bertahap dengan keluaran berikut:
1. **Ringkasan sistem lama**: Modul, fitur, dan struktur yang ditemukan.
2. **Pemetaan fitur**: Fungsi, relevansi, dependensi, dan rekomendasi tindakan.
3. **Pemetaan Log Aktivitas QMA**: Kesepuluh kolom, definisi bisnis, sumber data, relasi, serta status verifikasi.
4. **Pemetaan struktur data**: Entitas, atribut, relasi, dan kebutuhan perubahan.
5. **Analisis kesenjangan**: Perbedaan antara sistem lama dan kebutuhan RKM.
6. **Rancangan konseptual sistem baru**: Pembagian modul dan relasi data untuk Laravel.
7. **Daftar pertanyaan terbuka**: Informasi yang belum cukup untuk menetapkan desain final.
Jika informasi belum tersedia, nyatakan sebagai belum diketahui. Jangan mengarang fungsi kolom, relasi, atau aturan bisnis.
## 11. Cara Kerja Diskusi
Lakukan brainstorming secara bertahap dan kolaboratif. Periksa materi yang saya berikan, jelaskan temuan berdasarkan bukti yang tersedia, kemudian berikan rekomendasi dan alasan sebelum berpindah ke tahap berikutnya.
Jangan langsung menyimpulkan seluruh arsitektur atau membuat kode. Setiap keputusan mengenai struktur data dan penghapusan fitur harus mempertimbangkan dampaknya terhadap keseluruhan sistem.
**Tugas pertama:** Analisis sistem lama berdasarkan materi yang saya unggah. Petakan komponen yang relevan dengan kebutuhan RKM, lalu telusuri struktur Log Aktivitas QMA beserta sumber data dan relasinya sebelum kita membahas modul Private Guard (PG).
+86
View File
@@ -0,0 +1,86 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.50"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
Generated
+8404
View File
File diff suppressed because it is too large Load Diff
+126
View File
@@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];
+117
View File
@@ -0,0 +1,117 @@
<?php
use App\Models\User;
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the number of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];
+117
View File
@@ -0,0 +1,117 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "array", "database", "file", "memcached",
| "redis", "dynamodb", "octane",
| "failover", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
'table' => env('DB_CACHE_TABLE', 'cache'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
];
+184
View File
@@ -0,0 +1,184 @@
<?php
use Illuminate\Support\Str;
use Pdo\Mysql;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => env('DB_SSLMODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];
+80
View File
@@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'serve' => true,
'throw' => false,
'report' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
+132
View File
@@ -0,0 +1,132 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'handler_with' => [
'stream' => 'php://stderr',
],
'formatter' => env('LOG_STDERR_FORMATTER'),
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];
+118
View File
@@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "resend", "log", "array",
| "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
],
'resend' => [
'transport' => 'resend',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
'retry_after' => 60,
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
'retry_after' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails sent by your application to be sent from
| the same address. Here you may specify a name and address that is
| used globally for all emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
],
];
+129
View File
@@ -0,0 +1,129 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "background", "failover", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];
+38
View File
@@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'postmark' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];
+217
View File
@@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "memcached",
| "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain without subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,49 @@
<?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::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?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::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?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::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,30 @@
<?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::create('gates', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique();
$table->string('name', 100);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('gates');
}
};
@@ -0,0 +1,31 @@
<?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('users', function (Blueprint $table) {
$table->string('username', 50)->nullable()->unique()->after('name');
$table->string('role', 30)->default('gate_officer')->after('email');
$table->foreignId('gate_id')->nullable()->constrained('gates')->nullOnDelete()->after('role');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['gate_id']);
$table->dropColumn(['username', 'role', 'gate_id']);
});
}
};
@@ -0,0 +1,35 @@
<?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::create('employees', function (Blueprint $table) {
$table->id();
$table->string('nik', 50)->unique();
$table->string('name', 100);
$table->string('unit_kerja', 100)->nullable(); // Pembangkit, Bendungan, Teknik, Umum
$table->string('division', 100)->nullable();
$table->string('position', 100)->nullable();
$table->boolean('is_operator')->default(false);
$table->date('simper_expired_at')->nullable();
$table->string('photo_path')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('employees');
}
};
@@ -0,0 +1,50 @@
<?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::create('vehicles', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique(); // LVCode / UnitCode
$table->string('category', 30)->default('light_vehicle'); // 'light_vehicle', 'unit_support'
$table->string('brand_type', 150); // MITSUBISHI - L300 - PICK UP
$table->string('license_plate', 30)->nullable(); // Nopol
$table->string('ownership', 150)->nullable(); // Teks bebas pemilik aset
$table->string('division', 100)->nullable();
$table->string('status', 50)->default('Operation'); // Operation, Standby, Breakdown
$table->decimal('current_km', 12, 2)->default(0); // Odometer KM terstandarisasi
$table->string('photo_path')->nullable();
// Atribut spesifik Kendaraan Berat (Unit Support) - nullable
$table->string('unit_category', 100)->nullable(); // Excavator, Crane, dll
$table->string('unit_type', 100)->nullable();
$table->string('brand', 100)->nullable();
$table->string('model_number', 100)->nullable();
$table->smallInteger('production_year')->nullable();
$table->string('location', 150)->nullable();
$table->decimal('fuel_consumption', 8, 2)->nullable();
$table->string('silo_document', 150)->nullable();
$table->string('stnk_document', 150)->nullable();
$table->string('pajak_document', 150)->nullable();
$table->string('kir_document', 150)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vehicles');
}
};
@@ -0,0 +1,29 @@
<?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::create('security_guards', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('security_guards');
}
};
@@ -0,0 +1,45 @@
<?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::create('vehicle_activities', function (Blueprint $table) {
$table->id();
$table->string('transaction_no', 60)->unique();
$table->foreignId('vehicle_id')->constrained('vehicles')->cascadeOnDelete();
$table->foreignId('driver_id')->constrained('employees')->cascadeOnDelete();
$table->foreignId('gate_id')->constrained('gates')->cascadeOnDelete();
$table->string('direction', 10); // 'in', 'out'
$table->decimal('previous_km', 12, 2);
$table->decimal('current_km', 12, 2);
$table->decimal('distance', 12, 2); // current_km - previous_km
$table->text('purpose');
$table->timestamp('recorded_at');
$table->foreignId('security_guard_id')->nullable()->constrained('security_guards')->nullOnDelete();
$table->string('validation_status', 20)->default('pending'); // 'pending', 'approved', 'rejected'
$table->text('rejection_note')->nullable();
$table->timestamp('validated_at')->nullable();
$table->timestamps();
// Indexes untuk percepatan performa filter log & antrean gerbang
$table->index(['gate_id', 'validation_status']);
$table->index(['vehicle_id', 'recorded_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vehicle_activities');
}
};
+253
View File
@@ -0,0 +1,253 @@
<?php
namespace Database\Seeders;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\User;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// 1. Seed Master Gates (Pos Gerbang Proyek PLTA Merangin)
$gateList = [
['code' => 'ADIT1', 'name' => 'Adit 1'],
['code' => 'ADIT2', 'name' => 'Adit 2'],
['code' => 'ADIT3', 'name' => 'Adit 3'],
['code' => 'BDG6', 'name' => 'Bedeng 6'],
['code' => 'BTUNGGAL', 'name' => 'Beringin Tunggal'],
['code' => 'CCRDAM', 'name' => 'CCR DAM'],
['code' => 'CRESTDAM', 'name' => 'Crest DAM'],
['code' => 'JAKON', 'name' => 'Dermaga Jakon'],
['code' => 'GUDANG', 'name' => 'Gudang Induk'],
['code' => 'KUMUN', 'name' => 'Mess Kumun'],
['code' => 'PHOFFICE', 'name' => 'PH - Office'],
['code' => 'PHUTAMA', 'name' => 'PH - Utama'],
['code' => 'REGWEIR', 'name' => 'Regulating Weir'],
['code' => 'VSHAFT', 'name' => 'Vertical Shaft'],
['code' => 'VSTPST', 'name' => 'VS - TPST'],
];
$createdGates = [];
foreach ($gateList as $g) {
$createdGates[$g['code']] = Gate::create([
'code' => $g['code'],
'name' => $g['name'],
'is_active' => true,
]);
}
// 2. Seed Master Security Guards (Satpam PG)
$guards = [
['name' => 'Ahmad Fauzi', 'is_active' => true],
['name' => 'Budi Santoso', 'is_active' => true],
['name' => 'Hendra Pratama', 'is_active' => true],
['name' => 'Rusli Efendi', 'is_active' => true],
['name' => 'Slamet Widodo', 'is_active' => true],
];
foreach ($guards as $guard) {
SecurityGuard::create($guard);
}
// 3. Seed Users (Admin & Shared Gate Accounts)
// Admin HSE [Nama : Mima, Username : 1185, Password : password]
User::create([
'name' => 'Mima',
'username' => '1185',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'hse_admin',
]);
// Admin QMA [Nama : Pinto Yuliandra, Username : 1171, Password : password]
User::create([
'name' => 'Pinto Yuliandra',
'username' => '1171',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'qma_admin',
]);
// Admin PG [Nama : Admin PG, Username : AdminPG, Password : password]
User::create([
'name' => 'Admin PG',
'username' => 'AdminPG',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'pg_admin',
]);
// Shared Gate Accounts (Akun Pos Gerbang)
User::create([
'name' => 'Pos Gerbang Beringin Tunggal',
'username' => 'pos.beringin',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['BTUNGGAL']->id,
]);
User::create([
'name' => 'Pos Gerbang Adit 1',
'username' => 'pos.adit1',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['ADIT1']->id,
]);
User::create([
'name' => 'Pos Gerbang Regulating Weir',
'username' => 'pos.regweir',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['REGWEIR']->id,
]);
// 4. Seed Employees (Master Data HSE: Driver dengan SIMPER Valid dan Expired)
Employee::create([
'nik' => 'KMH-2022-001',
'name' => 'Eka Sufiatna',
'unit_kerja' => 'Teknik',
'division' => 'INFORMATION & TECHNOLOGY',
'position' => 'IT Division Coordinator',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(8), // SIMPER AKTIF
]);
Employee::create([
'nik' => 'KMH-2022-045',
'name' => 'Wanturi',
'unit_kerja' => 'Umum',
'division' => 'GA',
'position' => 'Driver Operasional',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(4), // SIMPER AKTIF
]);
Employee::create([
'nik' => 'KMH-2023-012',
'name' => 'Randi Kurniawan',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Operator Lapangan',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->subDays(14), // SIMPER KEDALUWARSA (Untuk Test Validasi)
]);
Employee::create([
'nik' => 'KMH-2021-088',
'name' => 'Siti Rahma',
'unit_kerja' => 'Umum',
'division' => 'Keuangan',
'position' => 'Staff Finance',
'is_operator' => false, // BUKAN DRIVER
'simper_expired_at' => null,
]);
// 5. Seed Vehicles (Master Data QMA: Kendaraan Ringan / LV)
Vehicle::create([
'code' => 'LV62',
'category' => 'light_vehicle',
'brand_type' => 'MITSUBISHI - L300 - PICK UP',
'license_plate' => 'BH 8893 DI',
'ownership' => 'EKA SUFIATNA',
'division' => 'IT',
'status' => 'Operation',
'current_km' => 12500.00,
]);
Vehicle::create([
'code' => 'LV01',
'category' => 'light_vehicle',
'brand_type' => 'TOYOTA HILUX 4X4 DC',
'license_plate' => 'BH 1024 AB',
'ownership' => 'PT Kerinci Merangin Hidro',
'division' => 'HSE',
'status' => 'Operation',
'current_km' => 45200.00,
]);
Vehicle::create([
'code' => 'LV15',
'category' => 'light_vehicle',
'brand_type' => 'ISUZU D-MAX 4X4',
'license_plate' => 'BH 9012 CD',
'ownership' => 'Divisi Bendungan',
'division' => 'Bendungan',
'status' => 'Standby',
'current_km' => 28350.00,
]);
// 6. Seed Vehicles (Master Data QMA: Kendaraan Berat / Unit Support - HANYA Pencatatan Data)
Vehicle::create([
'code' => 'EX01',
'category' => 'unit_support',
'brand_type' => 'KOMATSU PC200-8',
'unit_category' => 'Excavator',
'unit_type' => 'Hydraulic Excavator',
'brand' => 'Komatsu',
'model_number' => 'PC200-8M0',
'production_year' => 2021,
'ownership' => 'PT KMH - Project',
'division' => 'Civil & Inviro',
'location' => 'Beringin Tunggal / Tunnel #2',
'status' => 'Operation',
'current_km' => 3450.00,
'fuel_consumption' => 18.50,
'silo_document' => 'SILO-KMH-2024/091',
'stnk_document' => 'STNK-BH-EX01',
'pajak_document' => 'PAJAK-2026/12',
'kir_document' => 'KIR-2026/08',
]);
Vehicle::create([
'code' => 'CR01',
'category' => 'unit_support',
'brand_type' => 'KATO SR-250R',
'unit_category' => 'Mobile Crane',
'unit_type' => 'Rough Terrain Crane 25T',
'brand' => 'Kato',
'model_number' => 'SR-250R',
'production_year' => 2019,
'ownership' => 'PT Kerinci Merangin Hidro',
'division' => 'Mechanical',
'location' => 'CCR DAM / Spillway',
'status' => 'Operation',
'current_km' => 1820.00,
'fuel_consumption' => 14.20,
'silo_document' => 'SILO-KMH-2025/112',
'kir_document' => 'KIR-2026/10',
]);
Vehicle::create([
'code' => 'DT02',
'category' => 'unit_support',
'brand_type' => 'MITSUBISHI FUSO FIGHTER FN62F',
'license_plate' => 'BH 8412 AA',
'unit_category' => 'Dump Truck',
'unit_type' => 'Dump Truck 20 Ton',
'brand' => 'Mitsubishi Fuso',
'model_number' => 'FN62F HD',
'production_year' => 2022,
'ownership' => 'PT KMH - Project',
'division' => 'Civil & Inviro',
'location' => 'Quarry & Disposal Area',
'status' => 'Standby',
'current_km' => 14800.00,
'fuel_consumption' => 28.00,
'stnk_document' => 'STNK-BH-8412-AA',
'kir_document' => 'KIR-2026/11',
]);
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"$schema": "https://www.schemastore.org/package.json",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"tailwindcss": "^4.0.0",
"vite": "^7.0.7"
}
}
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="BROADCAST_CONNECTION" value="null"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_URL" value=""/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="NIGHTWATCH_ENABLED" value="false"/>
</php>
</phpunit>
+25
View File
@@ -0,0 +1,25 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+20
View File
@@ -0,0 +1,20 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->handleRequest(Request::capture());
+2
View File
@@ -0,0 +1,2 @@
User-agent: *
Disallow:
+11
View File
@@ -0,0 +1,11 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
@theme {
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
}
+1
View File
@@ -0,0 +1 @@
import './bootstrap';
+4
View File
@@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
+260
View File
@@ -0,0 +1,260 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Masuk ke Sistem RKM - PT Kerinci Merangin Hidro</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400&display=swap" rel="stylesheet">
<style>
* { font-family: 'Inter', sans-serif; }
/* Panel kiri: pola garis diagonal halus di atas gradasi */
.brand-panel {
background: linear-gradient(160deg, #1a3a1a 0%, #1b5e20 60%, #256127 100%);
position: relative;
overflow: hidden;
}
/* Pola grid titik-titik elegan di background */
.brand-panel::before {
content: '';
position: absolute;
inset: 0;
background-image: radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px);
background-size: 28px 28px;
}
/* Cahaya sorot lembut dari tengah atas */
.brand-panel::after {
content: '';
position: absolute;
top: -80px;
left: 50%;
transform: translateX(-50%);
width: 320px;
height: 320px;
background: radial-gradient(circle, rgba(255,255,255,0.09) 0%, transparent 70%);
pointer-events: none;
}
/* Input focus state */
.form-input {
border: 1.5px solid #e2e8f0;
background: #f9fafb;
transition: all 0.18s ease;
}
.form-input:focus {
outline: none;
border-color: #1b5e20;
background: #fff;
box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.1);
}
/* Tombol login */
.btn-login {
background: #1b5e20;
transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
box-shadow: 0 4px 12px rgba(27, 94, 32, 0.30);
}
.btn-login:hover {
background: #155117;
box-shadow: 0 6px 18px rgba(27, 94, 32, 0.38);
transform: translateY(-1px);
}
.btn-login:active { transform: translateY(0); }
/* Logo putih di panel kiri */
.logo-white {
filter: brightness(0) invert(1);
opacity: 0.92;
}
/* Animasi ikon panah tombol */
.btn-login:hover .arrow-icon { transform: translateX(4px); }
.arrow-icon { transition: transform 0.18s ease; display: inline-block; }
</style>
</head>
<body class="min-h-screen bg-slate-100 flex items-center justify-center p-4">
<!-- Container: Card split dua kolom -->
<div class="w-full max-w-[880px] bg-white rounded-[28px] shadow-2xl shadow-slate-300/60 overflow-hidden flex flex-col md:flex-row">
<!-- ============================================================
PANEL KIRI — Branding (Hanya tampil di layar MD ke atas)
============================================================ -->
<div class="brand-panel hidden md:flex flex-col items-center justify-center text-center md:w-[42%] p-10 gap-0">
<!-- Logo -->
<div class="relative z-10 mb-7">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="logo-white h-8 w-auto object-contain mx-auto">
</div>
<!-- Identitas Sistem -->
<div class="relative z-10">
<p class="text-emerald-300/70 text-[11px] font-semibold tracking-[0.25em] uppercase mb-2">
Sistem Operasional
</p>
<h1 class="text-white font-black leading-none tracking-tight" style="font-size: clamp(52px, 7vw, 72px);">
RKM
</h1>
<!-- Garis aksen tipis -->
<div class="flex items-center justify-center space-x-2 mt-5">
<span class="block h-[2px] w-8 rounded-full bg-white/30"></span>
<span class="block h-[2px] w-3 rounded-full bg-[#d4af37]/80"></span>
</div>
<p class="text-white/40 text-xs font-medium mt-5 leading-relaxed">
PT Kerinci Merangin Hidro<br>PLTA Merangin 350 MW
</p>
</div>
<!-- Badge Sistem Aktif -->
<div class="relative z-10 mt-8">
<span class="inline-flex items-center space-x-1.5 bg-white/10 border border-white/15 rounded-full px-3 py-1.5">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>
<span class="text-white/60 text-[10px] font-medium tracking-wide">Sistem Aktif</span>
</span>
</div>
</div>
<!-- ============================================================
PANEL KANAN — Form Login
============================================================ -->
<div class="flex flex-col justify-center flex-1 px-8 py-10 sm:px-12 sm:py-12">
<!-- Header Mobile: Logo + nama sistem (Hanya tampil di layar kecil) -->
<div class="flex flex-col items-center mb-8 md:hidden">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="h-7 w-auto object-contain mb-4">
<div class="text-center">
<p class="text-[10px] font-semibold text-slate-400 tracking-[0.2em] uppercase">Sistem Operasional</p>
<h1 class="text-2xl font-black text-[#1b5e20] tracking-tight">RKM</h1>
</div>
<div class="w-px h-5 bg-slate-200 mt-4"></div>
</div>
<!-- Sambutan -->
<div class="mb-7">
<h2 class="text-[22px] font-bold text-slate-900 tracking-tight">Selamat Datang</h2>
<p class="text-sm text-slate-500 mt-1">Masuk menggunakan akun yang telah terdaftar</p>
</div>
<!-- Notifikasi Error -->
@if($errors->any())
<div class="mb-5 flex items-start space-x-3 p-4 bg-rose-50 border border-rose-100 rounded-2xl text-xs">
<i class="fa-solid fa-circle-xmark text-rose-500 mt-0.5 flex-shrink-0"></i>
<div class="text-rose-700">
<p class="font-semibold mb-0.5">Autentikasi gagal</p>
@foreach($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
</div>
</div>
@endif
@if(session('success'))
<div class="mb-5 flex items-center space-x-2.5 p-4 bg-emerald-50 border border-emerald-100 rounded-2xl text-xs text-emerald-700">
<i class="fa-solid fa-circle-check flex-shrink-0"></i>
<p class="font-medium">{{ session('success') }}</p>
</div>
@endif
@if(session('error'))
<div class="mb-5 flex items-center space-x-2.5 p-4 bg-amber-50 border border-amber-100 rounded-2xl text-xs text-amber-700">
<i class="fa-solid fa-triangle-exclamation flex-shrink-0"></i>
<p class="font-medium">{{ session('error') }}</p>
</div>
@endif
<!-- Form -->
<form action="{{ route('login.post') }}" method="POST" class="space-y-4">
@csrf
<!-- Username -->
<div class="space-y-1.5">
<label for="username" class="block text-xs font-semibold text-slate-500 tracking-wider uppercase">
Username atau Email
</label>
<div class="relative">
<span class="absolute inset-y-0 left-4 flex items-center pointer-events-none text-slate-400">
<i class="fa-regular fa-user text-sm"></i>
</span>
<input type="text"
name="username"
id="username"
value="{{ old('username') }}"
required autofocus
placeholder="Masukkan username atau email"
class="form-input w-full text-sm pl-11 pr-4 py-3.5 rounded-xl text-slate-800 placeholder-slate-400">
</div>
</div>
<!-- Password -->
<div class="space-y-1.5">
<label for="password" class="block text-xs font-semibold text-slate-500 tracking-wider uppercase">
Password
</label>
<div class="relative">
<span class="absolute inset-y-0 left-4 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-lock text-sm"></i>
</span>
<input type="password"
name="password"
id="password"
required
placeholder="Masukkan password"
class="form-input w-full text-sm pl-11 pr-4 py-3.5 rounded-xl text-slate-800 placeholder-slate-400">
</div>
</div>
<!-- Tombol Masuk -->
<div class="pt-2">
<button type="submit"
class="btn-login w-full text-white font-semibold text-sm py-4 rounded-xl flex items-center justify-center gap-2">
Masuk ke Sistem
<i class="fa-solid fa-arrow-right text-xs arrow-icon"></i>
</button>
</div>
</form>
<!-- Footer -->
<div class="mt-7 pt-5 border-t border-slate-100 flex items-center justify-between">
<details class="text-[11px] text-slate-400 cursor-pointer group">
<summary class="list-none flex items-center gap-1.5 font-medium hover:text-slate-600 transition-colors">
<i class="fa-solid fa-circle-info text-[#1b5e20]/60"></i>
Akun Pengujian
</summary>
<div class="absolute mt-2 bg-white rounded-xl p-3 border border-slate-200 shadow-lg text-left space-y-2 w-60 z-50">
<div class="text-[10px] font-semibold text-slate-400 uppercase tracking-wider mb-2">Akun Tersedia</div>
@php
$accounts = [
['role' => 'Admin HSE', 'username' => '1185'],
['role' => 'Admin QMA', 'username' => '1171'],
['role' => 'Admin PG', 'username' => 'AdminPG'],
];
@endphp
@foreach($accounts as $acc)
<div class="flex items-center justify-between py-1.5 border-b border-slate-100 last:border-0">
<div>
<span class="text-[11px] font-semibold text-slate-700">{{ $acc['role'] }}</span>
<code class="ml-1.5 text-[10px] bg-slate-100 text-slate-600 px-1.5 py-0.5 rounded-md">{{ $acc['username'] }}</code>
</div>
<span class="text-[10px] text-slate-400 italic">password</span>
</div>
@endforeach
</div>
</details>
<p class="text-[11px] text-slate-400">&copy; 2026 PT KMH</p>
</div>
</div>
</div>
</body>
</html>
+217
View File
@@ -0,0 +1,217 @@
@extends('layouts.app')
@section('title', 'Dashboard - Admin HSE | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Admin HSE (Persis Gaya Referensi IT KMH) -->
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
SISTEM ADMINISTRATOR
</span>
<div class="flex items-center space-x-2.5">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Selamat datang, {{ auth()->user()->name }}
</h2>
<span class="w-5 h-5 rounded-full bg-slate-200/90 text-slate-500 text-xs inline-flex items-center justify-center font-bold shadow-sm" title="Dashboard Operasional Admin HSE">
<i class="fa-solid fa-info text-[10px]"></i>
</span>
</div>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Berikut ringkasan operasional keselamatan dan tata kelola izin mengemudi SIMPER PT Kerinci Merangin Hidro secara keseluruhan.
</p>
</div>
<!-- 5 Kartu Metrik Ringkasan (Persis Gaya Kotak Warna Pastel Referensi) -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4">
<!-- 1. Total Karyawan (Pastel Hijau) -->
<div>
<div class="bg-[#eef7ee] border border-[#d6ebd7] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#2e7d32]">{{ $totalEmployees }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">TOTAL KARYAWAN</p>
</div>
<!-- 2. Driver Aktif (Pastel Biru Muda) -->
<div>
<div class="bg-[#edf5fd] border border-[#d2e4fb] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#1976d2]">{{ $totalDrivers }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">DRIVER AKTIF</p>
</div>
<!-- 3. SIMPER Tersedia (Pastel Mint / Emerald) -->
<div>
<div class="bg-[#edfbf4] border border-[#d1f5e2] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#10b981]">{{ $validSimperCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">SIMPER TERSEDIA</p>
</div>
<!-- 4. SIMPER Kedaluwarsa (Pastel Soft Blue) -->
<div>
<div class="bg-[#f0f4fe] border border-[#dae5fd] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#2563eb]">{{ $expiredSimperCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">SIMPER KEDALUWARSA</p>
</div>
<!-- 5. Bukan Driver (Pastel Amber / Yellow) -->
<div>
<div class="bg-[#fef9e8] border border-[#feefc7] rounded-3xl h-28 flex items-center justify-center shadow-xs">
<span class="text-4xl sm:text-5xl font-black text-[#f59e0b]">{{ $nonDriversCount }}</span>
</div>
<p class="mt-2.5 text-center text-[11px] font-bold text-slate-500 uppercase tracking-wider">BUKAN DRIVER</p>
</div>
</div>
<!-- Layout 2 Kolom Bawah: Log Driver & Mutasi SIMPER (Persis Gambar Referensi) -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 items-start">
<!-- Kolom Kiri: Log Driver & SIMPER Terkini (Format Log Serah Terima) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Driver & SIMPER Terkini</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($recentDrivers as $driver)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Avatar Inisial Bulat Hijau Pastel -->
<div class="w-9 h-9 rounded-full bg-[#eef7ee] text-[#1b5e20] font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5">
{{ strtoupper(substr($driver->name, 0, 1)) }}
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $driver->nik }} <span class="text-slate-400 font-normal">driver</span> {{ $driver->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
{{ $driver->position }} &bull; {{ $driver->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
SIMPER: {{ $driver->simper_expired_at ? $driver->simper_expired_at->format('d M Y') : 'Tidak Ada Tanggal' }}
</p>
</div>
<div class="flex-shrink-0">
@if($driver->hasValidSimper())
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
Aktif
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
Kedaluwarsa
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-6">Belum ada data driver.</p>
@endforelse
</div>
</div>
<!-- Kolom Kanan: 2 Kartu Stacked (Format Log Mutasi & Log Pengembalian) -->
<div class="space-y-6">
<!-- Kartu Atas: Log Status SIMPER (Format Log Mutasi) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Status SIMPER</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($simperLogs as $log)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Icon Bulat Biru Pastel (Swap / Arrow Icon) -->
<div class="w-9 h-9 rounded-full bg-[#edf5fd] text-[#1976d2] flex items-center justify-center flex-shrink-0 mt-0.5">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"></path>
</svg>
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $log->nik }} &rarr; {{ $log->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
Divisi {{ $log->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
SIMPER: {{ $log->simper_expired_at ? $log->simper_expired_at->format('d M Y') : 'Belum Diatur' }}
</p>
</div>
<div class="flex-shrink-0">
@if($log->hasValidSimper())
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-50 text-emerald-700">
Valid
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-rose-50 text-rose-700">
Kedaluwarsa
</span>
@endif
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada riwayat SIMPER.</p>
@endforelse
</div>
</div>
<!-- Kartu Bawah: Log Karyawan Non-Driver (Format Log Pengembalian) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-5">
<h3 class="text-sm font-bold text-slate-900">Log Karyawan Non-Driver</h3>
<a href="{{ route('hse.employees.index') }}" class="text-xs font-bold text-[#1b5e20] hover:underline">
Lihat Semua
</a>
</div>
<div class="space-y-4">
@forelse($nonDrivers as $staff)
<div class="flex items-start space-x-3.5 py-2 border-b border-slate-50 last:border-b-0">
<!-- Icon Bulat Netral -->
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-500 font-bold text-xs flex items-center justify-center flex-shrink-0 mt-0.5">
{{ strtoupper(substr($staff->name, 0, 1)) }}
</div>
<div class="min-w-0 flex-1">
<p class="text-xs font-bold text-slate-900 leading-tight">
{{ $staff->nik }} &bull; {{ $staff->name }}
</p>
<p class="text-[11px] text-slate-500 mt-0.5">
{{ $staff->position }} &bull; {{ $staff->division }}
</p>
<p class="text-[10px] text-slate-400 mt-0.5">
Unit Kerja: {{ $staff->unit_kerja }}
</p>
</div>
<div class="flex-shrink-0">
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-slate-100 text-slate-600">
Non-Driver
</span>
</div>
</div>
@empty
<p class="text-xs text-slate-400 text-center py-4">Belum ada karyawan non-driver.</p>
@endforelse
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,466 @@
@extends('layouts.app')
@section('title', 'Data Simper - Admin HSE | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi (Persis Format Gambar Data Karyawan IT All Role) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
MANAJEMEN SISTEM
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Data Simper
</h2>
<!-- Info Icon Badge bulat abu-abu sesuai gambar -->
<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 driver dan masa berlaku SIMPER">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan (Ekspor Simper & Tambah Karyawan) -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<!-- Tombol Ekspor Dropdown -->
<button type="button"
onclick="alert('Fitur ekspor spreadsheet SIMPER sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Simper</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
<button onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Karyawan</span>
</button>
</div>
</div>
<!-- Kotak Pencarian (Search Bar Persis Format Gambar Data Karyawan) -->
<div class="relative w-full max-w-sm sm:max-w-md">
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
id="simperSearchInput"
placeholder="Cari NIK atau nama karyawan..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</div>
<!-- Tabel Data Simper dengan Header Biru Tua Navy (Persis Format Gambar) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse">
<!-- Header Tabel Navy Gelap Solid #06213f -->
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr>
<th class="py-3.5 px-4 text-center w-12">NO</th>
<th class="py-3.5 px-4">NIK</th>
<th class="py-3.5 px-4">NAMA LENGKAP</th>
<th class="py-3.5 px-4">JABATAN</th>
<th class="py-3.5 px-4">UNIT / DIVISI</th>
<th class="py-3.5 px-4 text-center">STATUS DRIVER</th>
<th class="py-3.5 px-4 text-center">MASA BERLAKU SIMPER</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody id="simperTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($employees as $index => $emp)
@php
$isValid = $emp->hasValidSimper();
@endphp
<tr class="simper-row hover:bg-slate-50/70 transition">
<!-- Nomor -->
<td class="py-3.5 px-4 text-center font-medium text-slate-400">{{ $index + 1 }}</td>
<!-- NIK (Font Bold Hitam Tegas) -->
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs">{{ $emp->nik }}</td>
<!-- Nama Lengkap (Font Bold Hitam) -->
<td class="py-3.5 px-4 font-bold text-slate-900">{{ $emp->name }}</td>
<!-- Jabatan -->
<td class="py-3.5 px-4 text-slate-600">{{ $emp->position ?? '-' }}</td>
<!-- Unit / Divisi -->
<td class="py-3.5 px-4 text-slate-500">
<span class="font-medium text-slate-700">{{ $emp->unit_kerja ?? '-' }}</span>
@if($emp->division)
<span class="text-slate-400 block text-[10px]">{{ $emp->division }}</span>
@endif
</td>
<!-- Status Driver -->
<td class="py-3.5 px-4 text-center">
@if($emp->is_operator)
<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">
Driver
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-500">
Bukan Driver
</span>
@endif
</td>
<!-- Masa Berlaku SIMPER -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if(!$emp->is_operator)
<span class="text-slate-400 italic text-[11px]">-</span>
@elseif($isValid)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200 font-mono">
<i class="fa-solid fa-circle-check mr-1.5 text-emerald-600 text-[10px]"></i>
{{ $emp->simper_expired_at->format('d/m/Y') }}
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-rose-50 text-rose-700 border border-rose-200 font-mono">
<i class="fa-solid fa-circle-xmark mr-1.5 text-rose-600 text-[10px]"></i>
{{ $emp->simper_expired_at ? $emp->simper_expired_at->format('d/m/Y') : 'Belum Ada' }}
</span>
@endif
</td>
<!-- Aksi (Edit Data Simper & Perpanjang SIMPER) -->
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-2">
<button onclick='openEditModal(@json($emp))'
class="inline-flex items-center space-x-1 text-amber-500 hover:text-amber-700 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
title="Edit Data Simper Karyawan">
<i class="fa-regular fa-pen-to-square text-sm"></i>
<span class="text-xs font-semibold">Edit</span>
</button>
<span class="text-slate-200">|</span>
<button onclick="openRenewModal({{ $emp->id }}, '{{ $emp->name }}', '{{ $emp->simper_expired_at ? $emp->simper_expired_at->format('Y-m-d') : '' }}', {{ $emp->is_operator ? '1' : '0' }})"
class="text-emerald-700 hover:text-emerald-900 font-bold underline text-[11px]"
title="Perpanjang Masa Berlaku SIMPER">
Perpanjang
</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-regular fa-folder-open text-3xl mb-2 block text-slate-300"></i>
Belum ada data pengemudi atau SIMPER yang terdaftar.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- Modal Dialog Add Karyawan (Persis Format Gambar IT All Role) -->
<div id="addKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
<!-- Header Modal Bersih Tanpa Banner Gelap Sesuai Gambar -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Data Simper
</h3>
<button type="button" onclick="document.getElementById('addKaryawanModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form action="{{ route('hse.employees.store') }}" method="POST" class="mt-5 space-y-4">
@csrf
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nomor Induk Karyawan (NIK) <span class="text-rose-500">*</span></label>
<input type="text" name="nik" required placeholder="Contoh: 0001"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" required placeholder="Contoh: Ahmad Budi"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Unit Kerja <span class="text-rose-500">*</span></label>
<select name="unit_kerja" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="" disabled selected>Pilih Unit Kerja</option>
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Divisi <span class="text-rose-500">*</span></label>
<select name="division" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="" disabled selected>Pilih Divisi</option>
<option value="INFORMATION & TECHNOLOGY">INFORMATION & TECHNOLOGY</option>
<option value="K3">K3 / HSE</option>
<option value="Quality Management Asset (QMA)">Quality Management Asset (QMA)</option>
<option value="GA">General Affairs (GA)</option>
<option value="HR">Human Resources (HR)</option>
<option value="Keuangan">Keuangan</option>
<option value="Logistik">Logistik / Warehouse</option>
<option value="Mechanical">Mechanical</option>
<option value="Civil & Inviro">Civil & Inviro</option>
<option value="PG">Private Guard (PG)</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Jabatan <span class="text-rose-500">*</span></label>
<input type="text" name="position" required placeholder="Contoh: Staff IT"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Operator / Driver <span class="text-rose-500">*</span></label>
<select name="is_operator" id="addOperator" onchange="toggleSimperInput('add')" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku SIMPER</label>
<input type="date" name="simper_expired_at" id="addSimperDate"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<!-- Footer Tombol: Batal & Simpan Data Sesuai Gambar -->
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('addKaryawanModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Data
</button>
</div>
</form>
</div>
</div>
<!-- Modal Dialog Perpanjang SIMPER (Clean White Card) -->
<div id="renewModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-md w-full p-7 border border-slate-100 overflow-hidden">
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">Perpanjang SIMPER</h3>
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="renewForm" method="POST" action="" class="mt-5 space-y-4">
@csrf
<div class="bg-slate-50 p-3.5 rounded-2xl border border-slate-200/80">
<span class="text-xs text-slate-400 block font-medium">Pengemudi:</span>
<strong id="renewName" class="block text-base text-slate-900 font-bold mt-0.5"></strong>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Status Driver</label>
<select name="is_operator" id="renewOperator" onchange="toggleSimperInput('renew')"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku Baru <span class="text-rose-500">*</span></label>
<input type="date" name="simper_expired_at" id="renewDate" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Data
</button>
</div>
</form>
</div>
</div>
<!-- Modal Dialog Edit Data Simper Karyawan -->
<div id="editModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
<!-- Header Modal -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Data Simper
</h3>
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editForm" method="POST" action="" class="mt-5 space-y-4">
@csrf
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nomor Induk Karyawan (NIK) <span class="text-rose-500">*</span></label>
<input type="text" name="nik" id="editNik" required placeholder="Contoh: 0001"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" id="editName" required placeholder="Contoh: Ahmad Budi"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Unit Kerja <span class="text-rose-500">*</span></label>
<select name="unit_kerja" id="editUnitKerja" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Pembangkit">Pembangkit</option>
<option value="Bendungan">Bendungan</option>
<option value="Teknik">Teknik</option>
<option value="Umum">Umum</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Divisi <span class="text-rose-500">*</span></label>
<select name="division" id="editDivision" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="INFORMATION & TECHNOLOGY">INFORMATION & TECHNOLOGY</option>
<option value="K3">K3 / HSE</option>
<option value="Quality Management Asset (QMA)">Quality Management Asset (QMA)</option>
<option value="GA">General Affairs (GA)</option>
<option value="HR">Human Resources (HR)</option>
<option value="Keuangan">Keuangan</option>
<option value="Logistik">Logistik / Warehouse</option>
<option value="Mechanical">Mechanical</option>
<option value="Civil & Inviro">Civil & Inviro</option>
<option value="PG">Private Guard (PG)</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Jabatan <span class="text-rose-500">*</span></label>
<input type="text" name="position" id="editPosition" required placeholder="Contoh: Staff IT"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Operator / Driver <span class="text-rose-500">*</span></label>
<select name="is_operator" id="editOperator" onchange="toggleSimperInput('edit')" required
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="1">YA (Aktif Mengemudi)</option>
<option value="0">TIDAK (Bukan Driver)</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku SIMPER</label>
<input type="date" name="simper_expired_at" id="editSimperDate"
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<!-- Footer Tombol -->
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')"
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-sm transition shadow-sm">
Simpan Perubahan
</button>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
<script>
// Logika Penguncian Input SIMPER jika Bukan Driver
function toggleSimperInput(type) {
let opSelect, dateInput;
if (type === 'add') {
opSelect = document.getElementById('addOperator');
dateInput = document.getElementById('addSimperDate');
} else if (type === 'edit') {
opSelect = document.getElementById('editOperator');
dateInput = document.getElementById('editSimperDate');
} else if (type === 'renew') {
opSelect = document.getElementById('renewOperator');
dateInput = document.getElementById('renewDate');
}
if (!opSelect || !dateInput) return;
if (opSelect.value === '0') {
// Bukan Driver: Kosongkan dan kunci input tanggal SIMPER
dateInput.value = '';
dateInput.disabled = true;
dateInput.required = false;
dateInput.classList.add('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
dateInput.classList.remove('bg-white', 'text-slate-800');
} else {
// Driver: Aktifkan input tanggal SIMPER
dateInput.disabled = false;
dateInput.classList.remove('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
dateInput.classList.add('bg-white', 'text-slate-800');
}
}
function openEditModal(emp) {
document.getElementById('editNik').value = emp.nik || '';
document.getElementById('editName').value = emp.name || '';
document.getElementById('editUnitKerja').value = emp.unit_kerja || '';
document.getElementById('editDivision').value = emp.division || '';
document.getElementById('editPosition').value = emp.position || '';
document.getElementById('editOperator').value = emp.is_operator ? '1' : '0';
let expDate = '';
if (emp.simper_expired_at) {
expDate = emp.simper_expired_at.substring(0, 10);
}
document.getElementById('editSimperDate').value = expDate;
// Cek status driver untuk mengunci/membuka input SIMPER
toggleSimperInput('edit');
document.getElementById('editForm').action = `/hse/employees/${emp.id}`;
document.getElementById('editModal').classList.remove('hidden');
}
function openRenewModal(id, name, expiredDate, isOperator) {
document.getElementById('renewName').textContent = name;
document.getElementById('renewOperator').value = isOperator ? '1' : '0';
document.getElementById('renewDate').value = expiredDate;
// Cek status driver untuk mengunci/membuka input SIMPER
toggleSimperInput('renew');
document.getElementById('renewForm').action = `/hse/employees/${id}`;
document.getElementById('renewModal').classList.remove('hidden');
}
// Inisialisasi awal untuk modal tambah
document.addEventListener('DOMContentLoaded', function() {
toggleSimperInput('add');
});
// Filter Pencarian Instan Real-time
document.getElementById('simperSearchInput')?.addEventListener('input', function(e) {
const query = e.target.value.toLowerCase();
const rows = document.querySelectorAll('#simperTableBody tr.simper-row');
rows.forEach(row => {
const text = row.textContent.toLowerCase();
row.style.display = text.includes(query) ? '' : 'none';
});
});
</script>
@endsection
+579
View File
@@ -0,0 +1,579 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Sistem RKM - PT Kerinci Merangin Hidro')</title>
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Plus Jakarta Sans', sans-serif;
}
/* Active Sidebar Item Style (Seperti Sistem IT All Role) */
.sidebar-item-active {
background-color: #1b5e20;
color: #ffffff;
font-weight: 600;
border-radius: 0.75rem;
box-shadow: 0 4px 12px rgba(27, 94, 32, 0.25);
}
.sidebar-item-active i,
.sidebar-item-active svg {
color: #ffffff;
}
.sidebar-item-inactive {
color: #475569;
font-weight: 500;
border-radius: 0.75rem;
transition: all 0.2s ease;
}
.sidebar-item-inactive:hover {
background-color: #f1f5f9;
color: #0f172a;
}
.sidebar-item-inactive i,
.sidebar-item-inactive svg {
color: #64748b;
}
.sidebar-item-inactive:hover i,
.sidebar-item-inactive:hover svg {
color: #1b5e20;
}
</style>
</head>
<body class="bg-slate-50 text-slate-800 antialiased font-sans min-h-screen">
@auth
<!-- ========================================================================= -->
<!-- LAYOUT AUTHENTICATED: SIDEBAR + TOPBAR (PERSIS SISTEM IT ALL ROLE) -->
<!-- ========================================================================= -->
<!-- 1. SIDEBAR DESKTOP (Fixed di Sebelah Kiri) -->
<aside class="hidden md:flex flex-col justify-between w-64 bg-white border-r border-slate-200 h-screen fixed left-0 top-0 z-30 shadow-sm">
<div class="flex flex-col h-full overflow-hidden">
<!-- Header Sidebar: Logo Kerinci Hydropower (Tengah Sidebar) -->
<div class="h-16 px-6 flex items-center justify-center border-b border-slate-100 flex-shrink-0">
<a href="{{ url('/') }}" class="flex items-center justify-center">
<img src="{{ asset('images/logo-kerinci.png') }}"
alt="Kerinci Hydropower"
class="h-8 w-auto object-contain">
</a>
</div>
<!-- Menu Navigasi Sidebar -->
<div class="flex-1 overflow-y-auto px-4 py-5 space-y-6">
<!-- Grup: Navigasi Utama -->
<div>
<nav class="space-y-1">
@if(auth()->user()->isHseAdmin())
<a href="{{ route('hse.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@elseif(auth()->user()->isQmaAdmin())
<a href="{{ route('qma.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@elseif(auth()->user()->isPgAdmin() || auth()->user()->isGateOfficer())
<a href="{{ route('pg.gate.inspection') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Pos Gerbang</span>
</a>
@else
<a href="{{ route('qma.activity.log') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm sidebar-item-active">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@endif
</nav>
</div>
<!-- Grup: Modul Operasional RKM -->
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN SISTEM
</p>
<nav class="space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
<a href="{{ route('hse.employees.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card text-base w-5 text-center"></i>
<span>Data Simper</span>
</a>
@endif
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
@php
$isVehicleRoute = request()->routeIs('qma.vehicles.*');
@endphp
<!-- Dropdown Menu: Data Kendaraan -->
<div>
<button type="button"
onclick="toggleVehicleMenu('desktop')"
class="w-full flex items-center justify-between px-3.5 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRoute ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<div class="flex items-center space-x-3">
<i class="fa-solid fa-car text-base w-5 text-center {{ $isVehicleRoute ? 'text-[#1b5e20]' : '' }}"></i>
<span>Data Kendaraan</span>
</div>
<i id="vehicleChevronDesktop" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRoute ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<!-- Submenu Dropdown: Light Vehicle & Unit Support (Tanpa Icon) -->
<div id="vehicleSubmenuDesktop" class="{{ $isVehicleRoute ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<a href="{{ route('qma.vehicles.lv') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Light Vehicle</span>
</a>
<a href="{{ route('qma.vehicles.support') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Unit Support</span>
</a>
</div>
</div>
<a href="{{ route('qma.activity.log') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-list text-base w-5 text-center"></i>
<span>Log Aktivitas Kendaraan</span>
</a>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.guards.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
<span>Master Satpam (PG)</span>
</a>
@endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.gate.inspection') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Verifikasi Gerbang</span>
</a>
@endif
</nav>
</div>
<!-- Grup: Pengaturan Akun -->
<div class="mt-6">
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
PENGATURAN
</p>
<nav class="space-y-1">
<a href="{{ route('profile.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('profile.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<span>Profil Saya</span>
</a>
</nav>
</div>
</div>
<!-- Footer Bawah Sidebar: Profil Pengguna & Tombol Logout (Persis Gambar IT All Role) -->
<div class="p-4 border-t border-slate-100 flex items-center justify-between bg-slate-50/50">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-2.5 min-w-0 hover:opacity-80 transition group" title="Buka Profil Saya">
<div class="w-8 h-8 rounded-full bg-[#1b5e20] text-white font-black text-xs flex items-center justify-center flex-shrink-0 shadow-sm group-hover:ring-2 ring-emerald-500/30">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<div class="truncate">
<p class="text-xs font-bold text-slate-800 truncate leading-tight group-hover:text-[#1b5e20]">{{ auth()->user()->name }}</p>
<p class="text-[10px] text-slate-400 capitalize truncate">{{ str_replace('_', ' ', auth()->user()->role) }}</p>
</div>
</a>
<form action="{{ route('logout') }}" method="POST" class="inline">
@csrf
<button type="submit" title="Logout" class="w-8 h-8 rounded-lg flex items-center justify-center text-slate-400 hover:text-rose-600 hover:bg-rose-50 transition">
<i class="fa-solid fa-arrow-right-from-bracket text-sm"></i>
</button>
</form>
</div>
</div>
</aside>
<!-- 2. SIDEBAR MOBILE (Drawer Modal untuk Layar Kecil) -->
<div id="mobileDrawer" class="fixed inset-0 z-50 hidden md:hidden">
<!-- Backdrop gelap -->
<div id="mobileBackdrop" class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm transition-opacity duration-300 ease-in-out opacity-0"></div>
<!-- Drawer Content -->
<div id="mobileDrawerPanel" class="fixed inset-y-0 left-0 w-72 bg-white shadow-2xl flex flex-col justify-between z-10 transform -translate-x-full transition-transform duration-300 ease-in-out">
<div class="p-5 border-b border-slate-100 flex items-center justify-between">
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-7 w-auto object-contain">
<button id="closeDrawerBtn" class="text-slate-400 hover:text-slate-600 p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="p-4 space-y-4 flex-1 overflow-y-auto">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2">NAVIGASI</p>
<div class="space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
<a href="{{ route('hse.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
<a href="{{ route('hse.employees.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card w-5 text-center"></i>
<span>Data Simper</span>
</a>
@endif
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
<a href="{{ route('qma.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg>
<span>Dashboard</span>
</a>
@php
$isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
@endphp
<div>
<button type="button"
onclick="toggleVehicleMenu('mobile')"
class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<div class="flex items-center space-x-3">
<i class="fa-solid fa-car w-5 text-center {{ $isVehicleRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
<span>Data Kendaraan</span>
</div>
<i id="vehicleChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<a href="{{ route('qma.vehicles.lv') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Light Vehicle</span>
</a>
<a href="{{ route('qma.vehicles.support') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Unit Support</span>
</a>
</div>
</div>
<a href="{{ route('qma.activity.log') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-list w-5 text-center"></i>
<span>Log Aktivitas Kendaraan</span>
</a>
@endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.guards.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-user-shield w-5 text-center"></i>
<span>Master Satpam (PG)</span>
</a>
@endif
@if(auth()->user()->isGateOfficer() || auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Pos Gerbang</span>
</a>
@endif
</div>
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mt-4">PENGATURAN</p>
<div class="space-y-1">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('profile.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<span>Profil Saya</span>
</a>
</div>
</div>
<div class="p-4 border-t border-slate-100 flex items-center justify-between bg-slate-50">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-2 hover:opacity-80 transition">
<div class="w-8 h-8 rounded-full bg-[#1b5e20] text-white font-bold text-xs flex items-center justify-center">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<span class="text-xs font-bold text-slate-800">{{ auth()->user()->name }}</span>
</a>
<form action="{{ route('logout') }}" method="POST">
@csrf
<button type="submit" class="text-rose-600 text-xs font-bold px-2.5 py-1 rounded bg-rose-50">Logout</button>
</form>
</div>
</div>
</div>
<!-- 3. TOPBAR HEADER (Di Bagian Atas Samping Sidebar) -->
<header class="md:ml-64 bg-white border-b border-slate-200 h-16 sticky top-0 z-20 flex items-center justify-between px-6 sm:px-8 shadow-sm">
<!-- Sisi Kiri: Judul Halaman / Hamburger Button -->
<div class="flex items-center space-x-3">
<button id="openDrawerBtn" class="md:hidden text-slate-600 hover:text-slate-900 p-1.5 rounded-lg border border-slate-200">
<i class="fa-solid fa-bars text-base"></i>
</button>
<h1 class="text-lg sm:text-xl font-bold text-slate-900 tracking-tight">
@if(request()->routeIs('hse.dashboard') || request()->routeIs('qma.dashboard'))
Dashboard
@elseif(request()->routeIs('hse.employees.*'))
Data Simper
@elseif(request()->routeIs('qma.vehicles.lv'))
Light Vehicle
@elseif(request()->routeIs('qma.vehicles.support'))
Unit Support
@elseif(request()->routeIs('qma.vehicles.*'))
Data Kendaraan
@elseif(request()->routeIs('qma.activity.log'))
Log Aktivitas Kendaraan
@elseif(request()->routeIs('profile.*'))
Profil Saya
@elseif(request()->routeIs('pg.gate.*'))
Verifikasi Pos Gerbang
@elseif(request()->routeIs('pg.guards.*'))
Master Data Satpam (PG)
@else
Dashboard
@endif
</h1>
</div>
<!-- Sisi Kanan: Profil Pengguna (Avatar Bulat + Nama + Role Huruf Kapital) Sesuai Gambar IT All Role -->
<div class="flex items-center space-x-3">
<a href="{{ route('profile.index') }}" class="flex items-center space-x-3 pl-3 hover:opacity-80 transition group" title="Buka Profil Saya">
<div class="w-9 h-9 rounded-full bg-[#1b5e20] text-white font-bold text-sm flex items-center justify-center shadow-sm group-hover:ring-2 ring-emerald-500/30">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<div class="text-left hidden sm:block">
<p class="text-xs font-bold text-slate-800 leading-tight group-hover:text-[#1b5e20]">{{ auth()->user()->name }}</p>
<p class="text-[10px] font-semibold text-slate-400 uppercase tracking-wider mt-0.5">
{{ str_replace('_', ' ', auth()->user()->role) }}
</p>
</div>
</a>
</div>
</header>
<!-- 4. KONTEN UTAMA DASHBOARD -->
<main class="md:ml-64 p-6 sm:p-8 min-h-[calc(100vh-4rem)]">
@yield('content')
</main>
@else
<!-- ========================================================================= -->
<!-- LAYOUT PUBLIC (KHUSUS FORM SCAN QR LAPANGAN TANPA LOGIN) -->
<!-- ========================================================================= -->
<header class="bg-white border-b border-slate-200 sticky top-0 z-30 shadow-sm">
<div class="max-w-4xl mx-auto px-4 py-3 flex items-center justify-between">
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-8 w-auto object-contain">
<a href="{{ route('login') }}" class="text-xs font-semibold text-[#1b5e20] hover:underline flex items-center space-x-1">
<span>Login Petugas</span>
<i class="fa-solid fa-arrow-right text-[10px]"></i>
</a>
</div>
</header>
<main class="max-w-4xl mx-auto p-4 sm:p-6 min-h-[calc(100vh-5rem)]">
@yield('content')
</main>
<footer class="py-4 text-center text-xs text-slate-400 border-t border-slate-200 bg-white">
&copy; 2026 PT Kerinci Merangin Hidro &bull; PLTA Merangin 350 MW
</footer>
@endauth
<!-- Toast Notification Container (Pojok Kanan Bawah) -->
<div id="toastContainer" class="fixed bottom-6 right-6 z-50 flex flex-col space-y-3 pointer-events-none">
@if(session('success'))
<div id="toast-success" class="pointer-events-auto bg-white rounded-2xl shadow-2xl border border-slate-100 overflow-hidden min-w-[320px] max-w-sm sm:max-w-md transform transition-all duration-300 ease-out translate-y-0 opacity-100">
<div class="px-5 py-4 flex items-center justify-between gap-4">
<div class="flex items-center space-x-3.5">
<div class="flex-shrink-0 text-[#10b981]">
<svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.3" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" stroke="currentColor"></circle>
<path stroke-linecap="round" stroke-linejoin="round" d="M8.5 12.5l2.5 2.5 4.5-5"></path>
</svg>
</div>
<div class="text-sm font-bold text-slate-800 leading-snug">
{{ session('success') }}
</div>
</div>
<button type="button" onclick="dismissToast('toast-success')" class="text-slate-400 hover:text-slate-600 transition-colors p-1 flex-shrink-0 focus:outline-none" title="Tutup">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Progress Countdown Bar -->
<div class="w-full bg-slate-100 h-1 overflow-hidden">
<div id="toast-progress-success" class="h-full bg-[#10b981] transition-all ease-linear" style="transition-duration: 4000ms; width: 100%;"></div>
</div>
</div>
@endif
@if(session('error'))
<div id="toast-error" class="pointer-events-auto bg-white rounded-2xl shadow-2xl border border-slate-100 overflow-hidden min-w-[320px] max-w-sm sm:max-w-md transform transition-all duration-300 ease-out translate-y-0 opacity-100">
<div class="px-5 py-4 flex items-center justify-between gap-4">
<div class="flex items-center space-x-3.5">
<div class="flex-shrink-0 text-rose-500">
<svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.3" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9" stroke="currentColor"></circle>
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01"></path>
</svg>
</div>
<div class="text-sm font-bold text-slate-800 leading-snug">
{{ session('error') }}
</div>
</div>
<button type="button" onclick="dismissToast('toast-error')" class="text-slate-400 hover:text-slate-600 transition-colors p-1 flex-shrink-0 focus:outline-none" title="Tutup">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Progress Countdown Bar -->
<div class="w-full bg-slate-100 h-1 overflow-hidden">
<div id="toast-progress-error" class="h-full bg-rose-500 transition-all ease-linear" style="transition-duration: 4000ms; width: 100%;"></div>
</div>
</div>
@endif
</div>
<!-- Script Javascript untuk Drawer Mobile & Toast Notification -->
<script>
const openBtn = document.getElementById('openDrawerBtn');
const closeBtn = document.getElementById('closeDrawerBtn');
const drawer = document.getElementById('mobileDrawer');
const backdrop = document.getElementById('mobileBackdrop');
const drawerPanel = document.getElementById('mobileDrawerPanel');
let drawerTimer = null;
if (openBtn && drawer && closeBtn && backdrop && drawerPanel) {
const openDrawer = () => {
if (drawerTimer) clearTimeout(drawerTimer);
drawer.classList.remove('hidden');
document.body.classList.add('overflow-hidden');
// Beri waktu 2 frame agar browser menyelesaikan repaint sebelum memulai transisi CSS
requestAnimationFrame(() => {
requestAnimationFrame(() => {
backdrop.classList.remove('opacity-0');
backdrop.classList.add('opacity-100');
drawerPanel.classList.remove('-translate-x-full');
drawerPanel.classList.add('translate-x-0');
});
});
};
const closeDrawer = () => {
backdrop.classList.remove('opacity-100');
backdrop.classList.add('opacity-0');
drawerPanel.classList.remove('translate-x-0');
drawerPanel.classList.add('-translate-x-full');
document.body.classList.remove('overflow-hidden');
if (drawerTimer) clearTimeout(drawerTimer);
drawerTimer = setTimeout(() => {
drawer.classList.add('hidden');
}, 300);
};
openBtn.addEventListener('click', openDrawer);
closeBtn.addEventListener('click', closeDrawer);
backdrop.addEventListener('click', closeDrawer);
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && !drawer.classList.contains('hidden')) {
closeDrawer();
}
});
}
// Fungsi Menutup Toast
function dismissToast(id) {
const toast = document.getElementById(id);
if (!toast) return;
toast.classList.add('opacity-0', 'translate-y-3');
setTimeout(() => {
toast.remove();
}, 300);
}
// Auto dismiss Toast dengan countdown progress bar
document.addEventListener('DOMContentLoaded', () => {
const successToast = document.getElementById('toast-success');
if (successToast) {
const bar = document.getElementById('toast-progress-success');
setTimeout(() => {
if (bar) bar.style.width = '0%';
}, 50);
setTimeout(() => {
dismissToast('toast-success');
}, 4100);
}
const errorToast = document.getElementById('toast-error');
if (errorToast) {
const bar = document.getElementById('toast-progress-error');
setTimeout(() => {
if (bar) bar.style.width = '0%';
}, 50);
setTimeout(() => {
dismissToast('toast-error');
}, 4100);
}
});
// Toggle Dropdown Menu Data Kendaraan (Desktop & Mobile)
function toggleVehicleMenu(target) {
const submenu = document.getElementById(target === 'desktop' ? 'vehicleSubmenuDesktop' : 'vehicleSubmenuMobile');
const chevron = document.getElementById(target === 'desktop' ? 'vehicleChevronDesktop' : 'vehicleChevronMobile');
if (submenu) {
submenu.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
</script>
@yield('scripts')
</body>
</html>
@@ -0,0 +1,188 @@
@extends('layouts.app')
@section('title', 'Verifikasi Pos Gerbang - Private Guard (PG)')
@section('content')
<div class="space-y-6">
<!-- 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>
<div class="flex items-center space-x-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">
<i class="fa-solid fa-shield-halved mr-1"></i> Pos Gerbang Aktif
</span>
<span class="text-xs text-slate-400">Akun Bersama Pos Jaga</span>
</div>
<h2 class="text-2xl font-black text-white tracking-tight mt-1">
{{ $gate ? $gate->name : 'Pos Gerbang Belum Dipilih' }}
</h2>
<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.
</p>
</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">
<i class="fa-solid fa-clock-rotate-left mr-2 animate-spin"></i>
Antrean: {{ $pendingActivities->count() }} Kendaraan
</span>
</div>
</div>
<!-- Antrean Validasi Kendaraan -->
<div class="bg-white rounded-xl 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">
<h3 class="text-sm 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
</h3>
<span class="text-xs text-slate-500">Auto-refresh saat halaman dimuat ulang</span>
</div>
<div class="divide-y divide-slate-200">
@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="space-y-2 flex-1">
<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">
{{ $act->vehicle->code }}
</span>
<span class="text-xs font-bold text-amber-600 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded">
{{ $act->vehicle->license_plate ?? 'Tanpa Plat' }}
</span>
@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">
<i class="fa-solid fa-arrow-right-to-bracket mr-1"></i> MASUK (In)
</span>
@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">
<i class="fa-solid fa-arrow-right-from-bracket mr-1"></i> KELUAR (Out)
</span>
@endif
<span class="text-xs text-slate-500 font-mono">
Diinput: {{ $act->recorded_at->format('H:i:s d/m/Y') }}
</span>
</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><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">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">Jarak Sesi Ini:</span> <strong class="text-slate-800 font-mono">+{{ number_format($act->distance, 0, ',', '.') }} KM</strong></div>
</div>
<div class="text-xs bg-slate-100 p-2.5 rounded-lg border border-slate-200 text-slate-700">
<span class="font-bold text-slate-800">Rencana Kerja:</span> {{ $act->purpose }}
</div>
</div>
<!-- Tombol Aksi Verifikasi Satpam -->
<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 }}')"
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">
<i class="fa-solid fa-clipboard-check"></i>
<span>Verifikasi Satpam</span>
</button>
</div>
</div>
@empty
<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>
<p class="text-sm font-medium text-slate-600">Tidak ada kendaraan yang menunggu verifikasi di gerbang ini saat ini.</p>
<span class="text-xs text-slate-400">Semua aktivitas kendaraan telah diperiksa atau belum ada pemindaian baru.</span>
</div>
@endforelse
</div>
</div>
</div>
<!-- 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 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-slate-900 text-white p-4 flex justify-between 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
</h3>
<button onclick="closeVerificationModal()" class="text-slate-400 hover:text-white"><i class="fa-solid fa-xmark"></i></button>
</div>
<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><span class="text-slate-500">Unit:</span> <strong id="modalUnitCode" class="text-slate-800 font-mono"></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">KM Odometer Input:</span> <strong id="modalKmInput" class="text-emerald-700 font-mono text-sm"></strong> KM</div>
</div>
<!-- Form Approve -->
<form id="approveForm" method="POST" action="">
@csrf
<div class="mb-4">
<label for="security_guard_id" class="block text-xs font-semibold text-slate-700 mb-1">
Pilih Nama Satpam yang Bertugas <span class="text-rose-500">*</span>
</label>
<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">
<option value="" disabled selected>-- Pilih Nama Anda (Satpam) --</option>
@foreach($guards as $guard)
<option value="{{ $guard->id }}">{{ $guard->name }}</option>
@endforeach
</select>
</div>
<div class="flex items-center space-x-2 pt-2 border-t border-slate-200">
<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">
<i class="fa-solid fa-check"></i>
<span>Setujui (Buka Portal)</span>
</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">
Tolak
</button>
</div>
</form>
<!-- Section Form Reject (Hidden by default) -->
<form id="rejectForm" method="POST" action="" class="hidden border-t border-rose-200 pt-3">
@csrf
<div class="space-y-3">
<div>
<label class="block text-xs font-semibold 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>
</div>
<input type="hidden" name="security_guard_id" id="rejectGuardId">
<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">
Konfirmasi Tolak Kendaraan
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
function openVerificationModal(activityId, unitCode, kmInput, driverName) {
document.getElementById('modalUnitCode').textContent = unitCode;
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('rejectForm').action = `/pg/gate-inspection/${activityId}/reject`;
document.getElementById('rejectForm').classList.add('hidden');
document.getElementById('verificationModal').classList.remove('hidden');
}
function closeVerificationModal() {
document.getElementById('verificationModal').classList.add('hidden');
}
function showRejectSection() {
const guardSelect = document.getElementById('security_guard_id');
if (!guardSelect.value) {
alert('Silakan pilih nama Satpam terlebih dahulu sebelum menolak.');
guardSelect.focus();
return;
}
document.getElementById('rejectGuardId').value = guardSelect.value;
document.getElementById('rejectForm').classList.toggle('hidden');
}
</script>
@endsection
+91
View File
@@ -0,0 +1,91 @@
@extends('layouts.app')
@section('title', 'Master Data Satpam - Admin Private Guard')
@section('content')
<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">
<div>
<h2 class="text-xl font-bold text-slate-900 tracking-tight flex items-center">
<i class="fa-solid fa-user-shield text-emerald-600 mr-2.5"></i> Master Data Satpam (Private Guard)
</h2>
<p class="text-xs text-slate-500 mt-1">
Kelola data petugas keamanan yang bertugas melakukan verifikasi kendaraan di pos gerbang proyek.
</p>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<!-- Form Tambah Satpam Baru -->
<div class="bg-white p-5 rounded-xl border border-slate-200 shadow-sm h-fit">
<h3 class="text-sm font-bold text-slate-800 uppercase tracking-wider mb-4 flex items-center">
<i class="fa-solid fa-user-plus text-emerald-600 mr-2"></i> Tambah Petugas Satpam
</h3>
<form action="{{ route('pg.guards.store') }}" method="POST" class="space-y-4">
@csrf
<div>
<label for="name" class="block text-xs font-semibold text-slate-700 mb-1">
Nama Lengkap Satpam <span class="text-rose-500">*</span>
</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">
</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>
</div>
<!-- Tabel Daftar Satpam -->
<div class="md:col-span-2 bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
<div class="p-4 bg-slate-50 border-b border-slate-200">
<h3 class="text-xs font-bold text-slate-700 uppercase tracking-wider">
Daftar Petugas Satpam Aktif & Nonaktif
</h3>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-200 text-xs text-left">
<thead class="bg-slate-100 font-semibold text-slate-600 uppercase tracking-wider">
<tr>
<th class="py-3 px-4 text-center">No</th>
<th class="py-3 px-4">Nama Lengkap</th>
<th class="py-3 px-4 text-center">Status Piket</th>
<th class="py-3 px-4 text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200 text-slate-700">
@forelse($guards as $index => $g)
<tr class="hover:bg-slate-50 transition">
<td class="py-3 px-4 text-center text-slate-400">{{ $index + 1 }}</td>
<td class="py-3 px-4 font-bold text-slate-800">{{ $g->name }}</td>
<td class="py-3 px-4 text-center">
@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">
Aktif
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-slate-100 text-slate-500">
Nonaktif
</span>
@endif
</td>
<td class="py-3 px-4 text-center">
<form action="{{ route('pg.guards.toggle', $g->id) }}" method="POST" class="inline">
@csrf
<button type="submit" class="text-[11px] font-medium text-slate-600 hover:text-slate-900 underline">
{{ $g->is_active ? 'Nonaktifkan' : 'Aktifkan' }}
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="py-6 text-center text-slate-400">Belum ada data petugas Satpam.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
+163
View File
@@ -0,0 +1,163 @@
@extends('layouts.app')
@section('title', 'Profil Saya - PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6 max-w-5xl">
<!-- Header Judul -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
PENGATURAN AKUN
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Profil Saya
</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="Informasi akun pengguna Anda">
<i class="fa-solid fa-info"></i>
</span>
</div>
<p class="text-xs text-slate-500 mt-1">
Kelola informasi identitas, kredensial login, dan pengaturan keamanan akun Anda.
</p>
</div>
</div>
<!-- Layout 2 Kolom Profil -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 items-start">
<!-- Kolom Kiri: Kartu Ringkasan Pengguna -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm flex flex-col items-center text-center">
<!-- Avatar Besar -->
<div class="w-24 h-24 rounded-full bg-[#1b5e20] text-white text-3xl font-black flex items-center justify-center shadow-lg mb-4 ring-4 ring-emerald-50">
{{ strtoupper(substr($user->name, 0, 1)) }}
</div>
<h3 class="text-lg font-bold text-slate-900">{{ $user->name }}</h3>
<p class="text-xs font-mono text-slate-500 mt-0.5">NIK / Username: {{ $user->username ?? '-' }}</p>
<!-- Role Badge -->
<div class="mt-3">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-emerald-100 text-emerald-800 uppercase tracking-wide">
<i class="fa-solid fa-user-shield mr-1.5 text-[11px]"></i>
{{ str_replace('_', ' ', $user->role) }}
</span>
</div>
<div class="w-full border-t border-slate-100 mt-6 pt-5 space-y-3 text-left text-xs">
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Status Akun</span>
<span class="inline-flex items-center font-bold text-emerald-700">
<span class="w-2 h-2 rounded-full bg-emerald-500 mr-1.5 animate-pulse"></span>
Aktif
</span>
</div>
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Unit Operasional</span>
<span class="font-semibold text-slate-800">PLTA Merangin 350 MW</span>
</div>
<div class="flex justify-between items-center py-1">
<span class="text-slate-500">Terdaftar Sejak</span>
<span class="font-semibold text-slate-800">{{ $user->created_at ? $user->created_at->format('d M Y') : '12 Okt 2026' }}</span>
</div>
</div>
</div>
<!-- Kolom Kanan: Form Edit Profil & Kata Sandi -->
<div class="lg:col-span-2 bg-white rounded-2xl border border-slate-200 p-6 sm:p-8 shadow-sm">
<h3 class="text-base font-bold text-slate-900 mb-1">Perbarui Data Akun</h3>
<p class="text-xs text-slate-400 mb-6">Ubah data nama lengkap, email, atau perbarui kata sandi akun Anda.</p>
@if($errors->any())
<div class="mb-6 p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-800 text-xs space-y-1">
<div class="font-bold flex items-center">
<i class="fa-solid fa-triangle-exclamation mr-2"></i> Mohon periksa kesalahan berikut:
</div>
<ul class="list-disc list-inside ml-2">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('profile.update') }}" method="POST" class="space-y-5">
@csrf
@method('PUT')
<!-- Nama Lengkap -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="name" value="{{ old('name', $user->name) }}" required
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<!-- Username / NIK (Read-Only) -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Username / NIK</label>
<div class="relative">
<input type="text" value="{{ $user->username ?? '-' }}" readonly
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-slate-100 text-slate-500 font-mono cursor-not-allowed">
<span class="absolute inset-y-0 right-0 pr-3.5 flex items-center text-slate-400 text-xs" title="Username dikelola oleh Administrator">
<i class="fa-solid fa-lock"></i>
</span>
</div>
</div>
<!-- Role Sistem (Read-Only) -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Hak Akses Sistem</label>
<div class="relative">
<input type="text" value="{{ strtoupper(str_replace('_', ' ', $user->role)) }}" readonly
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-slate-100 text-slate-500 cursor-not-allowed">
<span class="absolute inset-y-0 right-0 pr-3.5 flex items-center text-slate-400 text-xs" title="Hak akses ditentukan administrator">
<i class="fa-solid fa-shield"></i>
</span>
</div>
</div>
</div>
<!-- Email Pengguna -->
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Alamat Email</label>
<input type="email" name="email" value="{{ old('email', $user->email) }}" placeholder="[email protected]"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<!-- Pemisah Bagian Ganti Password -->
<div class="pt-4 border-t border-slate-100">
<h4 class="text-xs font-bold uppercase tracking-wider text-slate-700 mb-1">Keamanan & Kata Sandi</h4>
<p class="text-[11px] text-slate-400 mb-4">Kosongkan kolom kata sandi di bawah jika Anda tidak berniat mengubah kata sandi saat ini.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Kata Sandi Baru</label>
<input type="password" name="password" placeholder="Minimal 6 karakter"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-2">Konfirmasi Kata Sandi Baru</label>
<input type="password" name="password_confirmation" placeholder="Ulangi kata sandi baru"
class="w-full text-xs px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
</div>
<!-- Tombol Aksi Simpan -->
<div class="pt-4 flex justify-end">
<button type="submit"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-6 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-md">
<i class="fa-solid fa-floppy-disk text-xs"></i>
<span>Simpan Perubahan</span>
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,204 @@
@extends('layouts.app')
@section('title', 'Input Timesheet Unit - ' . $vehicle->code)
@section('content')
<div class="max-w-2xl mx-auto">
<!-- Card Utama Form Input Timesheet -->
<div class="bg-white rounded-xl shadow-md border border-slate-200 overflow-hidden">
<!-- Header Info Kendaraan (Readonly Card) -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 text-white p-5 border-b border-slate-700">
<div class="flex items-center justify-between mb-3">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-500/20 text-emerald-300 border border-emerald-500/30">
<i class="fa-solid fa-car mr-1"></i> Kendaraan Ringan (LV)
</span>
<span class="text-xs text-slate-400">Scan QR Code Aktif</span>
</div>
<h2 class="text-xl font-bold tracking-tight text-white mb-3">Input Timesheet Unit</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs text-slate-300 bg-slate-800/80 p-3 rounded-lg border border-slate-700">
<div><span class="text-slate-400 font-medium">Kode Unit:</span> <span class="font-bold text-white text-sm">{{ $vehicle->code }}</span></div>
<div><span class="text-slate-400 font-medium">Nopol:</span> <span class="font-bold text-amber-300 text-sm">{{ $vehicle->license_plate ?? '-' }}</span></div>
<div class="col-span-1 sm:col-span-2"><span class="text-slate-400 font-medium">Merk / Tipe:</span> <span class="text-white">{{ $vehicle->brand_type }}</span></div>
<div><span class="text-slate-400 font-medium">Penanggung Jawab:</span> <span class="text-slate-200">{{ $vehicle->ownership ?? '-' }}</span></div>
<div><span class="text-slate-400 font-medium">KM Sebelumnya:</span> <span class="font-bold text-emerald-400 text-sm">{{ number_format($vehicle->current_km, 0, ',', '.') }} KM</span></div>
</div>
</div>
<!-- Form Body -->
<form action="{{ route('vehicle.activity.store', ['code' => $vehicle->code]) }}" method="POST" id="timesheetForm" class="p-6 space-y-5">
@csrf
<!-- 1. Pilihan Pengemudi (Driver) dengan Validasi SIMPER Real-time -->
<div>
<label for="driver_id" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Nama Pemakai Unit (Driver) <span class="text-rose-500">*</span>
</label>
<select name="driver_id" id="driver_id" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Driver / Pemakai Unit --</option>
@foreach($drivers as $d)
@php
$isValid = $d->hasValidSimper();
$expiredDate = $d->simper_expired_at ? $d->simper_expired_at->format('d/m/Y') : 'Tidak Ada Data';
@endphp
<option value="{{ $d->id }}"
data-is-valid="{{ $isValid ? '1' : '0' }}"
data-expired="{{ $expiredDate }}"
{{ old('driver_id') == $d->id ? 'selected' : '' }}>
{{ $d->name }} ({{ $d->division ?? 'Umum' }}) — SIMPER: {{ $expiredDate }} {{ !$isValid ? '🔴 [KEDALUWARSA]' : '🟢' }}
</option>
@endforeach
</select>
<!-- Warning Banner SIMPER Kedaluwarsa (BR-01 & BR-02) -->
<div id="simperWarningBanner" class="hidden mt-3 p-3.5 bg-rose-50 border border-rose-200 rounded-lg text-rose-800 text-xs flex items-start space-x-2.5 animate-pulse">
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base mt-0.5"></i>
<div>
<span class="font-bold block text-sm">Peringatan: Masa Berlaku SIMPER Telah Kedaluwarsa!</span>
<p class="mt-0.5" id="simperWarningText">Karyawan ini tidak dapat mengoperasikan unit. Silakan lakukan perpanjangan SIMPER melalui Divisi HSE.</p>
</div>
</div>
</div>
<!-- 2. Pilihan Gate / Gerbang -->
<div>
<label for="gate_id" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Lokasi Gate / Gerbang <span class="text-rose-500">*</span>
</label>
<select name="gate_id" id="gate_id" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Pos Gerbang --</option>
@foreach($gates as $g)
<option value="{{ $g->id }}" {{ old('gate_id') == $g->id ? 'selected' : '' }}>
{{ $g->name }} ({{ $g->code }})
</option>
@endforeach
</select>
</div>
<!-- 3. Arah Gerbang (In/Out) dengan Logika Berpasangan -->
<div>
<div class="flex items-center justify-between mb-1.5">
<label for="direction" class="block text-xs font-semibold uppercase tracking-wider text-slate-700">
Arah Akses Gerbang (In / Out) <span class="text-rose-500">*</span>
</label>
@if($allowedDirection === 'ANY')
<span class="text-xs text-emerald-600 font-medium"><i class="fa-solid fa-sparkles"></i> Transaksi Perdana (Bebas Pilih)</span>
@else
<span class="text-xs text-amber-600 font-medium"><i class="fa-solid fa-lock"></i> Terkunci Berpasangan ({{ strtoupper($allowedDirection) }})</span>
@endif
</div>
@if($allowedDirection === 'ANY')
<select name="direction" id="direction" required class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<option value="" disabled selected>-- Pilih Arah Akses --</option>
<option value="in" {{ old('direction') === 'in' ? 'selected' : '' }}>MASUK (In)</option>
<option value="out" {{ old('direction') === 'out' ? 'selected' : '' }}>KELUAR (Out)</option>
</select>
@else
<input type="hidden" name="direction" value="{{ $allowedDirection }}">
<div class="p-3 bg-slate-100 border border-slate-300 rounded-lg text-sm font-semibold flex items-center justify-between {{ $allowedDirection === 'in' ? 'text-emerald-700 bg-emerald-50 border-emerald-300' : 'text-blue-700 bg-blue-50 border-blue-300' }}">
<span>
<i class="fa-solid {{ $allowedDirection === 'in' ? 'fa-arrow-right-to-bracket' : 'fa-arrow-right-from-bracket' }} mr-2"></i>
Arah Otomatis: {{ $allowedDirection === 'in' ? 'MASUK (In)' : 'KELUAR (Out)' }}
</span>
<span class="text-xs font-normal text-slate-500">(Berdasarkan status terakhir)</span>
</div>
@endif
</div>
<!-- 4. Input Odometer KM -->
<div>
<label for="current_km" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Odometer Saat Ini (KM) <span class="text-rose-500">*</span>
</label>
<div class="relative">
<input type="number" step="0.1" name="current_km" id="current_km"
value="{{ old('current_km', $vehicle->current_km) }}"
min="{{ $vehicle->current_km }}"
required
placeholder="Masukkan angka odometer di speedometer"
class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 font-semibold focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none text-xs font-bold text-slate-400">
KM
</div>
</div>
<div class="flex items-center justify-between mt-1 text-xs text-slate-500">
<span>Minimal: {{ number_format($vehicle->current_km, 0, ',', '.') }} KM</span>
<span id="distancePreview" class="font-medium text-emerald-600">Estimasi Jarak: 0 KM</span>
</div>
</div>
<!-- 5. Rencana Pekerjaan / Aktivitas -->
<div>
<label for="purpose" class="block text-xs font-semibold uppercase tracking-wider text-slate-700 mb-1.5">
Rencana Pekerjaan / Aktivitas <span class="text-rose-500">*</span>
</label>
<textarea name="purpose" id="purpose" rows="3" required placeholder="Jelaskan keperluan operasional penggunaan unit..." class="w-full rounded-lg border border-slate-300 bg-white px-3.5 py-2.5 text-sm text-slate-800 focus:border-emerald-500 focus:ring-2 focus:ring-emerald-200 transition">{{ old('purpose') }}</textarea>
</div>
<!-- Tombol Aksi -->
<div class="pt-3 border-t border-slate-200 flex items-center space-x-3">
<button type="submit" id="btnSubmit" class="flex-1 bg-emerald-600 hover:bg-emerald-700 text-white font-semibold py-2.5 px-4 rounded-lg shadow-sm transition flex items-center justify-center space-x-2 disabled:bg-slate-300 disabled:text-slate-500 disabled:cursor-not-allowed">
<i class="fa-solid fa-check"></i>
<span>Simpan Timesheet</span>
</button>
<button type="reset" class="bg-slate-100 hover:bg-slate-200 text-slate-700 font-semibold py-2.5 px-4 rounded-lg transition border border-slate-300">
<i class="fa-solid fa-rotate-left mr-1"></i> Reset
</button>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
<script>
document.addEventListener('DOMContentLoaded', function () {
const driverSelect = document.getElementById('driver_id');
const submitBtn = document.getElementById('btnSubmit');
const warningBanner = document.getElementById('simperWarningBanner');
const warningText = document.getElementById('simperWarningText');
const currentKmInput = document.getElementById('current_km');
const distancePreview = document.getElementById('distancePreview');
const previousKm = parseFloat("{{ $vehicle->current_km }}") || 0;
// Validasi SIMPER saat driver dipilih
function checkSimper() {
const selectedOption = driverSelect.options[driverSelect.selectedIndex];
if (!selectedOption || !selectedOption.value) {
warningBanner.classList.add('hidden');
submitBtn.disabled = false;
return;
}
const isValid = selectedOption.getAttribute('data-is-valid') === '1';
const expiredDate = selectedOption.getAttribute('data-expired');
if (!isValid) {
// SIMPER Kedaluwarsa -> Blokir Tombol Submit (BR-01 & BR-02)
warningText.textContent = `SIMPER pengemudi telah kedaluwarsa pada ${expiredDate}. Tombol simpan dinonaktifkan. Pengemudi wajib melakukan perpanjangan SIMPER melalui Divisi HSE.`;
warningBanner.classList.remove('hidden');
submitBtn.disabled = true;
} else {
warningBanner.classList.add('hidden');
submitBtn.disabled = false;
}
}
// Kalkulasi jarak real-time
function calculateDistance() {
const inputKm = parseFloat(currentKmInput.value) || 0;
const diff = Math.max(0, inputKm - previousKm);
distancePreview.textContent = `Estimasi Jarak: ${diff.toLocaleString('id-ID')} KM`;
}
driverSelect.addEventListener('change', checkSimper);
currentKmInput.addEventListener('input', calculateDistance);
// Run check on load
checkSimper();
calculateDistance();
});
</script>
@endsection
+170
View File
@@ -0,0 +1,170 @@
@extends('layouts.app')
@section('title', 'Log Aktivitas Kendaraan QMA - 10 Kolom')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Total Catatan (Persis Format Standar Manajemen Sistem) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
MANAJEMEN SISTEM
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Log Aktivitas Kendaraan
</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="Catatan komprehensif 10 kolom pergerakan armada kendaraan dengan validasi pos gerbang">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<div class="flex items-center space-x-3 w-full sm:w-auto">
<span class="inline-flex items-center px-4 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-clipboard-check mr-2 text-emerald-600"></i> Total: {{ $activities->total() }} Catatan
</span>
</div>
</div>
<!-- Filter Bar -->
<div class="bg-white p-4 rounded-xl border border-slate-200 shadow-sm">
<form method="GET" action="{{ route('qma.activity.log') }}" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3">
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Mulai Tanggal</label>
<input type="date" name="start_date" value="{{ request('start_date') }}" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Sampai Tanggal</label>
<input type="date" name="end_date" value="{{ request('end_date') }}" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Pos Gerbang</label>
<select name="gate_id" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
<option value="">Semua Gerbang</option>
@foreach($gates as $g)
<option value="{{ $g->id }}" {{ request('gate_id') == $g->id ? 'selected' : '' }}>{{ $g->name }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1">Arah Akses</label>
<select name="direction" class="w-full text-xs rounded-lg border-slate-300 border px-3 py-2">
<option value="">Semua Arah</option>
<option value="in" {{ request('direction') === 'in' ? 'selected' : '' }}>MASUK (In)</option>
<option value="out" {{ request('direction') === 'out' ? 'selected' : '' }}>KELUAR (Out)</option>
</select>
</div>
<div class="flex items-end space-x-2">
<button type="submit" class="flex-1 bg-slate-800 hover:bg-slate-900 text-white text-xs font-bold py-2 px-3 rounded-lg transition">
<i class="fa-solid fa-filter mr-1"></i> Filter
</button>
<a href="{{ route('qma.activity.log') }}" class="bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-semibold py-2 px-3 rounded-lg border border-slate-300 transition">
Reset
</a>
</div>
</form>
</div>
<!-- Tabel 10 Kolom Log Aktivitas QMA -->
<div class="bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-200 text-xs text-left">
<thead class="bg-slate-800 text-white font-semibold uppercase tracking-wider">
<tr>
<th class="py-3 px-3 text-center">1. Tanggal</th>
<th class="py-3 px-3 text-center">2. Kode LV</th>
<th class="py-3 px-3">3. Unit</th>
<th class="py-3 px-3">4. Penanggung Jawab</th>
<th class="py-3 px-3">5. Driver</th>
<th class="py-3 px-3 text-center">6. Gate</th>
<th class="py-3 px-3 text-center">7. Akses</th>
<th class="py-3 px-3 text-right">8. KM Sebelumnya</th>
<th class="py-3 px-3 text-right">9. KM Berjalan</th>
<th class="py-3 px-3">10. Aktifitas</th>
<th class="py-3 px-3 text-center">Status PG</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200 text-slate-700 bg-white">
@forelse($activities as $act)
<tr class="hover:bg-slate-50 transition">
<td class="py-3 px-3 text-center font-medium text-slate-600 whitespace-nowrap">
{{ $act->recorded_at->format('d/m/Y H:i') }}
</td>
<td class="py-3 px-3 text-center font-bold text-slate-900 whitespace-nowrap">
<span class="bg-slate-100 px-2 py-0.5 rounded border border-slate-300 font-mono">
{{ $act->vehicle->code }}
</span>
</td>
<td class="py-3 px-3 font-medium text-slate-800">
<div>{{ $act->vehicle->brand_type }}</div>
<span class="text-[10px] text-amber-700 font-mono">{{ $act->vehicle->license_plate ?? '-' }}</span>
</td>
<td class="py-3 px-3 text-slate-600">
{{ $act->vehicle->ownership ?? '-' }}
</td>
<td class="py-3 px-3 font-semibold text-slate-900">
{{ $act->driver->name }}
<div class="text-[10px] text-slate-400 font-normal">{{ $act->driver->division ?? '-' }}</div>
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
<span class="inline-flex items-center px-2 py-0.5 rounded text-[11px] font-medium bg-slate-100 text-slate-700 border border-slate-200">
{{ $act->gate->name }}
</span>
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
@if($act->direction === 'in')
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-100 text-emerald-800 border border-emerald-200">
<i class="fa-solid fa-arrow-right-to-bracket mr-1"></i> MASUK
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-blue-100 text-blue-800 border border-blue-200">
<i class="fa-solid fa-arrow-right-from-bracket mr-1"></i> KELUAR
</span>
@endif
</td>
<td class="py-3 px-3 text-right font-mono font-medium text-slate-600 whitespace-nowrap">
{{ number_format($act->previous_km, 0, ',', '.') }} KM
</td>
<td class="py-3 px-3 text-right font-mono font-bold text-emerald-600 whitespace-nowrap">
+{{ number_format($act->distance, 0, ',', '.') }} KM
<div class="text-[10px] text-slate-400 font-normal">Akhir: {{ number_format($act->current_km, 0, ',', '.') }}</div>
</td>
<td class="py-3 px-3 text-slate-600 max-w-xs truncate" title="{{ $act->purpose }}">
{{ $act->purpose }}
</td>
<td class="py-3 px-3 text-center whitespace-nowrap">
@if($act->validation_status === 'approved')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-300" title="Divalidasi oleh: {{ $act->securityGuard->name ?? 'Satpam' }}">
<i class="fa-solid fa-circle-check mr-1"></i> Disetujui
</span>
@elseif($act->validation_status === 'rejected')
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-rose-50 text-rose-700 border border-rose-300" title="Alasan: {{ $act->rejection_note }}">
<i class="fa-solid fa-circle-xmark mr-1"></i> Ditolak
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-amber-50 text-amber-700 border border-amber-300 animate-pulse">
<i class="fa-solid fa-clock mr-1"></i> Menunggu PG
</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="11" class="py-8 text-center text-slate-400">
<i class="fa-solid fa-inbox text-3xl mb-2 block"></i>
Belum ada catatan aktivitas kendaraan yang sesuai dengan kriteria filter.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $activities->links() }}
</div>
</div>
</div>
@endsection
+58
View File
@@ -0,0 +1,58 @@
@extends('layouts.app')
@section('title', 'Dashboard - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Admin QMA (Gaya Elegan Sistem IT All Role, Selaras dengan Admin HSE) -->
<div class="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-xs font-semibold bg-emerald-100 text-emerald-800">
<i class="fa-solid fa-car mr-1.5"></i> Divisi QMA (Quality Management Asset)
</span>
<span class="text-xs text-slate-400">Sistem Administrator</span>
</div>
<h2 class="text-2xl font-black text-slate-900 tracking-tight mt-1.5">
Selamat datang, {{ auth()->user()->name }}
</h2>
<p class="text-xs text-slate-500 mt-0.5">
Berikut ringkasan operasional aset kendaraan dan pencatatan log aktivitas armada PT Kerinci Merangin Hidro.
</p>
</div>
</div>
<!-- Area Konten Dashboard Sementara Dikosongkan (Placeholder Bersih - Sama seperti Admin HSE) -->
<div class="bg-white rounded-2xl border border-dashed border-slate-300 p-12 text-center shadow-sm">
<div class="w-16 h-16 rounded-2xl bg-emerald-50 text-emerald-700 flex items-center justify-center mx-auto mb-4 border border-emerald-100 shadow-sm">
<i class="fa-solid fa-layer-group text-2xl"></i>
</div>
<h3 class="text-base font-bold text-slate-800">Konten Dashboard Sedang Disiapkan</h3>
<p class="text-xs text-slate-400 max-w-lg mx-auto mt-1.5 leading-relaxed">
Halaman dashboard utama admin QMA untuk sementara dikosongkan sesuai instruksi. Seluruh pengelolaan master kendaraan dialihkan ke menu <strong class="text-slate-600 font-semibold">Data Aset Kendaraan</strong> dan pemantauan pergerakan pos gerbang ke menu <strong class="text-slate-600 font-semibold">Log Aktivitas Kendaraan</strong>.
</p>
<div class="mt-6 flex flex-wrap items-center justify-center gap-3">
<a href="{{ route('qma.vehicles.lv') }}"
class="inline-flex items-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-car"></i>
<span>Buka Light Vehicle</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.vehicles.support') }}"
class="inline-flex items-center space-x-2 bg-blue-700 hover:bg-blue-800 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-tractor"></i>
<span>Buka Unit Support</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.activity.log') }}"
class="inline-flex items-center space-x-2 bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-clipboard-list"></i>
<span>Buka Log Aktivitas Kendaraan</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
</div>
</div>
</div>
@endsection
+727
View File
@@ -0,0 +1,727 @@
@extends('layouts.app')
@section('title', 'Light Vehicle - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
MANAJEMEN SISTEM
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Light Vehicle
</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 master armada kendaraan ringan operasional">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<button type="button"
onclick="alert('Fitur ekspor spreadsheet Light Vehicle sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Light Vehicle</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<button onclick="openAddModal()"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Light Vehicle</span>
</button>
</div>
</div>
<!-- Kotak Pencarian & Filter Status -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<form method="GET" action="{{ route('qma.vehicles.lv') }}" class="relative w-full max-w-sm sm:max-w-md">
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode LV, nopol, merek, tipe, atau pemilik..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</form>
<div class="flex items-center space-x-2">
<form method="GET" action="{{ route('qma.vehicles.lv') }}">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Jalan)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</form>
@if(request('search') || request('status'))
<a href="{{ route('qma.vehicles.lv') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-2">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
<!-- Tabel Data Light Vehicle (Header Navy Solid #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse">
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr>
<th class="py-3.5 px-4 text-center w-12">NO</th>
<th class="py-3.5 px-4">KODE LV</th>
<th class="py-3.5 px-4">MEREK & TIPE</th>
<th class="py-3.5 px-4 text-center">NO. POLISI</th>
<th class="py-3.5 px-4">DIVISI</th>
<th class="py-3.5 px-4">KEPEMILIKAN</th>
<th class="py-3.5 px-4 text-right">ODOMETER</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }}
</td>
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-emerald-50 text-emerald-800 px-2 py-0.5 rounded border border-emerald-200">
{{ $v->code }}
</span>
</td>
<td class="py-3.5 px-4 font-bold text-slate-900">
{{ $v->brand_type }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->license_plate)
<span class="text-[11px] font-mono font-bold text-amber-800 bg-amber-50 px-2 py-0.5 rounded border border-amber-200">
{{ $v->license_plate }}
</span>
@else
<span class="text-slate-400 italic">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-slate-600 font-medium">
{{ $v->division ?? '-' }}
</td>
<td class="py-3.5 px-4 text-slate-600">
{{ $v->ownership ?? '-' }}
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($v->current_km, 0, ',', '.') }}
<span class="text-[10px] text-slate-400 font-sans font-normal">KM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->status === 'Operation')
<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">
<i class="fa-solid fa-circle-check mr-1 text-[9px]"></i> Operation
</span>
@elseif($v->status === 'Standby')
<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">
<i class="fa-solid fa-pause mr-1 text-[9px]"></i> Standby
</span>
@elseif($v->status === 'Breakdown')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-triangle-exclamation mr-1 text-[9px]"></i> Breakdown
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
{{ $v->status }}
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-1.5">
<button onclick='openDetailModal(@json($v))'
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
title="Lihat Detail Kendaraan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<button onclick='openEditModal(@json($v))'
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
title="Edit Data Light Vehicle">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
<button type="button"
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
title="Hapus Kendaraan">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-car text-3xl mb-2 block text-slate-300"></i>
Belum ada armada Light Vehicle yang sesuai dengan kriteria pencarian.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="addVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Light Vehicle
</h3>
<button type="button" onclick="closeAddModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="light_vehicle">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV <span class="text-rose-500">*</span></label>
<input type="text"
name="code"
id="addCodeInput"
required
value="{{ old('code') }}"
placeholder="MISAL: LV01, LV62"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border {{ $errors->has('code') ? 'border-rose-500 ring-2 ring-rose-500/10' : 'border-slate-200' }} bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="codeHint" class="text-[11px] text-slate-400 mt-1 {{ $errors->has('code') ? 'hidden' : '' }}">* Kode LV tidak boleh sama dengan kode aset yang lain.</p>
<p id="codeError" class="text-xs text-rose-600 font-semibold mt-1.5 {{ $errors->has('code') ? '' : 'hidden' }} flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="codeErrorText">{{ $errors->first('code') ?? 'Kode LV sudah ada, silakan gunakan kode lain.' }}</span>
</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<input type="text" name="license_plate" value="{{ old('license_plate') }}" placeholder="Misal: BH 1024 AB"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" required placeholder="Misal: Toyota Hilux 4x4 Double Cabin"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<input type="text" name="division" placeholder="Misal: HSE, Civil, Bendungan, GA"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<input type="text" name="ownership" placeholder="Misal: PT Kerinci Merangin Hidro"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Jalan)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Awal (KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" required value="0"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeAddModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Simpan Light Vehicle
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="editVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Light Vehicle
</h3>
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editVehicleForm" action="" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="light_vehicle">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="editCode" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="editCodeError" class="text-xs text-rose-600 font-semibold mt-1.5 hidden flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="editCodeErrorText">Kode LV sudah ada, silakan gunakan kode lain.</span>
</p>
<p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Kode LV tidak boleh sama dengan kendaraan lain.</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<input type="text" name="license_plate" id="editLicensePlate"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" id="editBrandType" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<input type="text" name="division" id="editDivision"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<input type="text" name="ownership" id="editOwnership"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="editStatus" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Jalan)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini (KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="editCurrentKm" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Perbarui Data
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: DETAIL LIGHT VEHICLE -->
<!-- ========================================================================= -->
<div id="detailVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Card Tambah Data -->
<div class="flex items-center justify-between mb-5">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Light Vehicle
</h3>
<button type="button" onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="space-y-4">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode LV</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center">
<span id="detailCode" class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center uppercase">
<span id="detailNopol">-</span>
</div>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Kendaraan</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailBrand">-</span>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Operasional</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailDivision">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan Aset</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailOwnership">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi</label>
<div class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white flex items-center">
<span id="detailStatusBadge" class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<span id="detailStatus">Operation</span>
</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-emerald-700 font-mono font-bold flex items-center">
<span id="detailKm">0 KM</span>
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end">
<button type="button" onclick="closeDetailModal()"
class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm">
Tutup
</button>
</div>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: KONFIRMASI HAPUS KENDARAAN (LIGHT VEHICLE) -->
<!-- ========================================================================= -->
<div id="deleteVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
<!-- Icon Peringatan Elegan -->
<div class="w-14 h-14 rounded-2xl bg-rose-50 border border-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4 text-2xl shadow-sm">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 tracking-tight">
Konfirmasi Hapus Kendaraan
</h3>
<p class="text-xs text-slate-600 mt-2 leading-relaxed">
Apakah Anda yakin ingin menghapus data kendaraan <span id="deleteVehicleCode" class="font-bold font-mono text-slate-900 bg-slate-100 px-2 py-0.5 rounded border border-slate-200"></span>?
</p>
<p class="text-[11px] text-rose-600 mt-3 bg-rose-50/70 border border-rose-100 py-1.5 px-3 rounded-xl inline-flex items-center">
<i class="fa-solid fa-circle-info mr-1.5 flex-shrink-0 text-xs"></i>
<span>Data yang dihapus tidak dapat dipulihkan kembali.</span>
</p>
<!-- Tombol Aksi -->
<div class="flex items-center space-x-3 mt-6">
<button type="button" onclick="closeDeleteModal()"
class="flex-1 py-2.5 px-4 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<form id="deleteVehicleForm" action="" method="POST" class="flex-1">
@csrf
@method('DELETE')
<button type="submit"
class="w-full py-2.5 px-4 rounded-xl bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs transition shadow-sm flex items-center justify-center space-x-1.5">
<i class="fa-regular fa-trash-can text-xs"></i>
<span>Ya, Hapus Data</span>
</button>
</form>
</div>
</div>
</div>
<script>
// Daftar semua kode kendaraan LV yang sudah terdaftar di sistem
const existingVehicleCodes = @json($existingCodes ?? \App\Models\Vehicle::lightVehicles()->pluck('code')->map(fn($c) => strtoupper(trim($c))));
const addCodeInput = document.getElementById('addCodeInput');
const codeError = document.getElementById('codeError');
const codeErrorText = document.getElementById('codeErrorText');
const codeHint = document.getElementById('codeHint');
const addVehicleForm = document.getElementById('addVehicleForm');
function checkDuplicateCode() {
if (!addCodeInput) return false;
const val = addCodeInput.value.trim().toUpperCase();
if (!val) {
hideCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showCodeError('Kode LV sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideCodeError();
return false;
}
}
function showCodeError(message) {
if (codeErrorText) codeErrorText.innerText = message;
if (codeError) codeError.classList.remove('hidden');
if (codeHint) codeHint.classList.add('hidden');
if (addCodeInput) {
addCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.remove('border-slate-200');
}
}
function hideCodeError() {
if (codeError) codeError.classList.add('hidden');
if (codeHint) codeHint.classList.remove('hidden');
if (addCodeInput) {
addCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.add('border-slate-200');
}
}
if (addCodeInput) {
addCodeInput.addEventListener('input', function() {
if (codeError && !codeError.classList.contains('hidden')) {
checkDuplicateCode();
}
});
addCodeInput.addEventListener('blur', function() {
checkDuplicateCode();
});
}
if (addVehicleForm) {
addVehicleForm.addEventListener('submit', function(e) {
if (checkDuplicateCode()) {
e.preventDefault();
addCodeInput.focus();
return false;
}
});
}
// Elemen modal Edit
const editCodeInput = document.getElementById('editCode');
const editCodeError = document.getElementById('editCodeError');
const editCodeErrorText = document.getElementById('editCodeErrorText');
const editCodeHint = document.getElementById('editCodeHint');
const editVehicleForm = document.getElementById('editVehicleForm');
let currentEditVehicleCode = '';
function checkEditDuplicateCode() {
if (!editCodeInput) return false;
const val = editCodeInput.value.trim().toUpperCase();
if (!val) {
hideEditCodeError();
return false;
}
// Jika kode sama dengan kode kendaraan ini saat ini, maka bukan duplikat
if (val === currentEditVehicleCode) {
hideEditCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showEditCodeError('Kode LV sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideEditCodeError();
return false;
}
}
function showEditCodeError(message) {
if (editCodeErrorText) editCodeErrorText.innerText = message;
if (editCodeError) editCodeError.classList.remove('hidden');
if (editCodeHint) editCodeHint.classList.add('hidden');
if (editCodeInput) {
editCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.remove('border-slate-200');
}
}
function hideEditCodeError() {
if (editCodeError) editCodeError.classList.add('hidden');
if (editCodeHint) editCodeHint.classList.remove('hidden');
if (editCodeInput) {
editCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.add('border-slate-200');
}
}
if (editCodeInput) {
editCodeInput.addEventListener('input', function() {
if (editCodeError && !editCodeError.classList.contains('hidden')) {
checkEditDuplicateCode();
}
});
editCodeInput.addEventListener('blur', function() {
checkEditDuplicateCode();
});
}
if (editVehicleForm) {
editVehicleForm.addEventListener('submit', function(e) {
if (checkEditDuplicateCode()) {
e.preventDefault();
editCodeInput.focus();
return false;
}
});
}
function openAddModal() {
document.getElementById('addVehicleModal').classList.remove('hidden');
if (addCodeInput) addCodeInput.focus();
}
function closeAddModal() {
document.getElementById('addVehicleModal').classList.add('hidden');
hideCodeError();
}
function openEditModal(v) {
document.getElementById('editVehicleModal').classList.remove('hidden');
document.getElementById('editVehicleForm').action = `/qma/vehicles/${v.id}`;
document.getElementById('editCode').value = v.code || '';
currentEditVehicleCode = (v.code || '').trim().toUpperCase();
hideEditCodeError();
document.getElementById('editBrandType').value = v.brand_type || '';
document.getElementById('editLicensePlate').value = v.license_plate || '';
document.getElementById('editDivision').value = v.division || '';
document.getElementById('editOwnership').value = v.ownership || '';
document.getElementById('editStatus').value = v.status || 'Operation';
document.getElementById('editCurrentKm').value = v.current_km || 0;
}
function closeEditModal() {
document.getElementById('editVehicleModal').classList.add('hidden');
hideEditCodeError();
}
function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailBrand').innerText = v.brand_type || '-';
document.getElementById('detailNopol').innerText = v.license_plate || '-';
document.getElementById('detailStatus').innerText = v.status || '-';
document.getElementById('detailKm').innerText = Number(v.current_km || 0).toLocaleString('id-ID') + ' KM';
document.getElementById('detailDivision').innerText = v.division || '-';
document.getElementById('detailOwnership').innerText = v.ownership || '-';
const badge = document.getElementById('detailStatusBadge');
if (badge) {
badge.className = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold border ';
if (v.status === 'Operation') {
badge.className += 'bg-emerald-50 text-emerald-700 border-emerald-200';
} else if (v.status === 'Standby') {
badge.className += 'bg-amber-50 text-amber-700 border-amber-200';
} else if (v.status === 'Breakdown') {
badge.className += 'bg-rose-50 text-rose-700 border-rose-200';
} else {
badge.className += 'bg-slate-100 text-slate-700 border-slate-200';
}
}
}
function closeDetailModal() {
document.getElementById('detailVehicleModal').classList.add('hidden');
}
function openDeleteModal(id, code, brand) {
document.getElementById('deleteVehicleForm').action = `/qma/vehicles/${id}`;
document.getElementById('deleteVehicleCode').innerText = code + (brand ? ` (${brand})` : '');
document.getElementById('deleteVehicleModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteVehicleModal').classList.add('hidden');
}
@if($errors->any())
document.addEventListener('DOMContentLoaded', function() {
openAddModal();
});
@endif
</script>
<style>
/* Hilangkan scrollbar default pada modal */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.no-scrollbar::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera */
width: 0px;
height: 0px;
}
</style>
@endsection
@@ -0,0 +1,953 @@
@extends('layouts.app')
@section('title', 'Unit Support - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="space-y-6">
<!-- Header Judul & Tombol Aksi -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20] block mb-1">
MANAJEMEN SISTEM
</span>
<div class="flex items-center space-x-3">
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Unit Support
</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 armada alat berat, spesifikasi teknis, dan perizinan SILO/KIR">
<i class="fa-solid fa-info"></i>
</span>
</div>
</div>
<!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto">
<button type="button"
onclick="alert('Fitur ekspor spreadsheet Unit Support sedang disiapkan')"
class="border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Unit Support</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button>
<button onclick="openAddModal()"
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Support</span>
</button>
</div>
</div>
<!-- Kotak Pencarian & Filter Kategori Alat Berat -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="relative w-full max-w-sm sm:max-w-md">
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
@if(request('unit_category'))
<input type="hidden" name="unit_category" value="{{ request('unit_category') }}">
@endif
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
<i class="fa-solid fa-magnifying-glass text-xs"></i>
</span>
<input type="text"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode unit, model, tipe, lokasi, dokumen..."
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
</form>
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Kategori Alat Berat -->
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
@if(request('status'))
<input type="hidden" name="status" value="{{ request('status') }}">
@endif
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Kategori Alat</option>
@foreach($availableCategories as $cat)
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
</form>
<!-- Filter Status Operasional -->
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2">
@if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}">
@endif
@if(request('unit_category'))
<input type="hidden" name="unit_category" value="{{ request('unit_category') }}">
@endif
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
<option value="">Semua Status Operasi</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation (Siap Kerja)</option>
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
<option value="Maintenance" {{ request('status') === 'Maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</form>
@if(request('search') || request('status') || request('unit_category'))
<a href="{{ route('qma.vehicles.support') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset</span>
</a>
@endif
</div>
</div>
<!-- Tabel Data Unit Support (Header Navy Solid #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse">
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr>
<th class="py-3.5 px-4 text-center w-12">NO</th>
<th class="py-3.5 px-4">KODE UNIT</th>
<th class="py-3.5 px-4">KATEGORI & MODEL</th>
<th class="py-3.5 px-4">MEREK & SPESIFIKASI</th>
<th class="py-3.5 px-4">LOKASI KERJA</th>
<th class="py-3.5 px-4 text-right">ODOMETER (HM/KM)</th>
<th class="py-3.5 px-4 text-center">DOKUMEN IZIN</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">AKSI</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }}
</td>
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">
{{ $v->code }}
</span>
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-900 block">{{ $v->unit_category ?? 'Alat Berat' }}</span>
<span class="text-[10px] text-slate-500 font-mono">{{ $v->model_number ? "Model: {$v->model_number}" : '-' }}</span>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-900">{{ $v->brand_type }}</div>
<div class="flex items-center space-x-2 mt-0.5 text-[10px] text-slate-500">
@if($v->unit_type)
<span>{{ $v->unit_type }}</span>
@endif
@if($v->production_year)
<span>&bull; Thn {{ $v->production_year }}</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-slate-600">
<div class="font-medium text-slate-800">
@if($v->location)
<i class="fa-solid fa-location-dot text-[9px] mr-1 text-rose-500"></i>{{ $v->location }}
@else
-
@endif
</div>
<span class="text-[10px] text-slate-400 block">{{ $v->division ?? '-' }}</span>
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($v->current_km, 0, ',', '.') }}
<span class="text-[10px] text-slate-400 font-sans font-normal">HM/KM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex flex-col items-center space-y-1">
@if($v->silo_document)
<span class="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-800 border border-emerald-200" title="SILO: {{ $v->silo_document }}">
<i class="fa-solid fa-certificate mr-1 text-[9px] text-emerald-600"></i> SILO Ada
</span>
@else
<span class="text-[10px] text-slate-400 italic">Tanpa SILO</span>
@endif
@if($v->kir_document)
<span class="inline-flex items-center px-1.5 py-0.2 rounded text-[9px] font-mono bg-slate-100 text-slate-600 border border-slate-200">
KIR: {{ $v->kir_document }}
</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($v->status === 'Operation')
<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">
<i class="fa-solid fa-circle-check mr-1 text-[9px]"></i> Operation
</span>
@elseif($v->status === 'Standby')
<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">
<i class="fa-solid fa-pause mr-1 text-[9px]"></i> Standby
</span>
@elseif($v->status === 'Breakdown')
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-screwdriver-wrench mr-1 text-[9px]"></i> Breakdown
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
{{ $v->status }}
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-1.5">
<button onclick='openDetailModal(@json($v))'
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
title="Lihat Detail & Perizinan">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<button onclick='openEditModal(@json($v))'
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
title="Edit Data Unit Support">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
<button type="button"
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
title="Hapus Unit">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-tractor text-3xl mb-2 block text-slate-300"></i>
Belum ada unit alat berat yang sesuai dengan filter.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }}
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: TAMBAH UNIT SUPPORT (KENDARAAN BERAT) -->
<!-- ========================================================================= -->
<div id="addVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Tambah Unit Support
</h3>
<button type="button" onclick="closeAddModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-3">
@csrf
<input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="addCodeInput" required placeholder="MISAL: EX01, CR01, DT05" value="{{ old('code') }}"
class="w-full text-xs px-3.5 py-2 rounded-xl border @error('code') border-rose-500 @else border-slate-200 @enderror bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="codeError" class="text-xs text-rose-600 font-semibold mt-1 flex items-center space-x-1.5 @if(!$errors->has('code')) hidden @endif">
<i class="fa-solid fa-circle-exclamation text-rose-500 text-xs"></i>
<span id="codeErrorText">{{ $errors->first('code') ?? 'Kode unit sudah ada, silakan gunakan kode lain.' }}</span>
</p>
<p id="codeHint" class="text-[11px] text-slate-400 mt-0.5 @if($errors->has('code')) hidden @endif">
* Kode unit unik dan tidak boleh sama dengan kode aset yang lain.
</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kategori Alat Berat <span class="text-rose-500">*</span></label>
<input type="text" name="unit_category" required placeholder="Contoh: Excavator / Mobile Crane / Dump Truck"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Merek & Tipe Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" required placeholder="Contoh: KOMATSU PC200-8 / KATO SR-250R"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Tipe / Model Khusus</label>
<input type="text" name="unit_type" placeholder="Contoh: Hydraulic Excavator / Rough Terrain"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Nomor Model</label>
<input type="text" name="model_number" placeholder="Contoh: PC200-8M0"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Tahun Produksi</label>
<input type="number" name="production_year" placeholder="Contoh: 2021"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Nopol (Jika ada)</label>
<input type="text" name="license_plate" placeholder="Contoh: BH 8412 AA"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Lokasi Kerja Lapangan</label>
<input type="text" name="location" placeholder="Contoh: Beringin Tunggal / CCR DAM / Tunnel"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
<input type="text" name="division" placeholder="Contoh: Civil & Inviro / Mechanical"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset</label>
<input type="text" name="ownership" placeholder="Contoh: PT Kerinci Merangin Hidro"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Kerja)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1">Odometer Awal (HM/KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" required value="0"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Bagian Perizinan & Dokumen -->
<div class="p-3.5 rounded-2xl bg-slate-50 border border-slate-200 space-y-2.5">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan Kelayakan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2.5">
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor SILO (Surat Izin Layak Operasi)</label>
<input type="text" name="silo_document" placeholder="Contoh: SILO-KMH-2024/091"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen KIR</label>
<input type="text" name="kir_document" placeholder="Contoh: KIR-2026/08"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor STNK</label>
<input type="text" name="stnk_document" placeholder="Contoh: STNK-BH-EX01"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Konsumsi BBM (Liter/Jam)</label>
<input type="number" step="0.01" name="fuel_consumption" placeholder="Contoh: 18.5"
class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-200 bg-white">
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-3 flex items-center justify-end space-x-3">
<button type="button" onclick="closeAddModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Simpan Unit Support
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: EDIT UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="editVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Edit Unit Support
</h3>
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<form id="editVehicleForm" action="" method="POST" class="space-y-4">
@csrf
<input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="editCode" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono uppercase">
<p id="editCodeError" class="text-xs text-rose-600 font-semibold mt-1.5 hidden flex items-center">
<i class="fa-solid fa-circle-exclamation mr-1.5 flex-shrink-0"></i>
<span id="editCodeErrorText">Kode unit sudah ada, silakan gunakan kode lain.</span>
</p>
<p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Kode unit unik dan tidak boleh sama dengan kode aset yang lain.</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori Alat Berat <span class="text-rose-500">*</span></label>
<input type="text" name="unit_category" id="editUnitCategory" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Lengkap <span class="text-rose-500">*</span></label>
<input type="text" name="brand_type" id="editBrandType" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tipe / Model Khusus</label>
<input type="text" name="unit_type" id="editUnitType"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Model</label>
<input type="text" name="model_number" id="editModelNumber"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label>
<input type="number" name="production_year" id="editProductionYear"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nopol (Jika ada)</label>
<input type="text" name="license_plate" id="editLicensePlate"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition uppercase font-mono">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label>
<input type="text" name="location" id="editLocation"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi</label>
<input type="text" name="division" id="editDivision"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan</label>
<input type="text" name="ownership" id="editOwnership"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="editStatus" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
<option value="Operation">Operation (Siap Kerja)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer HM/KM <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="editCurrentKm" required
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono">
</div>
</div>
<!-- Bagian Perizinan di Edit -->
<div class="p-4 rounded-2xl bg-slate-50 border border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen SILO</label>
<input type="text" name="silo_document" id="editSiloDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor Dokumen KIR</label>
<input type="text" name="kir_document" id="editKirDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Nomor STNK</label>
<input type="text" name="stnk_document" id="editStnkDocument"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
<div>
<label class="block text-[11px] font-bold text-slate-700 mb-1">Konsumsi BBM (L/Jam)</label>
<input type="number" step="0.01" name="fuel_consumption" id="editFuelConsumption"
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white">
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()"
class="px-5 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<button type="submit"
class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Perbarui Data
</button>
</div>
</form>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: DETAIL UNIT SUPPORT -->
<!-- ========================================================================= -->
<div id="detailVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Card Tambah Data -->
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight">
Detail Unit Support
</h3>
<button type="button" onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="space-y-4">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center">
<span id="detailCode" class="bg-blue-50 text-blue-800 px-2 py-0.5 rounded border border-blue-200">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori & Model</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailCategoryModel">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Merek & Tipe Lengkap</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-bold flex items-center">
<span id="detailBrand">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold flex items-center uppercase">
<span id="detailNopol">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailYear">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailLocation">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailFuel">-</span>
</div>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5">
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi & Kepemilikan</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium flex items-center">
<span id="detailOwnerDiv">-</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi</label>
<div class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white flex items-center">
<span id="detailStatusBadge" class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<span id="detailStatus">Operation</span>
</span>
</div>
</div>
<div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Odometer Saat Ini</label>
<div class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-blue-700 font-mono font-bold flex items-center">
<span id="detailKm">0 HM/KM</span>
</div>
</div>
</div>
<!-- Bagian Legalitas & Perizinan -->
<div class="p-4 rounded-2xl bg-slate-50 border border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs">
<i class="fa-solid fa-file-contract text-emerald-600"></i>
<span>Dokumen Legalitas & Perizinan Kelayakan</span>
</div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor Dokumen SILO</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailSilo">-</span>
</div>
</div>
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor Dokumen KIR</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailKir">-</span>
</div>
</div>
<div>
<span class="text-[11px] font-bold text-slate-700 block mb-1">Nomor STNK</span>
<div class="text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white font-mono font-semibold text-slate-800">
<span id="detailStnk">-</span>
</div>
</div>
</div>
</div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset -->
<div class="pt-4 flex items-center justify-end">
<button type="button" onclick="closeDetailModal()"
class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm">
Tutup
</button>
</div>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- MODAL: KONFIRMASI HAPUS UNIT SUPPORT (KENDARAAN BERAT) -->
<!-- ========================================================================= -->
<div id="deleteVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
<!-- Icon Peringatan Elegan -->
<div class="w-14 h-14 rounded-2xl bg-rose-50 border border-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4 text-2xl shadow-sm">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 tracking-tight">
Konfirmasi Hapus Unit Support
</h3>
<p class="text-xs text-slate-600 mt-2 leading-relaxed">
Apakah Anda yakin ingin menghapus data unit support <span id="deleteVehicleCode" class="font-bold font-mono text-slate-900 bg-slate-100 px-2 py-0.5 rounded border border-slate-200"></span>?
</p>
<p class="text-[11px] text-rose-600 mt-3 bg-rose-50/70 border border-rose-100 py-1.5 px-3 rounded-xl inline-flex items-center">
<i class="fa-solid fa-circle-info mr-1.5 flex-shrink-0 text-xs"></i>
<span>Data yang dihapus tidak dapat dipulihkan kembali.</span>
</p>
<!-- Tombol Aksi -->
<div class="flex items-center space-x-3 mt-6">
<button type="button" onclick="closeDeleteModal()"
class="flex-1 py-2.5 px-4 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
Batal
</button>
<form id="deleteVehicleForm" action="" method="POST" class="flex-1">
@csrf
@method('DELETE')
<button type="submit"
class="w-full py-2.5 px-4 rounded-xl bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs transition shadow-sm flex items-center justify-center space-x-1.5">
<i class="fa-regular fa-trash-can text-xs"></i>
<span>Ya, Hapus Data</span>
</button>
</form>
</div>
</div>
</div>
<script>
// Daftar semua kode kendaraan unit support yang sudah terdaftar di sistem
const existingVehicleCodes = @json($existingCodes ?? \App\Models\Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c))));
const addCodeInput = document.getElementById('addCodeInput');
const codeError = document.getElementById('codeError');
const codeErrorText = document.getElementById('codeErrorText');
const codeHint = document.getElementById('codeHint');
const addVehicleForm = document.getElementById('addVehicleForm');
function checkDuplicateCode() {
if (!addCodeInput) return false;
const val = addCodeInput.value.trim().toUpperCase();
if (!val) {
hideCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showCodeError('Kode unit sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideCodeError();
return false;
}
}
function showCodeError(message) {
if (codeErrorText) codeErrorText.innerText = message;
if (codeError) codeError.classList.remove('hidden');
if (codeHint) codeHint.classList.add('hidden');
if (addCodeInput) {
addCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.remove('border-slate-200');
}
}
function hideCodeError() {
if (codeError) codeError.classList.add('hidden');
if (codeHint) codeHint.classList.remove('hidden');
if (addCodeInput) {
addCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
addCodeInput.classList.add('border-slate-200');
}
}
if (addCodeInput) {
addCodeInput.addEventListener('input', function() {
if (codeError && !codeError.classList.contains('hidden')) {
checkDuplicateCode();
}
});
addCodeInput.addEventListener('blur', function() {
checkDuplicateCode();
});
}
if (addVehicleForm) {
addVehicleForm.addEventListener('submit', function(e) {
if (checkDuplicateCode()) {
e.preventDefault();
addCodeInput.focus();
return false;
}
});
}
// Elemen modal Edit Unit Support
const editCodeInput = document.getElementById('editCode');
const editCodeError = document.getElementById('editCodeError');
const editCodeErrorText = document.getElementById('editCodeErrorText');
const editCodeHint = document.getElementById('editCodeHint');
const editVehicleForm = document.getElementById('editVehicleForm');
let currentEditVehicleCode = '';
function checkEditDuplicateCode() {
if (!editCodeInput) return false;
const val = editCodeInput.value.trim().toUpperCase();
if (!val) {
hideEditCodeError();
return false;
}
// Jika kode sama dengan kode kendaraan yang sedang diedit, bukan duplikat
if (val === currentEditVehicleCode) {
hideEditCodeError();
return false;
}
if (existingVehicleCodes.includes(val)) {
showEditCodeError('Kode unit sudah ada, silakan gunakan kode lain.');
return true;
} else {
hideEditCodeError();
return false;
}
}
function showEditCodeError(message) {
if (editCodeErrorText) editCodeErrorText.innerText = message;
if (editCodeError) editCodeError.classList.remove('hidden');
if (editCodeHint) editCodeHint.classList.add('hidden');
if (editCodeInput) {
editCodeInput.classList.add('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.remove('border-slate-200');
}
}
function hideEditCodeError() {
if (editCodeError) editCodeError.classList.add('hidden');
if (editCodeHint) editCodeHint.classList.remove('hidden');
if (editCodeInput) {
editCodeInput.classList.remove('border-rose-500', 'ring-2', 'ring-rose-500/10');
editCodeInput.classList.add('border-slate-200');
}
}
if (editCodeInput) {
editCodeInput.addEventListener('input', function() {
if (editCodeError && !editCodeError.classList.contains('hidden')) {
checkEditDuplicateCode();
}
});
editCodeInput.addEventListener('blur', function() {
checkEditDuplicateCode();
});
}
if (editVehicleForm) {
editVehicleForm.addEventListener('submit', function(e) {
if (checkEditDuplicateCode()) {
e.preventDefault();
editCodeInput.focus();
return false;
}
});
}
function openAddModal() {
document.getElementById('addVehicleModal').classList.remove('hidden');
if (addCodeInput) addCodeInput.focus();
}
function closeAddModal() {
document.getElementById('addVehicleModal').classList.add('hidden');
hideCodeError();
}
function openEditModal(v) {
document.getElementById('editVehicleModal').classList.remove('hidden');
document.getElementById('editVehicleForm').action = `/qma/vehicles/${v.id}`;
document.getElementById('editCode').value = v.code || '';
currentEditVehicleCode = (v.code || '').trim().toUpperCase();
hideEditCodeError();
document.getElementById('editUnitCategory').value = v.unit_category || '';
document.getElementById('editBrandType').value = v.brand_type || '';
document.getElementById('editUnitType').value = v.unit_type || '';
document.getElementById('editModelNumber').value = v.model_number || '';
document.getElementById('editProductionYear').value = v.production_year || '';
document.getElementById('editLicensePlate').value = v.license_plate || '';
document.getElementById('editLocation').value = v.location || '';
document.getElementById('editDivision').value = v.division || '';
document.getElementById('editOwnership').value = v.ownership || '';
document.getElementById('editStatus').value = v.status || 'Operation';
document.getElementById('editCurrentKm').value = v.current_km || 0;
document.getElementById('editSiloDocument').value = v.silo_document || '';
document.getElementById('editKirDocument').value = v.kir_document || '';
document.getElementById('editStnkDocument').value = v.stnk_document || '';
document.getElementById('editFuelConsumption').value = v.fuel_consumption || '';
}
function closeEditModal() {
document.getElementById('editVehicleModal').classList.add('hidden');
hideEditCodeError();
}
function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailBrand').innerText = v.brand_type || '-';
document.getElementById('detailCategoryModel').innerText = (v.unit_category || '-') + (v.model_number ? ` (${v.model_number})` : '');
document.getElementById('detailStatus').innerText = v.status || '-';
document.getElementById('detailLocation').innerText = v.location || '-';
document.getElementById('detailKm').innerText = Number(v.current_km || 0).toLocaleString('id-ID') + ' HM/KM';
document.getElementById('detailYear').innerText = v.production_year || '-';
document.getElementById('detailFuel').innerText = v.fuel_consumption ? `${v.fuel_consumption} L/Jam` : '-';
document.getElementById('detailOwnerDiv').innerText = (v.division || '-') + ' / ' + (v.ownership || '-');
document.getElementById('detailSilo').innerText = v.silo_document || '-';
document.getElementById('detailKir').innerText = v.kir_document || '-';
document.getElementById('detailStnk').innerText = v.stnk_document || '-';
document.getElementById('detailNopol').innerText = v.license_plate || '-';
const badge = document.getElementById('detailStatusBadge');
if (badge) {
badge.className = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold border ';
if (v.status === 'Operation') {
badge.className += 'bg-emerald-50 text-emerald-700 border-emerald-200';
} else if (v.status === 'Standby') {
badge.className += 'bg-amber-50 text-amber-700 border-amber-200';
} else if (v.status === 'Breakdown') {
badge.className += 'bg-rose-50 text-rose-700 border-rose-200';
} else {
badge.className += 'bg-slate-100 text-slate-700 border-slate-200';
}
}
}
function closeDetailModal() {
document.getElementById('detailVehicleModal').classList.add('hidden');
}
function openDeleteModal(id, code, brand) {
document.getElementById('deleteVehicleForm').action = `/qma/vehicles/${id}`;
document.getElementById('deleteVehicleCode').innerText = code + (brand ? ` (${brand})` : '');
document.getElementById('deleteVehicleModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteVehicleModal').classList.add('hidden');
}
@if($errors->any())
document.addEventListener('DOMContentLoaded', function() {
openAddModal();
});
@endif
</script>
<style>
/* Hilangkan scrollbar default pada modal tapi tetap bisa di-scroll secara halus */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.no-scrollbar::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera */
width: 0px;
height: 0px;
}
</style>
@endsection
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
+90
View File
@@ -0,0 +1,90 @@
<?php
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Hse\EmployeeController;
use App\Http\Controllers\Pg\GateInspectionController;
use App\Http\Controllers\Pg\SecurityGuardController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\Public\VehicleActivityFormController;
use App\Http\Controllers\Qma\ActivityLogController;
use App\Http\Controllers\Qma\VehicleController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
// Redirect root
Route::get('/', function () {
if (Auth::check()) {
/** @var \App\Models\User $user */
$user = Auth::user();
return match ($user->role) {
'hse_admin' => redirect()->route('hse.dashboard'),
'qma_admin' => redirect()->route('qma.dashboard'),
'pg_admin' => redirect()->route('pg.guards.index'),
'gate_officer' => redirect()->route('pg.gate.inspection'),
default => redirect()->route('qma.dashboard'),
};
}
return redirect()->route('login');
});
// Autentikasi Pengguna (Login & Logout)
Route::middleware('guest')->group(function () {
Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/login', [LoginController::class, 'login'])->name('login.post');
});
Route::post('/logout', [LoginController::class, 'logout'])->name('logout')->middleware('auth');
// 1. Modul Publik: Form Pencatatan Aktivitas Kendaraan Ringan (Via Scan QR Code di Lapangan)
Route::prefix('gate-activity')->name('vehicle.activity.')->group(function () {
Route::get('/{code}', [VehicleActivityFormController::class, 'show'])->name('form');
Route::post('/{code}', [VehicleActivityFormController::class, 'store'])->name('store');
});
// Group Terproteksi Autentikasi Sistem
Route::middleware('auth')->group(function () {
// 2. Modul HSE: Admin HSE (Mima - 1185) - Kelola Karyawan & SIMPER
Route::prefix('hse')->name('hse.')->middleware('role:hse_admin')->group(function () {
Route::get('/dashboard', [EmployeeController::class, 'dashboard'])->name('dashboard');
Route::get('/employees', [EmployeeController::class, 'index'])->name('employees.index');
Route::post('/employees', [EmployeeController::class, 'store'])->name('employees.store');
Route::post('/employees/{id}', [EmployeeController::class, 'update'])->name('employees.update');
});
// 3. Modul QMA: Admin QMA (Pinto Yuliandra - 1171) - Dashboard, Data Kendaraan & Log Aktivitas
Route::prefix('qma')->name('qma.')->middleware('role:qma_admin')->group(function () {
Route::get('/dashboard', [VehicleController::class, 'dashboard'])->name('dashboard');
// Halaman Data Kendaraan Terpisah: Light Vehicle (LV) dan Unit Support
Route::get('/vehicles', [VehicleController::class, 'index'])->name('vehicles.index');
Route::get('/vehicles/light-vehicle', [VehicleController::class, 'indexLv'])->name('vehicles.lv');
Route::get('/vehicles/unit-support', [VehicleController::class, 'indexSupport'])->name('vehicles.support');
Route::post('/vehicles', [VehicleController::class, 'store'])->name('vehicles.store');
Route::post('/vehicles/{id}', [VehicleController::class, 'update'])->name('vehicles.update');
Route::delete('/vehicles/{id}', [VehicleController::class, 'destroy'])->name('vehicles.destroy');
Route::get('/activity-log', [ActivityLogController::class, 'index'])->name('activity.log');
});
// 4. Modul Private Guard (PG): Admin PG (Admin PG - AdminPG) & Pos Gerbang Satpam
Route::prefix('pg')->name('pg.')->group(function () {
// Master Satpam (Hanya Admin PG)
Route::middleware('role:pg_admin')->group(function () {
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index');
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store');
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle');
});
// Verifikasi Pos Gerbang (Petugas Pos Gerbang & Admin PG)
Route::middleware('role:gate_officer,pg_admin')->group(function () {
Route::get('/gate-inspection', [GateInspectionController::class, 'index'])->name('gate.inspection');
Route::post('/gate-inspection/{id}/approve', [GateInspectionController::class, 'approve'])->name('gate.approve');
Route::post('/gate-inspection/{id}/reject', [GateInspectionController::class, 'reject'])->name('gate.reject');
});
});
// 5. Modul Profil Saya (Seluruh Pengguna Terautentikasi)
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
});
+4
View File
@@ -0,0 +1,4 @@
*
!private/
!public/
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+9
View File
@@ -0,0 +1,9 @@
compiled.php
config.php
down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json
+3
View File
@@ -0,0 +1,3 @@
*
!data/
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+222
View File
@@ -0,0 +1,222 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AuthenticationTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed();
}
/**
* Memastikan halaman login dapat diakses publik.
*/
public function test_login_page_renders_successfully(): void
{
$response = $this->get('/login');
$response->assertStatus(200);
$response->assertSee('PLTA Merangin 350 MW');
$response->assertSee('Username');
$response->assertSee('Password');
}
/**
* Memastikan Admin HSE (Mima - 1185) dapat login dan diarahkan ke dashboard HSE.
*/
public function test_admin_hse_can_login_and_redirects_to_hse_module(): void
{
$response = $this->post('/login', [
'username' => '1185',
'password' => 'password',
]);
$response->assertRedirect('/hse/dashboard');
$this->assertAuthenticated();
$user = auth()->user();
$this->assertEquals('1185', $user->username);
$this->assertEquals('Mima', $user->name);
$this->assertEquals('hse_admin', $user->role);
}
/**
* Memastikan Admin QMA (Pinto Yuliandra - 1171) dapat login dan diarahkan ke Log QMA.
*/
public function test_admin_qma_can_login_and_redirects_to_qma_module(): void
{
$response = $this->post('/login', [
'username' => '1171',
'password' => 'password',
]);
$response->assertRedirect('/qma/dashboard');
$this->assertAuthenticated();
$user = auth()->user();
$this->assertEquals('1171', $user->username);
$this->assertEquals('Pinto Yuliandra', $user->name);
$this->assertEquals('qma_admin', $user->role);
}
/**
* Memastikan Admin PG (Admin PG - AdminPG) dapat login dan diarahkan ke Master Satpam PG.
*/
public function test_admin_pg_can_login_and_redirects_to_pg_module(): void
{
$response = $this->post('/login', [
'username' => 'AdminPG',
'password' => 'password',
]);
$response->assertRedirect('/pg/guards');
$this->assertAuthenticated();
$user = auth()->user();
$this->assertEquals('AdminPG', $user->username);
$this->assertEquals('Admin PG', $user->name);
$this->assertEquals('pg_admin', $user->role);
}
/**
* Memastikan login gagal dengan pesan error jika kredensial tidak cocok.
*/
public function test_login_fails_with_invalid_credentials(): void
{
$response = $this->post('/login', [
'username' => '1185',
'password' => 'salah-password',
]);
$response->assertSessionHasErrors('username');
$this->assertGuest();
}
/**
* Memastikan Role-Based Access Control (RBAC) melindungi rute secara ketat.
*/
public function test_role_based_access_control_protection(): void
{
$hseUser = User::where('username', '1185')->first();
$qmaUser = User::where('username', '1171')->first();
$pgUser = User::where('username', 'AdminPG')->first();
// 1. Guest mencoba akses rute terproteksi -> dialihkan ke login
$this->get('/hse/employees')->assertRedirect('/login');
$this->get('/qma/activity-log')->assertRedirect('/login');
$this->get('/pg/guards')->assertRedirect('/login');
// 2. Admin HSE dapat akses modul HSE, ditolak dari modul QMA & PG
$this->actingAs($hseUser)->get('/hse/employees')->assertStatus(200);
$this->actingAs($hseUser)->get('/qma/activity-log')->assertStatus(403);
$this->actingAs($hseUser)->get('/pg/guards')->assertStatus(403);
// 3. Admin QMA dapat akses modul QMA, ditolak dari modul HSE & PG
$this->actingAs($qmaUser)->get('/qma/activity-log')->assertStatus(200);
$this->actingAs($qmaUser)->get('/hse/employees')->assertStatus(403);
$this->actingAs($qmaUser)->get('/pg/guards')->assertStatus(403);
// 4. Admin PG dapat akses modul PG guards & gate inspection, ditolak dari HSE
$this->actingAs($pgUser)->get('/pg/guards')->assertStatus(200);
$this->actingAs($pgUser)->get('/pg/gate-inspection')->assertStatus(200);
$this->actingAs($pgUser)->get('/hse/employees')->assertStatus(403);
}
/**
* Memastikan Admin HSE dapat mengedit data karyawan & SIMPER.
*/
public function test_admin_hse_can_edit_employee_simper_data(): void
{
$hseUser = User::where('username', '1185')->first();
$employee = \App\Models\Employee::first();
$response = $this->actingAs($hseUser)->post("/hse/employees/{$employee->id}", [
'nik' => $employee->nik,
'name' => 'Nama Karyawan Diperbarui',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Senior Technician',
'is_operator' => '1',
'simper_expired_at' => '2028-12-31',
]);
$response->assertSessionHas('success');
$employee->refresh();
$this->assertEquals('Nama Karyawan Diperbarui', $employee->name);
$this->assertEquals('Senior Technician', $employee->position);
$this->assertEquals('2028-12-31', $employee->simper_expired_at->format('Y-m-d'));
}
/**
* Memastikan jika bukan driver maka tanggal SIMPER otomatis bernilai null.
*/
public function test_non_driver_employee_has_null_simper_date(): void
{
$hseUser = User::where('username', '1185')->first();
$employee = \App\Models\Employee::first();
$response = $this->actingAs($hseUser)->post("/hse/employees/{$employee->id}", [
'nik' => $employee->nik,
'name' => $employee->name,
'unit_kerja' => $employee->unit_kerja,
'division' => $employee->division,
'position' => 'Staff Keuangan',
'is_operator' => '0',
'simper_expired_at' => '2029-01-01',
]);
$response->assertSessionHas('success');
$employee->refresh();
$this->assertFalse((bool) $employee->is_operator);
$this->assertNull($employee->simper_expired_at);
}
/**
* Memastikan user dapat logout dengan aman.
*/
public function test_authenticated_user_can_logout(): void
{
$user = User::where('username', '1185')->first();
$response = $this->actingAs($user)->post('/logout');
$response->assertRedirect('/login');
$this->assertGuest();
}
/**
* Memastikan halaman profil dapat diakses oleh pengguna yang login.
*/
public function test_authenticated_user_can_access_and_update_profile(): void
{
$user = User::where('username', '1185')->first();
// Guest dilarang akses
$this->get('/profile')->assertRedirect('/login');
// User terautentikasi dapat melihat halaman profil
$this->actingAs($user)
->get('/profile')
->assertStatus(200)
->assertSee('Profil Saya');
// User dapat memperbarui nama & email
$response = $this->actingAs($user)->put('/profile', [
'name' => 'Mima HSE Updated',
'email' => '[email protected]',
]);
$response->assertSessionHas('success');
$user->refresh();
$this->assertEquals('Mima HSE Updated', $user->name);
$this->assertEquals('[email protected]', $user->email);
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertRedirect('/login');
}
}
+243
View File
@@ -0,0 +1,243 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Models\Vehicle;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class QmaModuleTest extends TestCase
{
use RefreshDatabase;
protected User $qmaAdmin;
protected User $hseAdmin;
protected function setUp(): void
{
parent::setUp();
$this->qmaAdmin = User::factory()->create([
'name' => 'Pinto Yuliandra',
'username' => '1171',
'role' => 'qma_admin',
]);
$this->hseAdmin = User::factory()->create([
'name' => 'Mima',
'username' => '1185',
'role' => 'hse_admin',
]);
}
/**
* Memastikan QMA dashboard dapat diakses oleh Admin QMA.
*/
public function test_qma_dashboard_renders_successfully(): void
{
$response = $this->actingAs($this->qmaAdmin)->get('/qma/dashboard');
$response->assertStatus(200);
$response->assertSee('Divisi QMA (Quality Management Asset)');
$response->assertSee('Selamat datang, Pinto Yuliandra');
$response->assertSee('Light Vehicle');
$response->assertSee('Unit Support');
$response->assertSee('Log Aktivitas Kendaraan');
}
/**
* Memastikan route /qma/vehicles redirect ke /qma/vehicles/light-vehicle.
*/
public function test_qma_vehicles_index_redirects_to_lv(): void
{
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles');
$response->assertRedirect('/qma/vehicles/light-vehicle');
}
/**
* Memastikan halaman khusus Light Vehicle (LV) memuat armada LV.
*/
public function test_qma_lv_page_renders_successfully(): void
{
Vehicle::create([
'code' => 'LV99',
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux 4x4',
'license_plate' => 'BH 1234 XY',
'ownership' => 'PT KMH',
'status' => 'Operation',
'current_km' => 10000,
]);
Vehicle::create([
'code' => 'EX99',
'category' => 'unit_support',
'brand_type' => 'Komatsu PC200',
'unit_category' => 'Excavator',
'ownership' => 'PT KMH Project',
'status' => 'Standby',
'current_km' => 2500,
]);
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/light-vehicle');
$response->assertStatus(200);
$response->assertSee('Light Vehicle');
$response->assertSee('LV99');
$response->assertDontSee('EX99');
}
/**
* Memastikan halaman khusus Unit Support memuat armada alat berat.
*/
public function test_qma_unit_support_page_renders_successfully(): void
{
Vehicle::create([
'code' => 'LV99',
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux 4x4',
'license_plate' => 'BH 1234 XY',
'ownership' => 'PT KMH',
'status' => 'Operation',
'current_km' => 10000,
]);
Vehicle::create([
'code' => 'EX99',
'category' => 'unit_support',
'brand_type' => 'Komatsu PC200',
'unit_category' => 'Excavator',
'ownership' => 'PT KMH Project',
'status' => 'Standby',
'current_km' => 2500,
]);
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/unit-support');
$response->assertStatus(200);
$response->assertSee('Unit Support');
$response->assertSee('EX99');
$response->assertDontSee('LV99');
}
/**
* Memastikan Admin QMA dapat menambah kendaraan ringan baru.
*/
public function test_admin_qma_can_store_light_vehicle(): void
{
$response = $this->actingAs($this->qmaAdmin)->post('/qma/vehicles', [
'code' => 'LV77',
'category' => 'light_vehicle',
'brand_type' => 'Isuzu D-Max',
'license_plate' => 'BH 5555 ZZ',
'ownership' => 'PT KMH Divisi HSE',
'division' => 'HSE',
'status' => 'Operation',
'current_km' => 1500,
]);
$response->assertSessionHas('success');
$this->assertDatabaseHas('vehicles', [
'code' => 'LV77',
'category' => 'light_vehicle',
'license_plate' => 'BH 5555 ZZ',
]);
}
/**
* Memastikan Admin QMA dapat menambah unit support baru dengan dokumen teknis.
*/
public function test_admin_qma_can_store_unit_support(): void
{
$response = $this->actingAs($this->qmaAdmin)->post('/qma/vehicles', [
'code' => 'DZ01',
'category' => 'unit_support',
'brand_type' => 'Caterpillar D6R',
'unit_category' => 'Bulldozer',
'unit_type' => 'Track-type Tractor',
'brand' => 'Caterpillar',
'model_number' => 'D6R XL',
'production_year' => 2020,
'ownership' => 'PT KMH',
'division' => 'Civil',
'location' => 'CCR DAM',
'status' => 'Operation',
'current_km' => 4500,
'fuel_consumption' => 22.5,
'silo_document' => 'SILO-2026/01',
'kir_document' => 'KIR-2026/01',
]);
$response->assertSessionHas('success');
$this->assertDatabaseHas('vehicles', [
'code' => 'DZ01',
'category' => 'unit_support',
'unit_category' => 'Bulldozer',
'silo_document' => 'SILO-2026/01',
]);
}
/**
* Memastikan Admin QMA dapat mengupdate kendaraan.
*/
public function test_admin_qma_can_update_vehicle(): void
{
$vehicle = Vehicle::create([
'code' => 'LV50',
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux',
'status' => 'Standby',
'current_km' => 3000,
]);
$response = $this->actingAs($this->qmaAdmin)->post("/qma/vehicles/{$vehicle->id}", [
'code' => 'LV50',
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux Facelift',
'status' => 'Operation',
'current_km' => 3500,
]);
$response->assertSessionHas('success');
$this->assertDatabaseHas('vehicles', [
'id' => $vehicle->id,
'brand_type' => 'Toyota Hilux Facelift',
'status' => 'Operation',
'current_km' => 3500,
]);
}
/**
* Memastikan penghapusan kendaraan terlindungi jika tidak ada relasi aktivitas.
*/
public function test_vehicle_deletion_protection_when_activities_exist(): void
{
$vehicle = Vehicle::create([
'code' => 'LV05',
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux',
'status' => 'Operation',
'current_km' => 1000,
]);
$response = $this->actingAs($this->qmaAdmin)->delete("/qma/vehicles/{$vehicle->id}");
$response->assertSessionHas('success');
$this->assertDatabaseMissing('vehicles', ['id' => $vehicle->id]);
}
/**
* Memastikan role selain QMA Admin ditolak dari rute QMA.
*/
public function test_unauthorized_role_cannot_access_qma_routes(): void
{
$response = $this->actingAs($this->hseAdmin)->get('/qma/dashboard');
$response->assertStatus(403);
$responseLv = $this->actingAs($this->hseAdmin)->get('/qma/vehicles/light-vehicle');
$responseLv->assertStatus(403);
$responseSupport = $this->actingAs($this->hseAdmin)->get('/qma/vehicles/unit-support');
$responseSupport->assertStatus(403);
}
}
+185
View File
@@ -0,0 +1,185 @@
<?php
namespace Tests\Feature;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\User;
use App\Models\Vehicle;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class VehicleActivityTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
// Seed data dasar
$this->seed();
}
public function test_form_qr_loads_successfully_for_light_vehicle(): void
{
$response = $this->get('/gate-activity/LV62');
$response->assertStatus(200);
$response->assertSee('Input Timesheet Unit');
$response->assertSee('LV62');
$response->assertSee('MITSUBISHI - L300 - PICK UP');
}
public function test_submit_blocked_if_driver_simper_is_expired(): void
{
$vehicle = Vehicle::where('code', 'LV62')->first();
$gate = Gate::first();
// Driver dengan SIMPER kedaluwarsa (Randi Kurniawan)
$expiredDriver = Employee::where('nik', 'KMH-2023-012')->first();
$response = $this->post("/gate-activity/{$vehicle->code}", [
'driver_id' => $expiredDriver->id,
'gate_id' => $gate->id,
'direction' => 'out',
'current_km' => 12600,
'purpose' => 'Inspeksi Adit 1',
]);
$response->assertSessionHasErrors('driver_id');
$this->assertDatabaseMissing('vehicle_activities', [
'vehicle_id' => $vehicle->id,
'driver_id' => $expiredDriver->id,
]);
}
public function test_submit_blocked_if_odometer_is_less_than_previous(): void
{
$vehicle = Vehicle::where('code', 'LV62')->first(); // current_km: 12500
$gate = Gate::first();
$validDriver = Employee::where('nik', 'KMH-2022-001')->first(); // Eka Sufiatna (SIMPER Aktif)
// Coba input KM lebih kecil dari 12500
$response = $this->post("/gate-activity/{$vehicle->code}", [
'driver_id' => $validDriver->id,
'gate_id' => $gate->id,
'direction' => 'out',
'current_km' => 12400, // Error: < 12500
'purpose' => 'Perjalanan dinas',
]);
$response->assertSessionHasErrors('current_km');
}
public function test_submit_successful_with_valid_data_and_enforces_alternating_direction(): void
{
$vehicle = Vehicle::where('code', 'LV62')->first(); // current_km: 12500
$gate = Gate::first();
$validDriver = Employee::where('nik', 'KMH-2022-001')->first();
// 1. Transaksi pertama: KELUAR (Out)
$response1 = $this->post("/gate-activity/{$vehicle->code}", [
'driver_id' => $validDriver->id,
'gate_id' => $gate->id,
'direction' => 'out',
'current_km' => 12550,
'purpose' => 'Antar teknisi ke Power House',
]);
$response1->assertRedirect();
$this->assertDatabaseHas('vehicle_activities', [
'vehicle_id' => $vehicle->id,
'driver_id' => $validDriver->id,
'direction' => 'out',
'current_km' => 12550,
'validation_status' => 'pending',
]);
// 2. Coba kirim KELUAR (Out) lagi -> Wajib Ditolak karena harus MASUK (In)!
$response2 = $this->post("/gate-activity/{$vehicle->code}", [
'driver_id' => $validDriver->id,
'gate_id' => $gate->id,
'direction' => 'out', // Error: Harus 'in'
'current_km' => 12580,
'purpose' => 'Coba keluar lagi',
]);
$response2->assertSessionHasErrors('direction');
// 3. Kirim MASUK (In) -> Berhasil!
$response3 = $this->post("/gate-activity/{$vehicle->code}", [
'driver_id' => $validDriver->id,
'gate_id' => $gate->id,
'direction' => 'in',
'current_km' => 12600,
'purpose' => 'Kembali ke kantor',
]);
$response3->assertRedirect();
$this->assertDatabaseHas('vehicle_activities', [
'vehicle_id' => $vehicle->id,
'direction' => 'in',
'current_km' => 12600,
]);
}
public function test_security_guard_can_approve_activity_and_updates_master_odometer(): void
{
$vehicle = Vehicle::where('code', 'LV62')->first();
$gate = Gate::first();
$validDriver = Employee::where('nik', 'KMH-2022-001')->first();
$guard = SecurityGuard::first();
$activity = VehicleActivity::create([
'transaction_no' => 'TRX-TEST-001',
'vehicle_id' => $vehicle->id,
'driver_id' => $validDriver->id,
'gate_id' => $gate->id,
'direction' => 'out',
'previous_km' => 12500,
'current_km' => 12580,
'distance' => 80,
'purpose' => 'Perjalanan dinas Adit 2',
'recorded_at' => Carbon::now(),
'validation_status' => 'pending',
]);
// Satpam approve (Petugas Pos Gerbang login)
$gateOfficer = User::where('role', 'gate_officer')->first();
$response = $this->actingAs($gateOfficer)->post("/pg/gate-inspection/{$activity->id}/approve", [
'security_guard_id' => $guard->id,
]);
$response->assertRedirect();
// Verifikasi status transaksi
$this->assertDatabaseHas('vehicle_activities', [
'id' => $activity->id,
'validation_status' => 'approved',
'security_guard_id' => $guard->id,
]);
// Verifikasi master odometer terupdate
$this->assertEquals(12580, (float) $vehicle->fresh()->current_km);
}
public function test_qma_log_renders_10_columns(): void
{
$qmaAdmin = User::where('role', 'qma_admin')->first();
$response = $this->actingAs($qmaAdmin)->get('/qma/activity-log');
$response->assertStatus(200);
$response->assertSee('Log Aktivitas Kendaraan QMA');
$response->assertSee('1. Tanggal');
$response->assertSee('2. Kode LV');
$response->assertSee('3. Unit');
$response->assertSee('4. Penanggung Jawab');
$response->assertSee('5. Driver');
$response->assertSee('6. Gate');
$response->assertSee('7. Akses');
$response->assertSee('8. KM Sebelumnya');
$response->assertSee('9. KM Berjalan');
$response->assertSee('10. Aktifitas');
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
+18
View File
@@ -0,0 +1,18 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
tailwindcss(),
],
server: {
watch: {
ignored: ['**/storage/framework/views/**'],
},
},
});