feat: setup Docker production stack, Vite asset compilation, and resolve audit findings (P1/P2)

This commit is contained in:
Wahyudin
2026-10-15 13:53:52 +07:00
parent 9c00515a73
commit 38c70f9413
65 changed files with 13315 additions and 933 deletions
+20
View File
@@ -0,0 +1,20 @@
.git
.github
.idea
.vscode
node_modules
npm-debug.log
yarn-error.log
storage/logs/*.log
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
bootstrap/cache/*
.env
.env.backup
.env.production
.phpunit.result.cache
tests
Homestead.json
Homestead.yaml
Thumbs.db
+61
View File
@@ -0,0 +1,61 @@
# =============================================================================
# ENVIRONMENT CONFIGURATION FOR DOCKER DEPLOYMENT
# SISTEM RKM - PT KERINCI MERANGIN HIDRO (PLTA MERANGIN 350 MW)
# =============================================================================
APP_NAME="Sistem RKM - PT Kerinci Merangin Hidro"
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost
APP_PORT=80
APP_LOCALE=id
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=id_ID
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=warning
# -----------------------------------------------------------------------------
# DATABASE CONFIGURATION (DOCKER MYSQL 8.0)
# -----------------------------------------------------------------------------
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=rkm_kmh
DB_USERNAME=rkm_user
DB_PASSWORD=rkm_secret_password
DB_ROOT_PASSWORD=root_secret_password
FORWARD_DB_PORT=3306
# Flag to seed master data on first launch (set to true on initial deploy)
RUN_SEEDER=false
# -----------------------------------------------------------------------------
# SESSION & CACHE CONFIGURATION
# -----------------------------------------------------------------------------
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
SESSION_SECURE_COOKIE=false
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
# -----------------------------------------------------------------------------
# MAIL CONFIGURATION
# -----------------------------------------------------------------------------
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}"
+85
View File
@@ -0,0 +1,85 @@
# =========================================================================
# STAGE 1: Frontend Asset Compilation via Vite & Node.js
# =========================================================================
FROM node:22-alpine AS frontend-builder
WORKDIR /app
# Copy dependency manifests
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci || npm install
# Copy source assets needed for compilation
COPY vite.config.js ./
COPY resources/ ./resources/
# Compile production assets into /app/public/build
RUN npm run build
# =========================================================================
# STAGE 2: PHP 8.2-FPM Alpine Production Runtime
# =========================================================================
FROM php:8.2-fpm-alpine AS app
# Set working directory
WORKDIR /var/www
# Install system dependencies & build tools
RUN apk add --no-cache \
curl \
netcat-openbsd \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libzip-dev \
oniguruma-dev \
icu-dev \
mysql-client
# Configure and install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
intl \
opcache
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Copy PHP & OPcache custom configs
COPY docker/php/local.ini /usr/local/etc/php/conf.d/local.ini
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# Copy entrypoint script
COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Copy application source code
COPY . /var/www
# Copy compiled frontend assets from Stage 1 (Overrides public/build)
COPY --from=frontend-builder /app/public/build /var/www/public/build
# Install Composer production dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Set correct permissions for Laravel directories
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache
# Expose FastCGI port
EXPOSE 9000
# Set entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
# Start PHP-FPM
CMD ["php-fpm"]
@@ -72,11 +72,13 @@ class LoginController extends Controller
private function redirectBasedOnRole($user): RedirectResponse private function redirectBasedOnRole($user): RedirectResponse
{ {
return match ($user->role) { return match ($user->role) {
'super_admin', 'superadmin', 'admin' => redirect()->route('superadmin.dashboard'),
'hse_admin' => redirect()->route('hse.dashboard'), 'hse_admin' => redirect()->route('hse.dashboard'),
'qma_admin' => redirect()->route('qma.dashboard'), 'qma_admin' => redirect()->route('qma.dashboard'),
'pg_admin' => redirect()->route('pg.dashboard'), 'pg_admin' => redirect()->route('pg.dashboard'),
'gate_officer' => redirect()->route('pg.gate.inspection'), 'gate_officer' => redirect()->route('pg.gate.inspection'),
default => redirect()->route('qma.dashboard'), 'employee' => redirect()->route('employee.dashboard'),
default => redirect()->route('superadmin.dashboard'),
}; };
} }
} }
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Employee;
use App\Http\Controllers\Controller;
use App\Models\Vehicle;
use Illuminate\Http\Request;
use Illuminate\View\View;
class DashboardController extends Controller
{
/**
* Tampilkan halaman dashboard utama karyawan / operator.
*/
public function index(): View
{
$employee = auth()->user()->employee;
$totalSupport = Vehicle::unitSupports()->count();
$totalLv = Vehicle::lightVehicles()->count();
return view('employee.dashboard', compact('employee', 'totalSupport', 'totalLv'));
}
}
+10 -50
View File
@@ -4,8 +4,10 @@ namespace App\Http\Controllers\Hse;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Employee; use App\Models\Employee;
use App\Models\User;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\View\View; use Illuminate\View\View;
class EmployeeController extends Controller class EmployeeController extends Controller
@@ -36,9 +38,9 @@ class EmployeeController extends Controller
$simperLogs = Employee::where('is_operator', true) $simperLogs = Employee::where('is_operator', true)
->orderByRaw("CASE ->orderByRaw("CASE
WHEN simper_expired_at IS NULL THEN 1 WHEN simper_expired_at IS NULL THEN 1
WHEN simper_expired_at < '{$today}' THEN 0 WHEN simper_expired_at < ? THEN 0
ELSE 2 ELSE 2
END ASC, simper_expired_at ASC") END ASC, simper_expired_at ASC", [$today])
->take(5) ->take(5)
->get(); ->get();
@@ -112,80 +114,38 @@ class EmployeeController extends Controller
} }
} }
$employees = $query->orderBy('name')->get(); $employees = $query->orderBy('name')->paginate(20)->withQueryString();
return view('hse.employees_index', compact('employees')); return view('hse.employees_index', compact('employees'));
} }
/** /**
* Simpan data karyawan baru beserta izin SIMPER (Form modal gambar 3). * Pendaftaran master karyawan baru dialihkan ke Super Admin.
*/ */
public function store(Request $request): RedirectResponse public function store(Request $request): RedirectResponse
{ {
$validated = $request->validate([ return back()->with('error', 'Pendaftaran master data karyawan baru hanya dapat dilakukan oleh Super Admin melalui menu Manajemen Akun.');
'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. * Perpanjang atau perbarui status driver & masa berlaku SIMPER karyawan.
* Master data profil karyawan dikelola terpusat oleh Super Admin.
*/ */
public function update(Request $request, int $id): RedirectResponse public function update(Request $request, int $id): RedirectResponse
{ {
$employee = Employee::findOrFail($id); $employee = Employee::findOrFail($id);
$validated = $request->validate([ $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'], 'is_operator' => ['required', 'in:1,0'],
'simper_expired_at' => ['nullable', 'date'], '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.', 'is_operator.required' => 'Status driver wajib dipilih.',
]); ]);
$isOperator = (bool) $validated['is_operator']; $isOperator = (bool) $validated['is_operator'];
$simperExpiredAt = $isOperator ? ($validated['simper_expired_at'] ?? $employee->simper_expired_at) : null; $simperExpiredAt = $isOperator ? ($validated['simper_expired_at'] ?? null) : null;
$employee->update([ $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, 'is_operator' => $isOperator,
'simper_expired_at' => $simperExpiredAt, 'simper_expired_at' => $simperExpiredAt,
]); ]);
@@ -0,0 +1,232 @@
<?php
namespace App\Http\Controllers\P2h;
use App\Http\Controllers\Controller;
use App\Models\Employee;
use App\Models\P2hRecord;
use App\Models\P2hRecordItem;
use App\Models\P2hTemplate;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\View\View;
class P2hFormController extends Controller
{
/**
* Halaman katalog/pemilihan unit support untuk pengisian P2H.
*/
public function index(Request $request): View
{
$query = Vehicle::unitSupports()->where(function ($q) {
$q->whereNotNull('parent_id')
->orWhere(function ($sub) {
$sub->whereNull('parent_id')->whereDoesntHave('units');
});
});
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('location', 'like', "%{$search}%");
});
}
if ($request->filled('unit_category')) {
$query->where('unit_category', $request->input('unit_category'));
}
$vehicles = $query->with('p2hTemplate')->orderBy('code')->paginate(32)->withQueryString();
$categories = P2hTemplate::orderBy('name')->pluck('name');
$user = Auth::user();
$employee = $user ? $user->employee : null;
return view('p2h.index', compact('vehicles', 'categories', 'employee'));
}
/**
* Tampilkan formulir pengisian P2H untuk unit support tertentu.
*/
public function show(Request $request, string $code): View|RedirectResponse
{
$vehicle = Vehicle::where('code', $code)
->where('category', 'unit_support')
->firstOrFail();
$user = Auth::user();
$employee = $user->employee;
// Validasi identitas operator di sistem HSE
$simperError = null;
if ($user->isQmaAdmin() || $user->isSuperAdmin()) {
$simperError = "Anda saat ini login sebagai Admin QMA. Formulir P2H lapangan dikhususkan untuk diisi langsung oleh Operator pemegang lisensi SIMPER aktif saat pra-operasi unit. Sebagai Admin QMA, wewenang Anda adalah memeriksa, memverifikasi, dan menyetujui checksheet yang telah disubmit operator melalui Menu QMA.";
} elseif (!$employee) {
$simperError = "Akun login Anda ({$user->name}) belum ditautkan dengan data Karyawan di database HSE. Silakan hubungi Divisi HSE.";
} elseif (!$employee->is_operator) {
$simperError = "Karyawan atas nama {$employee->name} (NIK: {$employee->nik} - {$employee->division}) terdaftar sebagai BUKAN OPERATOR/DRIVER dan tidak memiliki izin mengoperasikan alat berat. Silakan hubungi Divisi HSE.";
} elseif (!$employee->hasValidSimper()) {
$expDate = $employee->simper_expired_at ? $employee->simper_expired_at->format('d/m/Y') : 'Belum Terdaftar';
$simperError = "SIMPER atas nama {$employee->name} (NIK: {$employee->nik}) telah KEDALUWARSA pada {$expDate}. Anda tidak diizinkan mengoperasikan alat berat. Silakan hubungi Divisi HSE.";
}
// Tentukan template P2H yang digunakan
$template = $vehicle->p2hTemplate;
if (!$template && $vehicle->unit_category) {
$template = P2hTemplate::where('name', 'like', "%{$vehicle->unit_category}%")
->orWhere('code', 'like', "%{$vehicle->unit_category}%")
->first();
}
if (!$template) {
// Ambil template default pertama jika belum terpetakan spesifik
$template = P2hTemplate::first();
}
$items = $template ? $template->items : collect();
$groupedItems = [];
foreach ($items as $item) {
$groupedItems[$item->section][] = $item;
}
return view('p2h.form', compact(
'vehicle',
'employee',
'simperError',
'template',
'groupedItems'
));
}
/**
* Simpan hasil pengisian formulir P2H ke database.
*/
public function store(Request $request, string $code): RedirectResponse
{
$vehicle = Vehicle::where('code', $code)
->where('category', 'unit_support')
->firstOrFail();
$user = Auth::user();
$employee = $user->employee;
if ($user->isQmaAdmin() || $user->isSuperAdmin()) {
return back()->with('error', 'Admin QMA tidak memiliki wewenang untuk mengisi formulir P2H operator. Formulir wajib diisi langsung oleh Operator alat berlisensi SIMPER aktif.');
}
if (!$employee || !$employee->is_operator || !$employee->hasValidSimper()) {
return back()->with('error', 'Validasi SIMPER gagal. Anda tidak memiliki wewenang untuk menyimpan P2H.');
}
$validated = $request->validate([
'template_id' => ['required', 'exists:p2h_templates,id'],
'shift' => ['nullable', 'string'],
'start_hm' => ['required', 'numeric', 'min:0'],
'general_notes' => ['nullable', 'string', 'max:2000'],
'items' => ['required', 'array'],
'items.*.condition' => ['nullable', 'string', 'in:baik,rusak'],
'items.*.answer' => ['nullable', 'string'],
'items.*.notes' => ['nullable', 'string', 'max:500'],
], [
'start_hm.required' => 'Nilai Hour Meter (HM) wajib diisi.',
'start_hm.numeric' => 'Nilai Hour Meter (HM) harus berupa angka valid.',
'items.required' => 'Daftar butir pemeriksaan P2H tidak boleh kosong.',
]);
$template = P2hTemplate::with('items')->findOrFail($validated['template_id']);
$submittedItems = $validated['items'];
$trxNo = 'P2H-' . Carbon::now()->format('Ymd') . '-' . strtoupper(Str::random(5));
$now = Carbon::now();
DB::transaction(function () use ($trxNo, $vehicle, $employee, $template, $validated, $submittedItems, $now) {
$defectCount = 0;
$itemsToInsert = [];
foreach ($template->items as $tItem) {
$itemId = $tItem->id;
$userAns = $submittedItems[$itemId] ?? null;
$condition = null;
$answerVal = null;
$notes = null;
if (in_array($tItem->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix'])) {
// Pilihan Baik atau Rusak (default 'baik' jika belum terisi)
$condition = isset($userAns['condition']) && $userAns['condition'] === 'rusak' ? 'rusak' : 'baik';
if ($condition === 'rusak') {
$defectCount++;
}
} elseif (in_array($tItem->question_type, ['number', 'Numerical Value'])) {
$answerVal = $userAns['answer'] ?? $validated['start_hm'];
} elseif (in_array($tItem->question_type, ['datetime', 'Datetime'])) {
$answerVal = $userAns['answer'] ?? $now->format('Y-m-d H:i');
} elseif (in_array($tItem->question_type, ['date', 'Date'])) {
$answerVal = $userAns['answer'] ?? $now->format('Y-m-d');
} else {
$answerVal = $userAns['answer'] ?? null;
}
if (!empty($userAns['notes'])) {
$notes = trim($userAns['notes']);
}
$itemsToInsert[] = [
'template_item_id' => $tItem->id,
'section' => $tItem->section,
'title' => $tItem->title,
'question_type' => $tItem->question_type,
'condition_status' => $condition,
'answer_value' => $answerVal,
'notes' => $notes,
'created_at' => $now,
'updated_at' => $now,
];
}
$summaryCondition = ($defectCount > 0) ? 'has_defect' : 'good';
$record = P2hRecord::create([
'transaction_no' => $trxNo,
'vehicle_id' => $vehicle->id,
'employee_id' => $employee->id,
'template_id' => $template->id,
'shift' => !empty($validated['shift']) ? $validated['shift'] : 'Shift 1 (Siang)',
'start_hm' => $validated['start_hm'],
'start_time' => $now,
'summary_condition' => $summaryCondition,
'defect_count' => $defectCount,
'general_notes' => $validated['general_notes'] ?? null,
'validation_status' => 'pending', // Menunggu approval Admin QMA
'inspected_at' => $now,
]);
foreach ($itemsToInsert as $ins) {
$ins['p2h_record_id'] = $record->id;
P2hRecordItem::create($ins);
}
// Perbarui HM unit di master data kendaraan jika lebih besar
if ((float)$validated['start_hm'] > (float)$vehicle->current_km) {
$vehicle->update(['current_km' => $validated['start_hm']]);
}
// Jika ada kerusakan kritis, tandai status kendaraan
if ($defectCount > 0 && $vehicle->status === 'Operation') {
$vehicle->update(['status' => 'Breakdown']);
}
});
return redirect()
->route('p2h.form', ['code' => $code])
->with('success', "Inspeksi P2H unit [{$vehicle->code}] berhasil dikirim dengan Nomor Transaksi {$trxNo}. Laporan saat ini berstatus 'Menunggu Approval' dari Admin QMA.");
}
}
@@ -45,7 +45,8 @@ class SecurityGuardController extends Controller
$guards = $query->orderBy('team') $guards = $query->orderBy('team')
->orderBy('name') ->orderBy('name')
->get(); ->paginate(20)
->withQueryString();
$gates = Gate::where('is_active', true)->orderBy('name')->get(); $gates = Gate::where('is_active', true)->orderBy('name')->get();
@@ -19,6 +19,33 @@ use Illuminate\View\View;
class VehicleActivityFormController extends Controller class VehicleActivityFormController extends Controller
{ {
/**
* Tampilkan katalog / daftar kendaraan ringan (LV) untuk keperluan mobilisasi karyawan.
*/
public function index(Request $request): View
{
$query = Vehicle::lightVehicles();
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}%");
});
}
$vehicles = $query->orderBy('code')->paginate(24)->withQueryString();
$employee = null;
if (auth()->check()) {
$employee = auth()->user()->employee;
}
return view('mobilisasi.index', compact('vehicles', 'employee'));
}
/** /**
* Tampilkan form pencatatan aktivitas kendaraan saat scan QR code. * Tampilkan form pencatatan aktivitas kendaraan saat scan QR code.
*/ */
@@ -71,6 +98,20 @@ class VehicleActivityFormController extends Controller
} else { } else {
$verifiedDriver = $emp; $verifiedDriver = $emp;
} }
} elseif (auth()->check() && auth()->user()->isEmployee()) {
$emp = auth()->user()->employee;
if ($emp) {
if (!$emp->is_operator) {
$nikErrorTitle = 'Bukan Driver Terdaftar';
$nikError = "Karyawan atas nama {$emp->name} (NIK: {$emp->nik} - {$emp->division}) terdaftar sebagai BUKAN DRIVER dan tidak memiliki izin mengemudi (SIMPER). Anda tidak diizinkan mengoperasikan kendaraan unit. Silakan hubungi Divisi HSE.";
} elseif (!$emp->hasValidSimper()) {
$nikErrorTitle = 'Peringatan: SIMPER Kedaluwarsa';
$nikError = "SIMPER atas nama {$emp->name} (NIK: {$emp->nik} - {$emp->division}) telah KEDALUWARSA. Anda tidak diizinkan mengoperasikan kendaraan. Silakan hubungi Divisi HSE untuk perpanjangan masa berlaku SIMPER.";
} else {
$verifiedDriver = $emp;
$inputNik = $emp->nik;
}
}
} }
return view('public.vehicle_activity_form', compact( return view('public.vehicle_activity_form', compact(
@@ -108,13 +108,23 @@ class ActivityLogController extends Controller
}); });
} }
$totalActivities = (clone $query)->count(); $stats = (clone $query)->selectRaw("
$totalDistance = (clone $query)->sum('distance'); COUNT(*) as total_activities,
$inCount = (clone $query)->where('direction', 'in')->count(); COALESCE(SUM(distance), 0) as total_distance,
$outCount = (clone $query)->where('direction', 'out')->count(); COUNT(CASE WHEN direction = 'in' THEN 1 END) as in_count,
$approvedCount = (clone $query)->where('validation_status', 'approved')->count(); COUNT(CASE WHEN direction = 'out' THEN 1 END) as out_count,
$pendingCount = (clone $query)->where('validation_status', 'pending')->count(); COUNT(CASE WHEN validation_status = 'approved' THEN 1 END) as approved_count,
$rejectedCount = (clone $query)->where('validation_status', 'rejected')->count(); COUNT(CASE WHEN validation_status = 'pending' THEN 1 END) as pending_count,
COUNT(CASE WHEN validation_status = 'rejected' THEN 1 END) as rejected_count
")->first();
$totalActivities = (int) ($stats->total_activities ?? 0);
$totalDistance = (float) ($stats->total_distance ?? 0);
$inCount = (int) ($stats->in_count ?? 0);
$outCount = (int) ($stats->out_count ?? 0);
$approvedCount = (int) ($stats->approved_count ?? 0);
$pendingCount = (int) ($stats->pending_count ?? 0);
$rejectedCount = (int) ($stats->rejected_count ?? 0);
// Rekapitulasi per Kendaraan // Rekapitulasi per Kendaraan
$vehicleSummaries = (clone $query) $vehicleSummaries = (clone $query)
@@ -0,0 +1,220 @@
<?php
namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller;
use App\Models\P2hRecord;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class P2hInspectionController extends Controller
{
/**
* Tampilkan riwayat dan log pemeriksaan P2H Unit Support untuk Admin QMA.
*/
public function index(Request $request): View
{
$query = P2hRecord::with(['vehicle', 'employee', 'template', 'validator']);
// Filter Status Approval
if ($request->filled('validation_status')) {
$query->where('validation_status', $request->input('validation_status'));
}
// Filter Status Kelayakan (Kondisi)
if ($request->filled('summary_condition')) {
$query->where('summary_condition', $request->input('summary_condition'));
}
// Filter Tanggal
if ($request->filled('date')) {
$query->whereDate('inspected_at', $request->input('date'));
}
// Filter Pencarian Keyword (Nomor Transaksi, Kode Unit, Nama Operator, NIK)
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$q->where('transaction_no', 'like', "%{$search}%")
->orWhereHas('vehicle', fn($v) => $v->where('code', 'like', "%{$search}%")->orWhere('brand_type', 'like', "%{$search}%"))
->orWhereHas('employee', fn($e) => $e->where('name', 'like', "%{$search}%")->orWhere('nik', 'like', "%{$search}%"));
});
}
$records = $query->orderByDesc('inspected_at')->paginate(15)->withQueryString();
// Statistik Ringkasan P2H
$totalP2h = P2hRecord::count();
$totalPending = P2hRecord::where('validation_status', 'pending')->count();
$totalApproved = P2hRecord::where('validation_status', 'approved')->count();
$totalRejected = P2hRecord::where('validation_status', 'rejected')->count();
$totalDefects = P2hRecord::where('summary_condition', 'has_defect')->count();
return view('qma.p2h_index', compact(
'records',
'totalP2h',
'totalPending',
'totalApproved',
'totalRejected',
'totalDefects'
));
}
/**
* Tampilkan Summary Pemeriksaan P2H Unit Support (Analitik, Rekapitulasi Alat Berat & Status).
*/
public function summary(Request $request): View
{
$today = Carbon::today()->toDateString();
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->toDateString());
$endDate = $request->input('end_date', $today);
$vehicleId = $request->input('vehicle_id');
$validationStatus = $request->input('validation_status');
$shift = $request->input('shift');
$search = trim($request->input('search', ''));
$query = P2hRecord::with(['vehicle', 'employee', 'template']);
if ($startDate && $endDate) {
$start = Carbon::parse($startDate)->startOfDay();
$end = Carbon::parse($endDate)->endOfDay();
$query->whereBetween('inspected_at', [$start, $end]);
} elseif ($startDate) {
$query->where('inspected_at', '>=', Carbon::parse($startDate)->startOfDay());
} elseif ($endDate) {
$query->where('inspected_at', '<=', Carbon::parse($endDate)->endOfDay());
}
if ($request->filled('vehicle_id')) {
$query->where('vehicle_id', $vehicleId);
}
if ($request->filled('validation_status')) {
$query->where('validation_status', $validationStatus);
}
if ($request->filled('shift')) {
$query->where('shift', $shift);
}
if ($search !== '') {
$query->where(function ($q) use ($search) {
$q->where('transaction_no', 'like', "%{$search}%")
->orWhereHas('vehicle', fn($v) => $v->where('code', 'like', "%{$search}%")->orWhere('brand_type', 'like', "%{$search}%"))
->orWhereHas('employee', fn($e) => $e->where('name', 'like', "%{$search}%")->orWhere('nik', 'like', "%{$search}%"));
});
}
$records = $query->orderByDesc('inspected_at')->get();
// 4 KPI Metrik Utama
$totalInspections = $records->count();
$totalApproved = $records->where('validation_status', 'approved')->count();
$totalPending = $records->where('validation_status', 'pending')->count();
$totalRejected = $records->where('validation_status', 'rejected')->count();
$totalDefects = $records->where('summary_condition', 'has_defect')->count();
$totalNormal = $records->where('summary_condition', 'good')->count();
$totalHm = $records->sum('start_hm');
// Rekapitulasi per Unit Support
$unitSummary = $records->groupBy('vehicle_id')->map(function ($group) {
$vehicle = $group->first()->vehicle;
return [
'vehicle' => $vehicle,
'total' => $group->count(),
'approved' => $group->where('validation_status', 'approved')->count(),
'pending' => $group->where('validation_status', 'pending')->count(),
'rejected' => $group->where('validation_status', 'rejected')->count(),
'has_defect' => $group->where('summary_condition', 'has_defect')->count(),
'good' => $group->where('summary_condition', 'good')->count(),
'latest_hm' => $group->max('start_hm'),
'latest_inspection' => $group->max('inspected_at'),
];
})->sortByDesc('total');
// Daftar Unit Support untuk opsi filter
$supportVehicles = Vehicle::where('category', 'unit_support')->orderBy('code')->get();
return view('qma.p2h_summary', compact(
'records',
'totalInspections',
'totalApproved',
'totalPending',
'totalRejected',
'totalDefects',
'totalNormal',
'totalHm',
'unitSummary',
'supportVehicles',
'startDate',
'endDate'
));
}
/**
* Tampilkan detail lembar pemeriksaan P2H (seluruh section & butir jawaban).
*/
public function show(int $id): View
{
$record = P2hRecord::with(['vehicle', 'employee', 'template', 'validator', 'items'])->findOrFail($id);
$groupedItems = [];
foreach ($record->items as $item) {
$groupedItems[$item->section][] = $item;
}
return view('qma.p2h_show', compact('record', 'groupedItems'));
}
/**
* Approval / Persetujuan lembar P2H oleh Admin QMA.
*/
public function approve(Request $request, int $id): RedirectResponse
{
$record = P2hRecord::with('vehicle')->findOrFail($id);
$record->update([
'validation_status' => 'approved',
'validated_by' => Auth::id(),
'validated_at' => Carbon::now(),
'validation_notes' => $request->input('validation_notes', 'Pemeriksaan P2H disetujui oleh QMA.'),
]);
// Jika unit dinyatakan aman dan sebelumnya breakdown karena review, status unit disetujui operasi
if (!$record->hasDefects() && $record->vehicle->status === 'Breakdown') {
$record->vehicle->update(['status' => 'Operation']);
}
return back()->with('success', "Inspeksi P2H [{$record->transaction_no}] untuk unit {$record->vehicle->code} berhasil DISETUJUI.");
}
/**
* Penolakan lembar P2H oleh Admin QMA (misal data tidak valid atau unit dilarang beroperasi).
*/
public function reject(Request $request, int $id): RedirectResponse
{
$request->validate([
'validation_notes' => ['required', 'string', 'max:1000'],
], [
'validation_notes.required' => 'Alasan penolakan / instruksi perbaikan wajib diisi.',
]);
$record = P2hRecord::with('vehicle')->findOrFail($id);
$record->update([
'validation_status' => 'rejected',
'validated_by' => Auth::id(),
'validated_at' => Carbon::now(),
'validation_notes' => $request->input('validation_notes'),
]);
// Kunci status kendaraan ke Breakdown atau Standby jika P2H ditolak
$record->vehicle->update(['status' => 'Breakdown']);
return back()->with('success', "Inspeksi P2H [{$record->transaction_no}] untuk unit {$record->vehicle->code} DITOLAK. Status unit diubah ke Breakdown.");
}
}
@@ -0,0 +1,351 @@
<?php
namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller;
use App\Models\P2hTemplate;
use App\Models\P2hTemplateItem;
use App\Models\Vehicle;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class P2hTemplateController extends Controller
{
/**
* Tampilkan daftar Master Template Checksheet P2H Unit Support sesuai kategori aset.
*/
public function index(Request $request): View
{
$query = P2hTemplate::withCount(['items', 'vehicles', 'records']);
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where('name', 'like', "%{$search}%")
->orWhere('code', 'like', "%{$search}%");
}
$templates = $query->orderBy('name')->get();
return view('qma.p2h_templates', compact('templates'));
}
/**
* Tampilkan detail butir pertanyaan dalam template tertentu.
*/
public function show(int $id): View
{
$template = P2hTemplate::findOrFail($id);
// Pastikan seluruh nomor urut pertanyaan berurutan otomatis tanpa celah (1, 2, 3... N)
$this->resequenceTemplate($template);
$template->load(['items' => fn($q) => $q->orderBy('sequence')]);
$groupedItems = [];
foreach ($template->items as $item) {
$groupedItems[$item->section][] = $item;
}
// Ambil daftar unik nama section yang sudah ada untuk saran/opsi dropdown
$availableSections = P2hTemplateItem::where('template_id', $template->id)
->distinct()
->pluck('section')
->values()
->all();
return view('qma.p2h_template_detail', compact('template', 'groupedItems', 'availableSections'));
}
/**
* Perbarui butir pertanyaan checksheet P2H yang sudah ada.
*/
public function updateItem(Request $request, int $templateId, int $itemId): RedirectResponse
{
$template = P2hTemplate::findOrFail($templateId);
$item = P2hTemplateItem::where('template_id', $template->id)->findOrFail($itemId);
$allowedTypes = [
'Multiple Lines Text Box',
'Single Line Text Box',
'Numerical Value',
'Date',
'Datetime',
'Multiple choice: only one answer',
'Multiple choice: multiple answers allowed',
'Matrix',
'choice',
'condition',
'number',
'text',
'datetime',
'date',
'textarea',
];
$validated = $request->validate([
'title' => 'required|string|max:255',
'section' => 'required|string|max:100',
'question_type' => ['required', 'string', 'max:50', \Illuminate\Validation\Rule::in($allowedTypes)],
'sequence' => 'nullable|integer|min:1',
]);
$oldSection = $item->section;
$newSection = trim($validated['section']);
$item->update([
'title' => trim($validated['title']),
'section' => $newSection,
'question_type' => $validated['question_type'],
]);
if ($oldSection !== $newSection) {
$targetMaxSeq = P2hTemplateItem::where('template_id', $template->id)
->where('section', $newSection)
->where('id', '!=', $item->id)
->max('sequence');
if ($targetMaxSeq) {
P2hTemplateItem::where('template_id', $template->id)
->where('id', '!=', $item->id)
->where('sequence', '>', $targetMaxSeq)
->increment('sequence', 10);
$item->update(['sequence' => $targetMaxSeq + 1]);
}
}
$this->resequenceTemplate($template);
return redirect()
->route('qma.p2h.templates.show', $template->id)
->with('success', "Butir pertanyaan '{$item->title}' berhasil diperbarui.");
}
/**
* Tambah butir pertanyaan baru ke dalam template checksheet.
*/
public function storeItem(Request $request, int $templateId): RedirectResponse
{
$template = P2hTemplate::findOrFail($templateId);
$allowedTypes = [
'Multiple Lines Text Box',
'Single Line Text Box',
'Numerical Value',
'Date',
'Datetime',
'Multiple choice: only one answer',
'Multiple choice: multiple answers allowed',
'Matrix',
'choice',
'condition',
'number',
'text',
'datetime',
'date',
'textarea',
];
// 1. Jika form mengirimkan daftar pertanyaan sekaligus (Tambah Section dengan List Pertanyaan)
if ($request->has('questions') && is_array($request->input('questions'))) {
$validated = $request->validate([
'section' => 'required|string|max:100',
'position_type' => 'nullable|string|in:end,start,after,before',
'target_section' => 'nullable|string|max:100',
'questions' => 'required|array|min:1',
'questions.*.title' => 'required|string|max:255',
'questions.*.question_type' => ['required', 'string', 'max:50', \Illuminate\Validation\Rule::in($allowedTypes)],
'questions.*.sequence' => 'nullable|integer|min:1',
]);
$section = trim($validated['section']);
$positionType = $validated['position_type'] ?? 'end';
$targetSection = !empty($validated['target_section']) ? trim($validated['target_section']) : null;
$validQuestions = array_values(array_filter($validated['questions'], fn($q) => !empty(trim($q['title'] ?? ''))));
$n = count($validQuestions);
if ($n === 0) {
return redirect()->back()->withErrors(['questions' => 'Minimal harus ada 1 pertanyaan yang terisi.']);
}
\Illuminate\Support\Facades\DB::transaction(function () use ($template, $section, $positionType, $targetSection, $validQuestions, $n) {
// Tentukan base sequence awal berdasarkan posisi penempatan
if ($positionType === 'start') {
// Geser semua item yang sudah ada
P2hTemplateItem::where('template_id', $template->id)->increment('sequence', $n + 100);
$startSeq = 1;
} elseif ($positionType === 'after' && $targetSection) {
$targetMaxSeq = P2hTemplateItem::where('template_id', $template->id)
->where('section', $targetSection)
->max('sequence');
if ($targetMaxSeq) {
P2hTemplateItem::where('template_id', $template->id)
->where('sequence', '>', $targetMaxSeq)
->increment('sequence', $n + 100);
$startSeq = $targetMaxSeq + 1;
} else {
$startSeq = (P2hTemplateItem::where('template_id', $template->id)->max('sequence') ?? 0) + 1;
}
} elseif ($positionType === 'before' && $targetSection) {
$targetMinSeq = P2hTemplateItem::where('template_id', $template->id)
->where('section', $targetSection)
->min('sequence');
if ($targetMinSeq) {
P2hTemplateItem::where('template_id', $template->id)
->where('sequence', '>=', $targetMinSeq)
->increment('sequence', $n + 100);
$startSeq = $targetMinSeq;
} else {
$startSeq = (P2hTemplateItem::where('template_id', $template->id)->max('sequence') ?? 0) + 1;
}
} else {
// Default 'end'
$startSeq = (P2hTemplateItem::where('template_id', $template->id)->max('sequence') ?? 0) + 1;
}
foreach ($validQuestions as $idx => $qData) {
P2hTemplateItem::create([
'template_id' => $template->id,
'section' => $section,
'title' => trim($qData['title']),
'question_type' => $qData['question_type'],
'sequence' => $startSeq + $idx,
]);
}
// Normalisasi ulang sequence otomatis berurutan dari section pertama hingga akhir
$this->resequenceTemplate($template);
});
return redirect()
->route('qma.p2h.templates.show', $template->id)
->with('success', "Bagian '{$section}' dengan {$n} butir pertanyaan berhasil ditambahkan.");
}
// 2. Format single question (form butir tunggal via modal tambah pertanyaan)
$validated = $request->validate([
'title' => 'required|string|max:255',
'section' => 'required|string|max:100',
'question_type' => ['required', 'string', 'max:50', \Illuminate\Validation\Rule::in($allowedTypes)],
'sequence' => 'nullable|integer|min:1',
]);
$section = trim($validated['section']);
\Illuminate\Support\Facades\DB::transaction(function () use ($template, $section, $validated) {
$targetSectionMaxSeq = P2hTemplateItem::where('template_id', $template->id)
->where('section', $section)
->max('sequence');
if ($targetSectionMaxSeq) {
// Geser butir di section setelahnya agar pertanyaan ini diletakkan di akhir section terkait
P2hTemplateItem::where('template_id', $template->id)
->where('sequence', '>', $targetSectionMaxSeq)
->increment('sequence', 10);
$seq = $targetSectionMaxSeq + 1;
} else {
$seq = (P2hTemplateItem::where('template_id', $template->id)->max('sequence') ?? 0) + 1;
}
P2hTemplateItem::create([
'template_id' => $template->id,
'section' => $section,
'title' => trim($validated['title']),
'question_type' => $validated['question_type'],
'sequence' => $seq,
]);
$this->resequenceTemplate($template);
});
return redirect()
->route('qma.p2h.templates.show', $template->id)
->with('success', "Butir pertanyaan berhasil ditambahkan ke bagian '{$section}'.");
}
/**
* Atur ulang urutan seluruh section dalam template checksheet.
*/
public function reorderSections(Request $request, int $templateId): RedirectResponse
{
$template = P2hTemplate::findOrFail($templateId);
$validated = $request->validate([
'sections' => 'required|array|min:1',
'sections.*' => 'required|string|max:100',
]);
\Illuminate\Support\Facades\DB::transaction(function () use ($template, $validated) {
$currentSequence = 1;
foreach ($validated['sections'] as $sectionName) {
$items = P2hTemplateItem::where('template_id', $template->id)
->where('section', $sectionName)
->orderBy('sequence')
->orderBy('id')
->get();
foreach ($items as $item) {
$item->update(['sequence' => $currentSequence]);
$currentSequence++;
}
}
});
return redirect()
->route('qma.p2h.templates.show', $template->id)
->with('success', 'Urutan section berhasil diperbarui.');
}
/**
* Hapus butir pertanyaan dari template checksheet.
*/
public function destroyItem(int $templateId, int $itemId): RedirectResponse
{
$template = P2hTemplate::findOrFail($templateId);
$item = P2hTemplateItem::where('template_id', $template->id)->findOrFail($itemId);
$itemTitle = $item->title;
$item->delete();
// Normalisasi ulang sequence otomatis agar tidak ada celah/lompatan nomor
$this->resequenceTemplate($template);
return redirect()
->route('qma.p2h.templates.show', $template->id)
->with('success', "Butir pertanyaan '{$itemTitle}' berhasil dihapus.");
}
/**
* Urutkan ulang sequence seluruh butir pertanyaan dalam template
* agar berurutan secara konsisten dari section pertama hingga akhir (1, 2, 3... N).
*/
private function resequenceTemplate(P2hTemplate $template): void
{
$sections = P2hTemplateItem::where('template_id', $template->id)
->select('section', \Illuminate\Support\Facades\DB::raw('MIN(sequence) as min_seq'))
->groupBy('section')
->orderBy('min_seq')
->pluck('section');
$currentSeq = 1;
foreach ($sections as $sectionName) {
$items = P2hTemplateItem::where('template_id', $template->id)
->where('section', $sectionName)
->orderBy('sequence')
->orderBy('id')
->get();
foreach ($items as $item) {
if ($item->sequence !== $currentSeq) {
$item->update(['sequence' => $currentSeq]);
}
$currentSeq++;
}
}
}
}
+273 -15
View File
@@ -3,9 +3,13 @@
namespace App\Http\Controllers\Qma; namespace App\Http\Controllers\Qma;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\P2hTemplate;
use App\Models\Vehicle; use App\Models\Vehicle;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Illuminate\View\View; use Illuminate\View\View;
@@ -77,11 +81,11 @@ class VehicleController extends Controller
} }
/** /**
* Halaman khusus pengelolaan armada Kendaraan Berat (Unit Support / Alat Berat). * Halaman khusus pengelolaan Kategori Kendaraan Berat (Unit Support / Alat Berat).
*/ */
public function indexSupport(Request $request): View public function indexSupport(Request $request): View
{ {
$query = Vehicle::unitSupports(); $query = Vehicle::unitSupportCategories()->withCount('units');
// Filter Status Operasional // Filter Status Operasional
if ($request->filled('status')) { if ($request->filled('status')) {
@@ -112,33 +116,202 @@ class VehicleController extends Controller
$vehicles = $query->orderBy('code')->paginate(15)->withQueryString(); $vehicles = $query->orderBy('code')->paginate(15)->withQueryString();
// Statistik Ringkasan Khusus Unit Support // Statistik Ringkasan Khusus Unit Support
$totalSupport = Vehicle::unitSupports()->count(); $totalSupport = Vehicle::unitSupportCategories()->count();
$totalOperation = Vehicle::unitSupports()->where('status', 'Operation')->count(); $totalUnits = Vehicle::unitSupportPhysical()->count();
$totalStandby = Vehicle::unitSupports()->where('status', 'Standby')->count(); $totalOperation = Vehicle::unitSupportCategories()->where('status', 'Operation')->count();
$totalBreakdown = Vehicle::unitSupports()->where('status', 'Breakdown')->count(); $totalStandby = Vehicle::unitSupportCategories()->where('status', 'Standby')->count();
$totalBreakdown = Vehicle::unitSupportCategories()->where('status', 'Breakdown')->count();
// Daftar kategori alat berat yang terdaftar untuk opsi filter // Daftar kategori alat berat yang terdaftar untuk opsi filter
$availableCategories = Vehicle::unitSupports() $availableCategories = Vehicle::unitSupportCategories()
->whereNotNull('unit_category') ->whereNotNull('unit_category')
->distinct() ->distinct()
->pluck('unit_category'); ->pluck('unit_category');
// Master data daftar divisi perusahaan (gabungan standar + data existing di Employee & Vehicle)
$standardDivisions = collect([
'Civil & Inviro',
'GA',
'HR',
'INFORMATION & TECHNOLOGY',
'K3',
'Keuangan',
'Logistik',
'Mechanical',
'Operasional',
'PG',
'Quality Management Asset (QMA)',
]);
$availableDivisions = $standardDivisions
->merge(Employee::whereNotNull('division')->where('division', '!=', '')->pluck('division'))
->merge(Vehicle::whereNotNull('division')->where('division', '!=', '')->pluck('division'))
->map(fn($d) => trim($d))
->filter()
->unique()
->sort()
->values()
->all();
// Daftar semua kode unit support untuk validasi unik langsung di form // Daftar semua kode unit support untuk validasi unik langsung di form
$existingCodes = Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all(); $existingCodes = Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
return view('qma.vehicles_support', compact( return view('qma.vehicles_support', compact(
'vehicles', 'vehicles',
'totalSupport', 'totalSupport',
'totalUnits',
'totalOperation', 'totalOperation',
'totalStandby', 'totalStandby',
'totalBreakdown', 'totalBreakdown',
'availableCategories', 'availableCategories',
'availableDivisions',
'existingCodes' 'existingCodes'
)); ));
} }
/** /**
* Simpan data aset kendaraan baru (Kendaraan Ringan atau Kendaraan Berat). * Halaman daftar unit fisik berdasarkan kategori Unit Support yang dipilih.
*/
public function indexSupportUnits(Request $request, int $id): View
{
$category = Vehicle::unitSupportCategories()->withCount('units')->findOrFail($id);
$query = $category->units();
if ($request->filled('status')) {
$query->where('status', $request->input('status'));
}
if ($request->filled('search')) {
$search = trim($request->input('search'));
$query->where(function ($q) use ($search) {
$q->where('code', 'like', "%{$search}%")
->orWhere('serial_number', 'like', "%{$search}%")
->orWhere('license_plate', 'like', "%{$search}%")
->orWhere('production_year', 'like', "%{$search}%")
->orWhere('location', 'like', "%{$search}%")
->orWhere('silo_document', 'like', "%{$search}%")
->orWhere('kir_document', 'like', "%{$search}%")
->orWhere('brand_type', 'like', "%{$search}%");
});
}
$units = $query->paginate(15)->withQueryString();
$totalUnits = $category->units()->count();
$totalOperation = $category->units()->where('status', 'Operation')->count();
$totalStandby = $category->units()->where('status', 'Standby')->count();
$totalBreakdown = $category->units()->where('status', 'Breakdown')->count();
$totalMaintenance = $category->units()->where('status', 'Maintenance')->count();
$nextUnitNumber = $category->getNextUnitNumber();
$nextUnitCode = $category->getNextUnitCode();
$existingCodes = Vehicle::pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
// Master data lokasi penempatan (gabungan pos gerbang aktif & lokasi operasional proyek)
$masterLocations = Gate::where('is_active', true)
->orderBy('name')
->pluck('name')
->merge(
Vehicle::whereNotNull('location')
->where('location', '!=', '')
->pluck('location')
)
->map(fn($loc) => trim($loc))
->filter()
->unique()
->sort()
->values()
->all();
return view('qma.vehicles_support_units', compact(
'category',
'units',
'totalUnits',
'totalOperation',
'totalStandby',
'totalBreakdown',
'totalMaintenance',
'nextUnitNumber',
'nextUnitCode',
'existingCodes',
'masterLocations'
));
}
/**
* Simpan penambahan unit fisik baru di bawah kategori Unit Support tertentu.
*/
public function storeSupportUnit(Request $request, int $id): RedirectResponse
{
$category = Vehicle::unitSupportCategories()->findOrFail($id);
$request->validate([
'unit_number' => ['nullable', 'string', 'max:20'],
'code' => ['nullable', 'string', 'max:50'],
'serial_number' => ['nullable', 'string', 'max:100'],
'license_plate' => ['nullable', 'string', 'max:30'],
'production_year' => ['nullable', 'integer', 'min:1980', 'max:' . (date('Y') + 1)],
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
'current_km' => ['nullable', 'numeric', 'min:0'],
'location' => ['nullable', 'string', 'max:150'],
'silo_document' => ['nullable', 'string', 'max:150'],
'kir_document' => ['nullable', 'string', 'max:150'],
'ownership' => ['nullable', 'string', 'max:150'],
'division' => ['nullable', 'string', 'max:100'],
]);
return DB::transaction(function () use ($request, $category) {
// Tentukan nomor unit dan kode unit
$rawUnitNumber = trim((string)$request->input('unit_number'));
if ($rawUnitNumber !== '') {
if (ctype_digit($rawUnitNumber)) {
$unitNumber = str_pad($rawUnitNumber, 3, '0', STR_PAD_LEFT);
} else {
$unitNumber = $rawUnitNumber;
}
$code = strtoupper(trim($category->code . '-' . $unitNumber));
} elseif ($request->filled('code')) {
$code = strtoupper(trim($request->input('code')));
} else {
$code = $category->getNextUnitCode();
}
// Validasi unik dengan lock for update
if (Vehicle::where('code', $code)->lockForUpdate()->exists()) {
return back()->withInput()->with('error', "Kode unit [{$code}] sudah terdaftar di sistem. Silakan gunakan nomor urut lain.");
}
$unit = Vehicle::create([
'code' => $code,
'category' => 'unit_support',
'parent_id' => $category->id,
'p2h_template_id' => $category->p2h_template_id,
'brand_type' => $category->brand_type,
'unit_category' => $category->unit_category,
'unit_type' => $category->unit_type,
'brand' => $category->brand,
'model_number' => $category->model_number,
'license_plate' => $request->input('license_plate'),
'serial_number' => $request->input('serial_number'),
'production_year' => $request->input('production_year'),
'status' => $request->input('status', 'Operation'),
'current_km' => $request->input('current_km', 0),
'location' => $request->input('location', $category->location),
'ownership' => $request->input('ownership', $category->ownership),
'division' => $request->input('division', $category->division),
'fuel_consumption' => $category->fuel_consumption,
'silo_document' => $request->input('silo_document'),
'kir_document' => $request->input('kir_document'),
]);
return back()->with('success', "Unit fisik [{$unit->code}] berhasil ditambahkan ke kategori {$category->unit_category}.");
});
}
/**
* Simpan data aset kendaraan baru (Kendaraan Ringan atau Kategori Kendaraan Berat).
*/ */
public function store(Request $request): RedirectResponse public function store(Request $request): RedirectResponse
{ {
@@ -149,10 +322,11 @@ class VehicleController extends Controller
'category' => ['required', 'in:light_vehicle,unit_support'], 'category' => ['required', 'in:light_vehicle,unit_support'],
'brand_type' => ['required', 'string', 'max:150'], 'brand_type' => ['required', 'string', 'max:150'],
'license_plate' => ['nullable', 'string', 'max:30'], 'license_plate' => ['nullable', 'string', 'max:30'],
'serial_number' => ['nullable', 'string', 'max:100'],
'ownership' => ['nullable', 'string', 'max:150'], 'ownership' => ['nullable', 'string', 'max:150'],
'division' => ['nullable', 'string', 'max:100'], 'division' => ['nullable', 'string', 'max:100'],
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'], 'status' => [$category === 'unit_support' ? 'nullable' : 'required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
'current_km' => ['required', 'numeric', 'min:0'], 'current_km' => [$category === 'unit_support' ? 'nullable' : 'required', 'numeric', 'min:0'],
]; ];
// Atribut opsional spesifik Unit Support (Kendaraan Berat) // Atribut opsional spesifik Unit Support (Kendaraan Berat)
@@ -180,29 +354,51 @@ class VehicleController extends Controller
'status.required' => 'Status operasional wajib dipilih.', 'status.required' => 'Status operasional wajib dipilih.',
]); ]);
if ($category === 'unit_support') {
$validated['status'] = $validated['status'] ?? 'Operation';
$validated['current_km'] = $validated['current_km'] ?? 0;
}
$vehicle = Vehicle::create($validated); $vehicle = Vehicle::create($validated);
$categoryLabel = $vehicle->isLightVehicle() ? 'Light Vehicle (LV)' : 'Unit Support'; if ($vehicle->isSupportCategory()) {
// Otomatis buatkan Master Template P2H baru (default kosong tanpa butir pertanyaan)
$template = P2hTemplate::firstOrCreate(
['code' => $vehicle->code],
[
'name' => $vehicle->unit_category ?: $vehicle->brand_type,
'description' => "Template form inspeksi P2H resmi untuk kategori {$vehicle->brand_type} (Kode: {$vehicle->code}).",
'is_active' => true,
]
);
$vehicle->update(['p2h_template_id' => $template->id]);
}
$categoryLabel = $vehicle->isLightVehicle() ? 'Light Vehicle (LV)' : 'Kategori Unit Support';
return back()->with('success', "Data {$categoryLabel} [{$vehicle->code}] berhasil ditambahkan ke sistem."); return back()->with('success', "Data {$categoryLabel} [{$vehicle->code}] berhasil ditambahkan ke sistem.");
} }
/** /**
* Perbarui data aset kendaraan (LV atau Unit Support). * Perbarui data aset kendaraan (LV atau Unit Support).
* Jika kode Kategori Unit Support diubah, otomatis sinkronisasikan kode seluruh unit fisik di bawahnya serta Master Template P2H.
*/ */
public function update(Request $request, int $id): RedirectResponse public function update(Request $request, int $id): RedirectResponse
{ {
$vehicle = Vehicle::findOrFail($id); $vehicle = Vehicle::findOrFail($id);
$oldCode = $vehicle->code;
$newCode = strtoupper(trim($request->input('code')));
$rules = [ $rules = [
'code' => ['required', 'string', 'max:50', Rule::unique('vehicles', 'code')->ignore($vehicle->id)], 'code' => ['required', 'string', 'max:50', Rule::unique('vehicles', 'code')->ignore($vehicle->id)],
'category' => ['required', 'in:light_vehicle,unit_support'], 'category' => ['required', 'in:light_vehicle,unit_support'],
'brand_type' => ['required', 'string', 'max:150'], 'brand_type' => ['required', 'string', 'max:150'],
'license_plate' => ['nullable', 'string', 'max:30'], 'license_plate' => ['nullable', 'string', 'max:30'],
'serial_number' => ['nullable', 'string', 'max:100'],
'ownership' => ['nullable', 'string', 'max:150'], 'ownership' => ['nullable', 'string', 'max:150'],
'division' => ['nullable', 'string', 'max:100'], 'division' => ['nullable', 'string', 'max:100'],
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'], 'status' => [$vehicle->isSupportCategory() ? 'nullable' : 'required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
'current_km' => ['required', 'numeric', 'min:0'], 'current_km' => [$vehicle->isSupportCategory() ? 'nullable' : 'required', 'numeric', 'min:0'],
'unit_category' => ['nullable', 'string', 'max:100'], 'unit_category' => ['nullable', 'string', 'max:100'],
'unit_type' => ['nullable', 'string', 'max:100'], 'unit_type' => ['nullable', 'string', 'max:100'],
'brand' => ['nullable', 'string', 'max:100'], 'brand' => ['nullable', 'string', 'max:100'],
@@ -223,7 +419,48 @@ class VehicleController extends Controller
'current_km.required' => 'Nilai KM / HM wajib diisi.', 'current_km.required' => 'Nilai KM / HM wajib diisi.',
]); ]);
$vehicle->update($validated); DB::transaction(function () use ($vehicle, $validated, $oldCode, $newCode) {
$vehicle->update($validated);
// Jika ini kategori Unit Support, sinkronkan Master Template P2H dan unit-unit fisik di bawahnya
if ($vehicle->isSupportCategory()) {
$template = $vehicle->p2hTemplate ?: P2hTemplate::where('code', $oldCode)->first();
if ($template) {
$template->update([
'code' => $newCode,
'name' => $vehicle->unit_category ?: $vehicle->brand_type,
'description' => "Template form inspeksi P2H resmi untuk kategori {$vehicle->brand_type} (Kode: {$newCode}).",
]);
if ($vehicle->p2h_template_id !== $template->id) {
$vehicle->update(['p2h_template_id' => $template->id]);
}
} else {
$template = P2hTemplate::firstOrCreate(
['code' => $newCode],
[
'name' => $vehicle->unit_category ?: $vehicle->brand_type,
'description' => "Template form inspeksi P2H resmi untuk kategori {$vehicle->brand_type} (Kode: {$newCode}).",
'is_active' => true,
]
);
$vehicle->update(['p2h_template_id' => $template->id]);
}
if ($oldCode !== $newCode) {
$childUnits = $vehicle->units()->lockForUpdate()->get();
foreach ($childUnits as $child) {
if (str_starts_with($child->code, $oldCode . '-')) {
$suffix = substr($child->code, strlen($oldCode . '-'));
$child->code = $newCode . '-' . $suffix;
} else {
$child->code = $newCode . '-' . $child->code;
}
$child->p2h_template_id = $template->id;
$child->save();
}
}
}
});
return back()->with('success', "Data unit kendaraan [{$vehicle->code}] berhasil diperbarui."); return back()->with('success', "Data unit kendaraan [{$vehicle->code}] berhasil diperbarui.");
} }
@@ -240,9 +477,30 @@ class VehicleController extends Controller
return back()->with('error', "Unit {$vehicle->code} tidak dapat dihapus karena telah memiliki catatan riwayat pergerakan di pos gerbang."); return back()->with('error', "Unit {$vehicle->code} tidak dapat dihapus karena telah memiliki catatan riwayat pergerakan di pos gerbang.");
} }
// Cegah jika memiliki catatan P2H
if ($vehicle->p2hRecords()->exists()) {
return back()->with('error', "Aset {$vehicle->code} tidak dapat dihapus karena telah memiliki riwayat inspeksi P2H.");
}
// Jika kategori memiliki unit fisik yang punya P2H atau riwayat aktivitas
if ($vehicle->isSupportCategory()) {
foreach ($vehicle->units as $u) {
if ($u->activities()->exists() || $u->p2hRecords()->exists()) {
return back()->with('error', "Kategori {$vehicle->code} tidak dapat dihapus karena unit fisik [{$u->code}] di bawahnya telah memiliki riwayat data operasional.");
}
}
// Hapus juga master template jika belum ada riwayat inspeksi
$template = $vehicle->p2hTemplate ?: P2hTemplate::where('code', $vehicle->code)->first();
if ($template && !$template->records()->exists()) {
$template->items()->delete();
$template->delete();
}
}
$code = $vehicle->code; $code = $vehicle->code;
$vehicle->delete(); $vehicle->delete();
return back()->with('success', "Unit kendaraan {$code} berhasil dihapus dari sistem."); return back()->with('success', "Unit/Kategori kendaraan {$code} berhasil dihapus dari sistem.");
} }
} }
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers\SuperAdmin;
use App\Http\Controllers\Controller;
use Illuminate\View\View;
class DashboardController extends Controller
{
/**
* Tampilkan dashboard utama Super Admin (halaman kosong / persiapan awal).
*/
public function index(): View
{
return view('superadmin.dashboard');
}
}
@@ -0,0 +1,272 @@
<?php
namespace App\Http\Controllers\SuperAdmin;
use App\Http\Controllers\Controller;
use App\Models\Gate;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rule;
use Illuminate\View\View;
class UserController extends Controller
{
/**
* Tampilkan halaman utama Super Admin: Manajemen Akun & Hak Akses Seluruh Modul.
*/
public function index(Request $request): View
{
$roleFilter = $request->query('role');
$search = trim((string) $request->query('search', ''));
$query = User::with(['gate', 'securityGuard.gate', 'employee'])->latest();
if ($roleFilter && $roleFilter !== 'all') {
if ($roleFilter === 'admin_group') {
$query->whereIn('role', ['super_admin', 'superadmin', 'admin', 'hse_admin', 'qma_admin', 'pg_admin']);
} elseif ($roleFilter === 'super_admin') {
$query->whereIn('role', ['super_admin', 'superadmin', 'admin']);
} else {
$query->where('role', $roleFilter);
}
}
if ($search !== '') {
$query->where(function ($q) use ($search) {
$q->where('name', 'like', "%{$search}%")
->orWhere('username', 'like', "%{$search}%")
->orWhere('email', 'like', "%{$search}%");
});
}
$users = $query->paginate(15)->withQueryString();
// Ringkasan Statistik Pengguna
$stats = [
'total' => User::count(),
'super_admin' => User::whereIn('role', ['super_admin', 'superadmin', 'admin'])->count(),
'hse_admin' => User::where('role', 'hse_admin')->count(),
'qma_admin' => User::where('role', 'qma_admin')->count(),
'pg_admin' => User::where('role', 'pg_admin')->count(),
'gate_officer' => User::where('role', 'gate_officer')->count(),
'employee' => User::where('role', 'employee')->count(),
];
// Daftar Gerbang Aktif untuk Pilihan Pos Satpam
$gates = Gate::where('is_active', true)->orderBy('name')->get();
return view('superadmin.roles_index', compact('users', 'stats', 'gates', 'roleFilter', 'search'));
}
/**
* Simpan akun admin / pengguna baru.
*/
public function store(Request $request): RedirectResponse
{
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:50', 'regex:/^[a-zA-Z0-9._-]+$/', 'unique:users,username'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
'password' => ['nullable', 'string', 'min:6'],
'role' => ['required', 'string', Rule::in(['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer', 'employee'])],
'gate_id' => ['nullable', 'exists:gates,id'],
], [
'username.unique' => 'Username tersebut sudah digunakan oleh akun lain.',
'username.regex' => 'Username hanya boleh berupa huruf, angka, titik (.), tanda hubung (-) dan garis bawah (_).',
'email.unique' => 'Email tersebut sudah terdaftar di sistem.',
'password.min' => 'Password minimal terdiri dari 6 karakter.',
'role.in' => 'Pilihan role tidak valid.',
]);
// Jika bukan gate_officer, kosongkan gate_id
if ($validated['role'] !== 'gate_officer') {
$validated['gate_id'] = null;
}
// Default password ke 'password' jika kosong atau tidak diisi
$rawPassword = !empty($validated['password']) ? $validated['password'] : 'password';
$validated['password'] = Hash::make($rawPassword);
$user = User::create($validated);
// Jika role adalah 'employee', buat juga record master Employee (Unit Kerja, Divisi, Jabatan Wajib Diisi)
if ($validated['role'] === 'employee') {
$empData = $request->validate([
'unit_kerja' => ['required', 'string', 'max:100'],
'division' => ['required', 'string', 'max:100'],
'position' => ['required', 'string', 'max:100'],
], [
'unit_kerja.required' => 'Unit kerja wajib dipilih untuk karyawan.',
'division.required' => 'Divisi wajib dipilih untuk karyawan.',
'position.required' => 'Jabatan wajib diisi untuk karyawan.',
]);
$nik = $validated['username'];
\App\Models\Employee::create([
'user_id' => $user->id,
'nik' => $nik,
'name' => $validated['name'],
'unit_kerja' => $empData['unit_kerja'],
'division' => $empData['division'],
'position' => $empData['position'],
'is_operator' => false, // Default bukan driver, akan diatur oleh Admin HSE
'simper_expired_at' => null,
]);
}
return redirect()->route('superadmin.roles.index')
->with('success', "Akun '{$validated['name']}' dengan role '{$validated['role']}' berhasil dibuat.");
}
/**
* Perbarui data akun pengguna.
*/
public function update(Request $request, int $id): RedirectResponse
{
$user = User::findOrFail($id);
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:50', 'regex:/^[a-zA-Z0-9._-]+$/', Rule::unique('users', 'username')->ignore($user->id)],
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users', 'email')->ignore($user->id)],
'password' => ['nullable', 'string', 'min:6'],
'role' => ['required', 'string', Rule::in(['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer', 'employee'])],
'gate_id' => ['nullable', 'exists:gates,id'],
], [
'username.unique' => 'Username tersebut sudah digunakan oleh akun lain.',
'username.regex' => 'Username hanya boleh berupa huruf, angka, titik (.), tanda hubung (-) dan garis bawah (_).',
'email.unique' => 'Email tersebut sudah terdaftar di sistem.',
'password.min' => 'Password baru minimal terdiri dari 6 karakter.',
]);
// Keamanan: Cegah super admin terakhir mengubah rolenya sendiri menjadi role biasa
if ($user->id === Auth::id() && $validated['role'] !== 'super_admin') {
$superAdminCount = User::whereIn('role', ['super_admin', 'superadmin', 'admin'])->count();
if ($superAdminCount <= 1) {
return back()->with('error', 'Gagal: Anda adalah satu-satunya Super Admin aktif di sistem.');
}
}
if ($validated['role'] !== 'gate_officer') {
$validated['gate_id'] = null;
}
if (!empty($validated['password'])) {
$validated['password'] = Hash::make($validated['password']);
} else {
unset($validated['password']);
}
$user->update($validated);
// Jika user ini adalah karyawan, sinkronkan nama, NIK (dari username), dan data kerjanya (wajib diisi)
if ($user->role === 'employee' || $user->employee) {
$unitKerja = $request->input('employee_unit_kerja') ?? $request->input('unit_kerja');
$division = $request->input('employee_division') ?? $request->input('division');
$position = $request->input('employee_position') ?? $request->input('position');
if ($user->role === 'employee' && (empty($unitKerja) || empty($division) || empty($position))) {
return back()->withErrors([
'employee_unit_kerja' => 'Unit kerja, divisi, dan jabatan wajib diisi untuk akun karyawan.',
])->withInput();
}
$empFields = [
'name' => $user->name,
'nik' => $user->username,
];
if (!empty($unitKerja)) {
$empFields['unit_kerja'] = $unitKerja;
}
if (!empty($division)) {
$empFields['division'] = $division;
}
if (!empty($position)) {
$empFields['position'] = $position;
}
if ($user->employee) {
$user->employee->update($empFields);
} else {
$empFields['user_id'] = $user->id;
$empFields['is_operator'] = false;
$empFields['simper_expired_at'] = null;
\App\Models\Employee::create($empFields);
}
}
return redirect()->route('superadmin.roles.index')
->with('success', "Data akun '{$user->name}' berhasil diperbarui.");
}
/**
* Hapus akun pengguna.
*/
public function destroy(int $id): RedirectResponse
{
$user = User::findOrFail($id);
// Keamanan 1: Cegah Super Admin menghapus akunnya sendiri
if ($user->id === Auth::id()) {
return back()->with('error', 'Operasi ditolak: Anda tidak dapat menghapus akun Anda sendiri.');
}
// Keamanan 2: Cegah menghapus jika merupakan super admin terakhir
if ($user->isSuperAdmin()) {
$superAdminCount = User::whereIn('role', ['super_admin', 'superadmin', 'admin'])->count();
if ($superAdminCount <= 1) {
return back()->with('error', 'Operasi ditolak: Akun Super Admin terakhir tidak boleh dihapus.');
}
}
// Keamanan 3: Cegah penghapusan jika Karyawan memiliki riwayat aktivitas atau P2H
if ($user->employee) {
if ($user->employee->activities()->exists()) {
return back()->with('error', "Operasi ditolak: Akun '{$user->name}' tidak dapat dihapus karena memiliki riwayat log pergerakan kendaraan di pos gerbang.");
}
if ($user->employee->p2hRecords()->exists()) {
return back()->with('error', "Operasi ditolak: Akun '{$user->name}' tidak dapat dihapus karena memiliki riwayat checksheet inspeksi keselamatan P2H.");
}
}
// Keamanan 4: Cegah penghapusan jika Petugas Satpam memiliki riwayat validasi pos gerbang
if ($user->securityGuard) {
if ($user->securityGuard->activities()->exists()) {
return back()->with('error', "Operasi ditolak: Petugas Satpam '{$user->name}' tidak dapat dihapus karena telah memvalidasi aktivitas kendaraan di pos gerbang.");
}
}
$userName = $user->name;
DB::transaction(function () use ($user) {
if ($user->employee) {
$user->employee->delete();
}
if ($user->securityGuard) {
$user->securityGuard->delete();
}
$user->delete();
});
return redirect()->route('superadmin.roles.index')
->with('success', "Akun '{$userName}' telah berhasil dihapus dari sistem.");
}
/**
* Reset password akun pengguna menjadi default "password".
*/
public function resetPassword(int $id): RedirectResponse
{
$user = User::findOrFail($id);
$user->update([
'password' => Hash::make('password'),
]);
return redirect()->route('superadmin.roles.index')
->with('success', "Password akun '{$user->name}' berhasil direset ke default ('password').");
}
}
+2 -2
View File
@@ -21,8 +21,8 @@ class CheckRole
$userRole = $request->user()->role; $userRole = $request->user()->role;
// Role 'admin' selalu memiliki hak akses penuh // Role 'super_admin' dan 'admin' selalu memiliki hak akses penuh ke seluruh modul
if ($userRole === 'admin' || in_array($userRole, $roles)) { if (in_array($userRole, ['super_admin', 'superadmin', 'admin']) || in_array($userRole, $roles)) {
return $next($request); return $next($request);
} }
+12
View File
@@ -6,6 +6,7 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
class Employee extends Model class Employee extends Model
@@ -13,6 +14,7 @@ class Employee extends Model
use HasFactory; use HasFactory;
protected $fillable = [ protected $fillable = [
'user_id',
'nik', 'nik',
'name', 'name',
'unit_kerja', 'unit_kerja',
@@ -52,4 +54,14 @@ class Employee extends Model
{ {
return $this->hasMany(VehicleActivity::class, 'driver_id'); return $this->hasMany(VehicleActivity::class, 'driver_id');
} }
public function p2hRecords(): HasMany
{
return $this->hasMany(P2hRecord::class, 'employee_id')->orderByDesc('inspected_at');
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
} }
+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class P2hRecord extends Model
{
use HasFactory;
protected $fillable = [
'transaction_no',
'vehicle_id',
'employee_id',
'template_id',
'shift',
'start_hm',
'start_km',
'start_time',
'stop_time',
'summary_condition',
'defect_count',
'general_notes',
'validation_status',
'validated_by',
'validated_at',
'validation_notes',
'inspected_at',
];
protected $casts = [
'start_hm' => 'decimal:2',
'start_km' => 'decimal:2',
'defect_count' => 'integer',
'start_time' => 'datetime',
'stop_time' => 'datetime',
'validated_at' => 'datetime',
'inspected_at' => 'datetime',
];
public function vehicle(): BelongsTo
{
return $this->belongsTo(Vehicle::class);
}
public function employee(): BelongsTo
{
return $this->belongsTo(Employee::class);
}
public function template(): BelongsTo
{
return $this->belongsTo(P2hTemplate::class, 'template_id');
}
public function validator(): BelongsTo
{
return $this->belongsTo(User::class, 'validated_by');
}
public function items(): HasMany
{
return $this->hasMany(P2hRecordItem::class, 'p2h_record_id');
}
public function isPending(): bool
{
return $this->validation_status === 'pending';
}
public function isApproved(): bool
{
return $this->validation_status === 'approved';
}
public function isRejected(): bool
{
return $this->validation_status === 'rejected';
}
public function hasDefects(): bool
{
return $this->summary_condition === 'has_defect' || $this->defect_count > 0;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class P2hRecordItem extends Model
{
use HasFactory;
protected $fillable = [
'p2h_record_id',
'template_item_id',
'section',
'title',
'question_type',
'condition_status',
'answer_value',
'notes',
];
public function record(): BelongsTo
{
return $this->belongsTo(P2hRecord::class, 'p2h_record_id');
}
public function templateItem(): BelongsTo
{
return $this->belongsTo(P2hTemplateItem::class, 'template_item_id');
}
public function isBaik(): bool
{
return strtolower((string)$this->condition_status) === 'baik';
}
public function isRusak(): bool
{
return strtolower((string)$this->condition_status) === 'rusak';
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class P2hTemplate extends Model
{
use HasFactory;
protected $fillable = [
'code',
'name',
'file_name',
'description',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
];
public function items(): HasMany
{
return $this->hasMany(P2hTemplateItem::class, 'template_id')->orderBy('sequence');
}
public function vehicles(): HasMany
{
return $this->hasMany(Vehicle::class, 'p2h_template_id');
}
public function records(): HasMany
{
return $this->hasMany(P2hRecord::class, 'template_id');
}
/**
* Ambil item yang dikelompokkan berdasarkan section.
*/
public function getGroupedItemsAttribute(): array
{
$grouped = [];
foreach ($this->items as $item) {
$grouped[$item->section][] = $item;
}
return $grouped;
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class P2hTemplateItem extends Model
{
use HasFactory;
protected $fillable = [
'template_id',
'section',
'title',
'question_type',
'sequence',
];
protected $casts = [
'sequence' => 'integer',
];
public function template(): BelongsTo
{
return $this->belongsTo(P2hTemplate::class, 'template_id');
}
/**
* Konversi question_type (termasuk nilai legacy) ke label standar resmi.
*/
public function getQuestionTypeLabelAttribute(): string
{
return match(strtolower(trim($this->question_type))) {
'multiple lines text box', 'textarea' => 'Multiple Lines Text Box',
'single line text box', 'text' => 'Single Line Text Box',
'numerical value', 'number' => 'Numerical Value',
'date' => 'Date',
'datetime' => 'Datetime',
'multiple choice: only one answer', 'choice', 'condition' => 'Multiple choice: only one answer',
'multiple choice: multiple answers allowed', 'multiple_choice' => 'Multiple choice: multiple answers allowed',
'matrix' => 'Matrix',
default => $this->question_type,
};
}
}
+34 -1
View File
@@ -52,6 +52,24 @@ class User extends Authenticatable
]; ];
} }
protected static function booted(): void
{
static::deleting(function (User $user) {
if ($user->employee) {
if ($user->employee->activities()->exists() || $user->employee->p2hRecords()->exists()) {
throw new \Exception("Tidak dapat menghapus user: Karyawan '{$user->name}' memiliki data audit riwayat operasional kendaraan atau inspeksi P2H.");
}
$user->employee->delete();
}
if ($user->securityGuard) {
if ($user->securityGuard->activities()->exists()) {
throw new \Exception("Tidak dapat menghapus user: Petugas Satpam '{$user->name}' memiliki riwayat data validasi pos gerbang.");
}
$user->securityGuard->delete();
}
});
}
public function gate(): BelongsTo public function gate(): BelongsTo
{ {
return $this->belongsTo(Gate::class); return $this->belongsTo(Gate::class);
@@ -62,6 +80,16 @@ class User extends Authenticatable
return $this->hasOne(SecurityGuard::class); return $this->hasOne(SecurityGuard::class);
} }
public function employee(): HasOne
{
return $this->hasOne(Employee::class);
}
public function isEmployee(): bool
{
return $this->role === 'employee';
}
public function isGateOfficer(): bool public function isGateOfficer(): bool
{ {
return $this->role === 'gate_officer'; return $this->role === 'gate_officer';
@@ -82,8 +110,13 @@ class User extends Authenticatable
return $this->role === 'pg_admin'; return $this->role === 'pg_admin';
} }
public function isSuperAdmin(): bool
{
return in_array($this->role, ['super_admin', 'superadmin']);
}
public function isAdmin(): bool public function isAdmin(): bool
{ {
return $this->role === 'admin'; return in_array($this->role, ['admin', 'super_admin', 'superadmin']);
} }
} }
+76
View File
@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOne;
@@ -15,8 +16,11 @@ class Vehicle extends Model
protected $fillable = [ protected $fillable = [
'code', 'code',
'category', 'category',
'parent_id',
'p2h_template_id',
'brand_type', 'brand_type',
'license_plate', 'license_plate',
'serial_number',
'ownership', 'ownership',
'division', 'division',
'status', 'status',
@@ -39,6 +43,7 @@ class Vehicle extends Model
'current_km' => 'decimal:2', 'current_km' => 'decimal:2',
'fuel_consumption' => 'decimal:2', 'fuel_consumption' => 'decimal:2',
'production_year' => 'integer', 'production_year' => 'integer',
'parent_id' => 'integer',
]; ];
public function isLightVehicle(): bool public function isLightVehicle(): bool
@@ -51,6 +56,16 @@ class Vehicle extends Model
return $this->category === 'unit_support'; return $this->category === 'unit_support';
} }
public function isSupportCategory(): bool
{
return $this->isUnitSupport() && is_null($this->parent_id);
}
public function isSupportUnit(): bool
{
return $this->isUnitSupport() && !is_null($this->parent_id);
}
public function scopeLightVehicles(Builder $query): Builder public function scopeLightVehicles(Builder $query): Builder
{ {
return $query->where('category', 'light_vehicle'); return $query->where('category', 'light_vehicle');
@@ -61,11 +76,72 @@ class Vehicle extends Model
return $query->where('category', 'unit_support'); return $query->where('category', 'unit_support');
} }
public function scopeUnitSupportCategories(Builder $query): Builder
{
return $query->where('category', 'unit_support')->whereNull('parent_id');
}
public function scopeUnitSupportPhysical(Builder $query): Builder
{
return $query->where('category', 'unit_support')->whereNotNull('parent_id');
}
public function parent(): BelongsTo
{
return $this->belongsTo(Vehicle::class, 'parent_id');
}
public function units(): HasMany
{
return $this->hasMany(Vehicle::class, 'parent_id')->orderBy('code');
}
/**
* Hitung nomor urut 3 digit berikutnya untuk unit fisik kategori ini.
*/
public function getNextUnitNumber(): string
{
$existingCodes = $this->units()->pluck('code')->all();
$maxNum = 0;
foreach ($existingCodes as $c) {
if (preg_match('/' . preg_quote($this->code, '/') . '-(\d+)$/i', $c, $matches)) {
$num = (int)$matches[1];
if ($num > $maxNum) {
$maxNum = $num;
}
}
}
return str_pad((string)($maxNum + 1), 3, '0', STR_PAD_LEFT);
}
/**
* Hasilkan saran kode unit unik berikutnya (misal: BL01-001).
*/
public function getNextUnitCode(): string
{
return $this->code . '-' . $this->getNextUnitNumber();
}
public function activities(): HasMany public function activities(): HasMany
{ {
return $this->hasMany(VehicleActivity::class); return $this->hasMany(VehicleActivity::class);
} }
public function p2hTemplate(): BelongsTo
{
return $this->belongsTo(P2hTemplate::class, 'p2h_template_id');
}
public function p2hRecords(): HasMany
{
return $this->hasMany(P2hRecord::class, 'vehicle_id')->orderByDesc('inspected_at');
}
public function latestP2h(): HasOne
{
return $this->hasOne(P2hRecord::class, 'vehicle_id')->latestOfMany('inspected_at');
}
/** /**
* Aktivitas gerbang terakhir dari kendaraan ini. * Aktivitas gerbang terakhir dari kendaraan ini.
*/ */
@@ -14,9 +14,9 @@ return new class extends Migration
Schema::create('vehicle_activities', function (Blueprint $table) { Schema::create('vehicle_activities', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('transaction_no', 60)->unique(); $table->string('transaction_no', 60)->unique();
$table->foreignId('vehicle_id')->constrained('vehicles')->cascadeOnDelete(); $table->foreignId('vehicle_id')->constrained('vehicles')->restrictOnDelete();
$table->foreignId('driver_id')->constrained('employees')->cascadeOnDelete(); $table->foreignId('driver_id')->constrained('employees')->restrictOnDelete();
$table->foreignId('gate_id')->constrained('gates')->cascadeOnDelete(); $table->foreignId('gate_id')->constrained('gates')->restrictOnDelete();
$table->string('direction', 10); // 'in', 'out' $table->string('direction', 10); // 'in', 'out'
$table->decimal('previous_km', 12, 2); $table->decimal('previous_km', 12, 2);
$table->decimal('current_km', 12, 2); $table->decimal('current_km', 12, 2);
@@ -0,0 +1,49 @@
<?php
use App\Models\Employee;
use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('employees', function (Blueprint $table) {
$table->foreignId('user_id')->nullable()->after('id')->constrained('users')->nullOnDelete();
});
// Buat akun user login otomatis untuk karyawan yang sudah ada di sistem
$employees = Employee::whereNull('user_id')->get();
foreach ($employees as $emp) {
$cleanNik = strtolower(str_replace(['-', ' '], '', $emp->nik));
$user = User::firstOrCreate(
['username' => $emp->nik],
[
'name' => $emp->name,
'email' => $cleanNik . '@kmh.co.id',
'password' => Hash::make('password'),
'role' => 'employee',
]
);
$emp->update(['user_id' => $user->id]);
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('employees', function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->dropColumn('user_id');
});
}
};
@@ -0,0 +1,105 @@
<?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
{
// 1. Tabel Master Template P2H (28 Kategori Unit Support)
Schema::create('p2h_templates', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique(); // Checksheet Code, misal: EXD4RP
$table->string('name', 100); // Kategori, misal: Excavator
$table->string('file_name', 150)->nullable();
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
});
// 2. Tabel Butir Pertanyaan / Item Cek per Template
Schema::create('p2h_template_items', function (Blueprint $table) {
$table->id();
$table->foreignId('template_id')->constrained('p2h_templates')->cascadeOnDelete();
$table->string('section', 100); // Start, Sebelum Mesin Hidup, Setelah Mesin Menyala, dll
$table->string('title', 255); // Pertanyaan / Butir Pemeriksaan
$table->string('question_type', 50); // choice, datetime, number, text
$table->integer('sequence')->default(0);
$table->timestamps();
$table->index(['template_id', 'sequence']);
});
// 3. Tambahkan Foreign Key p2h_template_id pada tabel vehicles
Schema::table('vehicles', function (Blueprint $table) {
$table->foreignId('p2h_template_id')->nullable()->after('category')->constrained('p2h_templates')->nullOnDelete();
});
// 4. Tabel Transaksi / Riwayat P2H
Schema::create('p2h_records', function (Blueprint $table) {
$table->id();
$table->string('transaction_no', 60)->unique();
$table->foreignId('vehicle_id')->constrained('vehicles')->restrictOnDelete();
$table->foreignId('employee_id')->constrained('employees')->restrictOnDelete();
$table->foreignId('template_id')->constrained('p2h_templates')->restrictOnDelete();
$table->string('shift', 30); // Shift 1, Shift 2
$table->decimal('start_hm', 12, 2);
$table->decimal('start_km', 12, 2)->nullable();
$table->dateTime('start_time')->nullable();
$table->dateTime('stop_time')->nullable();
$table->string('summary_condition', 30)->default('good'); // good, has_defect
$table->integer('defect_count')->default(0);
$table->text('general_notes')->nullable();
$table->string('validation_status', 20)->default('pending'); // pending, approved, rejected
$table->foreignId('validated_by')->nullable()->constrained('users')->nullOnDelete();
$table->dateTime('validated_at')->nullable();
$table->text('validation_notes')->nullable();
$table->dateTime('inspected_at');
$table->timestamps();
$table->index(['vehicle_id', 'inspected_at']);
$table->index(['employee_id', 'inspected_at']);
$table->index(['validation_status']);
});
// 5. Tabel Hasil Pengecekan Butir Item P2H
Schema::create('p2h_record_items', function (Blueprint $table) {
$table->id();
$table->foreignId('p2h_record_id')->constrained('p2h_records')->cascadeOnDelete();
$table->foreignId('template_item_id')->nullable()->constrained('p2h_template_items')->nullOnDelete();
$table->string('section', 100);
$table->string('title', 255);
$table->string('question_type', 50);
$table->string('condition_status', 20)->nullable(); // 'baik', 'rusak'
$table->text('answer_value')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
$table->index(['p2h_record_id', 'condition_status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('p2h_record_items');
Schema::dropIfExists('p2h_records');
if (Schema::hasColumn('vehicles', 'p2h_template_id')) {
Schema::table('vehicles', function (Blueprint $table) {
$table->dropForeign(['p2h_template_id']);
$table->dropColumn('p2h_template_id');
});
}
Schema::dropIfExists('p2h_template_items');
Schema::dropIfExists('p2h_templates');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('vehicles', function (Blueprint $table) {
$table->foreignId('parent_id')
->nullable()
->after('category')
->constrained('vehicles')
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('vehicles', function (Blueprint $table) {
$table->dropForeign(['parent_id']);
$table->dropColumn('parent_id');
});
}
};
@@ -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::table('vehicles', function (Blueprint $table) {
$table->string('serial_number', 100)
->nullable()
->after('license_plate');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('vehicles', function (Blueprint $table) {
$table->dropColumn('serial_number');
});
}
};
+63 -67
View File
@@ -76,7 +76,16 @@ class DatabaseSeeder extends Seeder
]); ]);
} }
// 3. Seed Users (Admin & Shared Gate Accounts) // 3. Seed Users (Super Admin, Dept Admins & Shared Gate Accounts)
// Super Admin [Nama : Super Administrator, Username : superadmin, Password : password]
User::create([
'name' => 'Super Administrator',
'username' => 'superadmin',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'super_admin',
]);
// Admin HSE [Nama : Mima, Username : 1185, Password : password] // Admin HSE [Nama : Mima, Username : 1185, Password : password]
User::create([ User::create([
'name' => 'Mima', 'name' => 'Mima',
@@ -104,74 +113,58 @@ class DatabaseSeeder extends Seeder
'role' => 'pg_admin', 'role' => 'pg_admin',
]); ]);
// Shared Gate Accounts (Akun Pos Gerbang) // 4. Seed Employees (Master Data HSE & Akun Login Karyawan dengan Role 'employee')
User::create([ $employeesData = [
'name' => 'Pos Gerbang Beringin Tunggal', [
'username' => 'pos.beringin', 'nik' => 'KMH-2022-001',
'email' => '[email protected]', 'name' => 'Eka Sufiatna',
'password' => Hash::make('password'), 'unit_kerja' => 'Teknik',
'role' => 'gate_officer', 'division' => 'INFORMATION & TECHNOLOGY',
'gate_id' => $createdGates['BTUNGGAL']->id, 'position' => 'IT Division Coordinator',
]); 'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(8), // SIMPER AKTIF
],
[
'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
],
[
'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)
],
[
'nik' => 'KMH-2021-088',
'name' => 'Siti Rahma',
'unit_kerja' => 'Umum',
'division' => 'Keuangan',
'position' => 'Staff Finance',
'is_operator' => false, // BUKAN DRIVER
'simper_expired_at' => null,
],
];
User::create([ foreach ($employeesData as $emp) {
'name' => 'Pos Gerbang Adit 1', $empUser = User::create([
'username' => 'pos.adit1', 'name' => $emp['name'],
'email' => '[email protected]', 'username' => $emp['nik'],
'password' => Hash::make('password'), 'email' => strtolower(str_replace(['-', ' '], '', $emp['nik'])) . '@kmh.co.id',
'role' => 'gate_officer', 'password' => Hash::make('password'),
'gate_id' => $createdGates['ADIT1']->id, 'role' => 'employee',
]); ]);
User::create([ $emp['user_id'] = $empUser->id;
'name' => 'Pos Gerbang Regulating Weir', Employee::create($emp);
'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) // 5. Seed Vehicles (Master Data QMA: Kendaraan Ringan / LV)
Vehicle::create([ Vehicle::create([
@@ -267,5 +260,8 @@ class DatabaseSeeder extends Seeder
'stnk_document' => 'STNK-BH-8412-AA', 'stnk_document' => 'STNK-BH-8412-AA',
'kir_document' => 'KIR-2026/11', 'kir_document' => 'KIR-2026/11',
]); ]);
// 7. Seed 28 Master Template P2H Unit Support
$this->call(P2hTemplateSeeder::class);
} }
} }
+185
View File
@@ -0,0 +1,185 @@
<?php
namespace Database\Seeders;
use App\Models\P2hTemplate;
use App\Models\P2hTemplateItem;
use App\Models\Vehicle;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class P2hTemplateSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$dir = base_path('../Data_List_Questions_P2H');
if (!is_dir($dir)) {
$dir = 'C:/laragon/www/htdocs/Data_List_Questions_P2H';
}
if (!is_dir($dir)) {
$this->command->error("Direktori {$dir} tidak ditemukan.");
return;
}
$files = glob("{$dir}/*.md");
$this->command->info("Ditemukan " . count($files) . " file template P2H.");
DB::transaction(function () use ($files) {
foreach ($files as $file) {
$content = file_get_contents($file);
$fileName = basename($file);
// 1. Ekstrak Judul Kategori
// Pola: # [P2H Excavator](url) atau # P2H Excavator
$categoryName = '';
if (preg_match('/#\s*\[?P2H\s+([^\]\(\r\n]+)/i', $content, $mTitle)) {
$categoryName = trim($mTitle[1]);
}
// 2. Ekstrak Checksheet Code
// Pola: * **Checksheet Code:** `EXD4RP`
$checksheetCode = '';
if (preg_match('/Checksheet Code:\**\s*`?([A-Za-z0-9]+)`?/i', $content, $mCode)) {
$checksheetCode = trim($mCode[1]);
}
if (!$checksheetCode) {
// Fallback kode dari nama file jika tidak ditemukan regex
$checksheetCode = strtoupper(Str::slug($categoryName, '_'));
}
$template = P2hTemplate::updateOrCreate(
['code' => $checksheetCode],
[
'name' => $categoryName ?: pathinfo($fileName, PATHINFO_FILENAME),
'file_name' => $fileName,
'description' => "Template form inspeksi P2H resmi untuk kategori {$categoryName} (Kode: {$checksheetCode}).",
'is_active' => true,
]
);
// Bersihkan item lama jika seeder dijalankan ulang
$template->items()->delete();
// 3. Parse Baris Tabel Markdown
$lines = explode("\n", $content);
$currentSection = 'General';
$sequence = 1;
foreach ($lines as $line) {
$line = trim($line);
if (str_starts_with($line, '|')) {
$cols = array_map('trim', explode('|', $line));
// cols format: [0]=>'', [1]=>No, [2]=>Section, [3]=>Title, [4]=>Question Type, [5]=>Sequence, [6]=>''
if (count($cols) >= 6 && is_numeric($cols[1])) {
$rawSection = trim(str_replace('**', '', $cols[2]));
$title = trim($cols[3]);
$rawType = trim($cols[4]);
// Jika baris adalah penanda Header Section
if (stripos($title, 'Header Section') !== false || $rawType === '-') {
if (!empty($rawSection)) {
$currentSection = $rawSection;
}
continue;
}
// Abaikan baris penutup jika berupa baris survey kosong
if (stripos($title, 'Penutup') !== false || stripos($rawSection, 'Penutup') !== false) {
continue;
}
if (!empty($rawSection) && $rawSection !== $currentSection) {
$currentSection = $rawSection;
}
// Map question type
$qType = match(true) {
stripos($rawType, 'Datetime') !== false => 'datetime',
stripos($rawType, 'Numerical') !== false => 'number',
stripos($rawType, 'Multiple Lines') !== false => 'text',
stripos($rawType, 'Single Line') !== false => 'text',
default => 'choice',
};
P2hTemplateItem::create([
'template_id' => $template->id,
'section' => $currentSection,
'title' => $title,
'question_type' => $qType,
'sequence' => $sequence++,
]);
}
}
}
}
// 4. Data Unit Kendaraan Support untuk Seluruh 28 Kategori P2H
$defaultUnits = [
'VGRM7Z' => ['code' => 'BL01', 'brand_type' => 'GENIE Z-45/25J DC BOOMLIFT', 'unit_type' => 'Articulating Boomlift', 'brand' => 'Genie', 'km' => 850.0, 'loc' => 'Powerhouse Area'],
'VGRM7X' => ['code' => 'BP01', 'brand_type' => 'BAUER BG 28 H ROTARY DRILL', 'unit_type' => 'Bore Pile Rig', 'brand' => 'Bauer', 'km' => 1240.0, 'loc' => 'Inlet Dam'],
'CDRM7C' => ['code' => 'CD01', 'brand_type' => 'BRODERSON IC-200-3J CARRY CRANE', 'unit_type' => 'Carry Deck Crane 15T', 'brand' => 'Broderson', 'km' => 980.0, 'loc' => 'Workshop Utama'],
'YMWL9T' => ['code' => 'CE01', 'brand_type' => 'ATLAS COPCO GA 75 VSD ELECTRIC', 'unit_type' => 'Electric Compressor', 'brand' => 'Atlas Copco', 'km' => 2100.0, 'loc' => 'Tunnel Adit 1'],
'YKWL9C' => ['code' => 'CG01', 'brand_type' => 'SULLAIR 375H DIESEL ENGINE', 'unit_type' => 'Engine Compressor', 'brand' => 'Sullair', 'km' => 1650.0, 'loc' => 'Regulating Weir'],
'CPWL9P' => ['code' => 'CPE01', 'brand_type' => 'PUTZMEISTER BSA 1407 D PORTABLE', 'unit_type' => 'Trailer Concrete Pump Electric', 'brand' => 'Putzmeister', 'km' => 740.0, 'loc' => 'Spillway Area'],
'CPWL9E' => ['code' => 'CPG01', 'brand_type' => 'SCHWING SP 500 DIESEL PUMP', 'unit_type' => 'Portable Concrete Pump Engine', 'brand' => 'Schwing', 'km' => 890.0, 'loc' => 'Surge Tank'],
'29NVFP' => ['code' => 'CPT01', 'brand_type' => 'SANY SY36 RZ5-130 PUMP TRUCK', 'unit_type' => 'Concrete Pump Truck 36M', 'brand' => 'Sany', 'km' => 3120.0, 'loc' => 'CCR DAM'],
'CT723D' => ['code' => 'CT01', 'brand_type' => 'ISUZU GIGA FVR 34P TADANO 5T', 'unit_type' => 'Crane Truck Cargo', 'brand' => 'Isuzu', 'km' => 4500.0, 'loc' => 'Gudang Induk'],
'EH713B' => ['code' => 'CC01', 'brand_type' => 'KOBELCO 7055-2 55T CRAWLER', 'unit_type' => 'Crawler Crane Lattice', 'brand' => 'Kobelco', 'km' => 2800.0, 'loc' => 'Bendungan Utama'],
'CR77BD' => ['code' => 'CRD01', 'brand_type' => 'SANDVIK DX700 SURFACE DRILL', 'unit_type' => 'Crawler Rig Drill', 'brand' => 'Sandvik', 'km' => 1950.0, 'loc' => 'Quarry Area'],
'DZ76BR' => ['code' => 'DZ01', 'brand_type' => 'KOMATSU D85ESS-2 DOZER', 'unit_type' => 'Crawler Bulldozer', 'brand' => 'Komatsu', 'km' => 4200.0, 'loc' => 'Disposal Area'],
'R8D3SY' => ['code' => 'DT02', 'brand_type' => 'MITSUBISHI FUSO FIGHTER FN62F', 'unit_type' => 'Dump Truck 20 Ton', 'brand' => 'Mitsubishi', 'km' => 14800.0, 'loc' => 'Quarry & Disposal'],
'EXD4RP' => ['code' => 'EX01', 'brand_type' => 'KOMATSU PC200-8 EXCAVATOR', 'unit_type' => 'Hydraulic Excavator', 'brand' => 'Komatsu', 'km' => 3450.0, 'loc' => 'Beringin Tunggal / Tunnel #2'],
'FKD4LY' => ['code' => 'FL01', 'brand_type' => 'TOYOTA 8FD30 DIESEL 3.0T', 'unit_type' => 'Industrial Forklift', 'brand' => 'Toyota', 'km' => 1100.0, 'loc' => 'Gudang Logistik'],
'R5D3FT' => ['code' => 'FT01', 'brand_type' => 'HINO RANGER FM 260 JD FUEL 10KL', 'unit_type' => 'Fuel Dispenser Truck', 'brand' => 'Hino', 'km' => 8200.0, 'loc' => 'Stasiun Pengisian BBM'],
'JD7553D' => ['code' => 'JD01', 'brand_type' => 'EPIROC BOOMER 282 JUMBO DRILL', 'unit_type' => 'Underground Jumbo Drill', 'brand' => 'Epiroc', 'km' => 1450.0, 'loc' => 'Tunnel Adit 2'],
'RF89BB' => ['code' => 'MN01', 'brand_type' => 'MANITOU MT-X 1840 TELEHANDLER', 'unit_type' => 'Telescopic Handler', 'brand' => 'Manitou', 'km' => 1350.0, 'loc' => 'Powerhouse Yard'],
'MG79KB' => ['code' => 'MG01', 'brand_type' => 'CATERPILLAR 140K MOTOR GRADER', 'unit_type' => 'Motor Grader 14ft', 'brand' => 'Caterpillar', 'km' => 2900.0, 'loc' => 'Jalan Akses Utama'],
'ML71KB' => ['code' => 'ML01', 'brand_type' => 'ITC 312 H6 TUNNEL LOADER', 'unit_type' => 'Tunnel Mucking Loader', 'brand' => 'ITC', 'km' => 920.0, 'loc' => 'Tunnel Adit 3'],
'EH713C' => ['code' => 'CR01', 'brand_type' => 'KATO SR-250R 25T ROUGH CRANE', 'unit_type' => 'Rough Terrain Crane', 'brand' => 'Kato', 'km' => 1820.0, 'loc' => 'CCR DAM / Spillway'],
'SSLS5W' => ['code' => 'SL01', 'brand_type' => 'JLG 1930ES ELECTRIC SCISSOR', 'unit_type' => 'Electric Scissorlift', 'brand' => 'JLG', 'km' => 620.0, 'loc' => 'Powerhouse Interior'],
'MS31AC' => ['code' => 'SC01', 'brand_type' => 'NORMET SPRAYMEC 8100 VC', 'unit_type' => 'Tunnel Shotcrete Sprayer', 'brand' => 'Normet', 'km' => 1180.0, 'loc' => 'Tunnel Main Header'],
'R8D3SW' => ['code' => 'TM01', 'brand_type' => 'HINO DUTRO 130 HD TRUK MIXER', 'unit_type' => 'Transit Mixer 3m3', 'brand' => 'Hino', 'km' => 5400.0, 'loc' => 'Batching Plant'],
'MV54AH' => ['code' => 'VB01', 'brand_type' => 'BOMAG BW 211 D-4 VIBRO ROLLER', 'unit_type' => 'Single Drum Roller', 'brand' => 'Bomag', 'km' => 2600.0, 'loc' => 'Dam Embankment'],
'CWPK3N' => ['code' => 'WP01', 'brand_type' => 'SELWOOD S150 WATER PUMP 6 INCH', 'unit_type' => 'Dewatering Water Pump', 'brand' => 'Selwood', 'km' => 1550.0, 'loc' => 'Cofferdam Sump'],
'WT51DB' => ['code' => 'WT01', 'brand_type' => 'ISUZU GIGA FVR WATER TRUCK 8KL', 'unit_type' => 'Water Sprayer Truck', 'brand' => 'Isuzu', 'km' => 6700.0, 'loc' => 'Hauling Road'],
'R8D3ST' => ['code' => 'WL01', 'brand_type' => 'CATERPILLAR 950H WHEEL LOADER', 'unit_type' => 'Wheel Loader 3.5m3', 'brand' => 'Caterpillar', 'km' => 3800.0, 'loc' => 'Crusher Plant'],
];
foreach ($defaultUnits as $tmplCode => $uData) {
$tmpl = P2hTemplate::where('code', $tmplCode)->first();
if (!$tmpl) continue;
$existing = Vehicle::where('code', $uData['code'])->first();
if ($existing) {
$existing->update([
'p2h_template_id' => $tmpl->id,
'unit_category' => $tmpl->name,
]);
} else {
Vehicle::create([
'code' => $uData['code'],
'category' => 'unit_support',
'p2h_template_id' => $tmpl->id,
'brand_type' => $uData['brand_type'],
'unit_category' => $tmpl->name,
'unit_type' => $uData['unit_type'],
'brand' => $uData['brand'],
'ownership' => 'PT Kerinci Merangin Hidro',
'division' => 'Operasional',
'location' => $uData['loc'],
'status' => 'Operation',
'current_km' => $uData['km'],
]);
}
}
});
$this->command->info("Seeder P2H berhasil! Seluruh 28 template kategori telah diimpor.");
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class SuperAdminSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
User::updateOrCreate(
['username' => 'superadmin'],
[
'name' => 'Super Administrator',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'super_admin',
]
);
}
}
+88
View File
@@ -0,0 +1,88 @@
services:
# ---------------------------------------------------------------------------
# 1. Aplikasi Laravel (PHP 8.2-FPM Alpine)
# ---------------------------------------------------------------------------
app:
container_name: rkm_app
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
environment:
APP_ENV: ${APP_ENV:-production}
APP_DEBUG: ${APP_DEBUG:-false}
DB_CONNECTION: mysql
DB_HOST: db
DB_PORT: 3306
DB_DATABASE: ${DB_DATABASE:-rkm_kmh}
DB_USERNAME: ${DB_USERNAME:-rkm_user}
DB_PASSWORD: ${DB_PASSWORD:-rkm_secret_password}
RUN_SEEDER: ${RUN_SEEDER:-false}
volumes:
- rkm_storage:/var/www/storage
- rkm_bootstrap_cache:/var/www/bootstrap/cache
depends_on:
db:
condition: service_healthy
networks:
- rkm_network
# ---------------------------------------------------------------------------
# 2. Web Server Nginx (Reverse Proxy & Static Asset Handler)
# ---------------------------------------------------------------------------
web:
container_name: rkm_web
image: nginx:alpine
restart: unless-stopped
ports:
- "${APP_PORT:-80}:80"
volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- .:/var/www:ro
- rkm_storage:/var/www/storage:ro
depends_on:
- app
networks:
- rkm_network
# ---------------------------------------------------------------------------
# 3. Database Server MySQL 8.0 (Enterprise Relational Database)
# ---------------------------------------------------------------------------
db:
container_name: rkm_db
image: mysql:8.0
restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_DATABASE: ${DB_DATABASE:-rkm_kmh}
MYSQL_USER: ${DB_USERNAME:-rkm_user}
MYSQL_PASSWORD: ${DB_PASSWORD:-rkm_secret_password}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root_secret_password}
ports:
- "${FORWARD_DB_PORT:-3306}:3306"
volumes:
- rkm_mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -p$${MYSQL_ROOT_PASSWORD} || exit 1"]
interval: 5s
timeout: 5s
retries: 10
start_period: 15s
networks:
- rkm_network
# -----------------------------------------------------------------------------
# Persistent Volumes & Network Configurations
# -----------------------------------------------------------------------------
volumes:
rkm_mysql_data:
name: rkm_mysql_data
rkm_storage:
name: rkm_storage
rkm_bootstrap_cache:
name: rkm_bootstrap_cache
networks:
rkm_network:
name: rkm_network
driver: bridge
+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh
set -e
echo "Starting RKM Laravel Application Container..."
# Wait for MySQL to be ready if DB_CONNECTION is mysql
if [ "$DB_CONNECTION" = "mysql" ]; then
echo "Waiting for MySQL database at $DB_HOST:$DB_PORT..."
while ! nc -z "$DB_HOST" "$DB_PORT"; do
sleep 1
done
echo "MySQL database is reachable!"
fi
# Ensure storage directories exist and have proper permissions
mkdir -p /var/www/storage/framework/cache/data \
/var/www/storage/framework/sessions \
/var/www/storage/framework/views \
/var/www/storage/logs \
/var/www/bootstrap/cache
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
# Run database migrations
echo "Executing database migrations..."
php artisan migrate --force
# Seed database if explicitly requested
if [ "$RUN_SEEDER" = "true" ]; then
echo "Seeding database..."
php artisan db:seed --force
fi
# Ensure symbolic link for storage
php artisan storage:link || true
# Production optimization caches
if [ "$APP_ENV" = "production" ]; then
echo "Caching configuration, routes, and views for production..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
else
echo "Clearing caches for non-production environment..."
php artisan config:clear
php artisan route:clear
php artisan view:clear
fi
echo "RKM Laravel is ready! Starting PHP-FPM..."
exec "$@"
+53
View File
@@ -0,0 +1,53 @@
server {
listen 80;
server_name localhost;
root /var/www/public;
index index.php index.html;
client_max_body_size 40M;
# Security Headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
charset utf-8;
# Gzip Compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Static Assets Caching
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv|svgz?|ttf|ttc|otf|eot|woff2?)$ {
expires 1y;
access_log off;
add_header Cache-Control "public, no-transform, immutable";
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 300;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
+7
View File
@@ -0,0 +1,7 @@
upload_max_filesize = 40M
post_max_size = 40M
memory_limit = 512M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Jakarta
expose_php = Off
+10
View File
@@ -0,0 +1,10 @@
[opcache]
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 0
opcache.validate_timestamps = 0
opcache.save_comments = 1
opcache.fast_shutdown = 1
+2495
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Masuk ke Sistem RKM - PT Kerinci Merangin Hidro</title> <title>Masuk ke Sistem RKM - PT Kerinci Merangin Hidro</title>
<script src="https://cdn.tailwindcss.com"></script> @vite(['resources/css/app.css', 'resources/js/app.js'])
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <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.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -0,0 +1,103 @@
@extends('layouts.app')
@section('title', 'Dashboard Karyawan - Sistem RKM | PT Kerinci Merangin Hidro')
@section('content')
<div class="w-full space-y-6">
<!-- Header Halaman Simple Kayak Satpam (Seamless, Tanpa Card Wrapper) -->
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-slate-200/80">
<div class="min-w-0">
<div class="flex items-center flex-wrap gap-2.5">
<h1 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight">
Dashboard Karyawan
</h1>
@if($employee && $employee->hasValidSimper())
<span class="px-2.5 py-1 rounded-lg text-xs font-black bg-emerald-50 text-emerald-700 border border-emerald-200">
SIMPER Aktif
</span>
@elseif($employee)
<span class="px-2.5 py-1 rounded-lg text-xs font-black bg-rose-50 text-rose-700 border border-rose-200">
SIMPER Exp
</span>
@endif
</div>
<div class="text-sm sm:text-base text-slate-600 font-medium truncate mt-1 flex items-center flex-wrap gap-1.5">
<span>Karyawan: <strong class="text-slate-900 font-bold">{{ $employee ? $employee->name : auth()->user()->name }}</strong></span>
@if($employee && $employee->nik)
<span class="text-slate-500 font-mono text-xs sm:text-sm font-semibold">({{ $employee->nik }})</span>
@endif
@if($employee && $employee->division)
<span class="text-slate-400">&bull;</span>
<span class="text-slate-500 text-xs sm:text-sm">{{ $employee->division }}</span>
@endif
</div>
</div>
@if($employee && $employee->simper_expired_at)
<div class="text-xs text-slate-500 font-medium self-start sm:self-center">
Masa Berlaku SIMPER: <span class="font-bold text-slate-800">{{ $employee->simper_expired_at->format('d/m/Y') }}</span>
</div>
@endif
</div>
<!-- 2 Card Fitur: Pemeriksaan P2H dan Timesheet -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-5 sm:gap-6">
<!-- Card 1: Pemeriksaan P2H -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md transition flex flex-col justify-between group">
<div>
<div class="flex items-center justify-end mb-4">
<span class="px-2.5 py-1 rounded-lg text-[11px] font-bold bg-amber-50 text-amber-800 border border-amber-200">
Unit Support / Alat Berat
</span>
</div>
<h2 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight mb-1">
Pemeriksaan Pra-Harian (P2H)
</h2>
<p class="text-xs sm:text-sm text-slate-500 leading-relaxed mb-4">
Pengisian formulir checklist kelaikan operasi harian sebelum mengoperasikan alat berat support unit (Excavator, Crane, Bulldozer, dan unit support lainnya).
</p>
<div class="text-xs text-slate-600 bg-slate-50 p-3 rounded-xl border border-slate-100 flex items-center justify-between">
<span class="text-slate-400">Total Unit Terdaftar:</span>
<span class="font-extrabold text-[#1b5e20]">{{ $totalSupport }} Unit Support</span>
</div>
</div>
<div class="mt-6 pt-4 border-t border-slate-100">
<a href="{{ route('p2h.index') }}" class="w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-3 px-4 rounded-xl shadow-sm transition flex items-center justify-center space-x-2 text-xs sm:text-sm">
<span>Buka Modul Pemeriksaan P2H</span>
<i class="fa-solid fa-arrow-right text-xs"></i>
</a>
</div>
</div>
<!-- Card 2: Timesheet Kendaraan Ringan (LV) -->
<div class="bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md transition flex flex-col justify-between group">
<div>
<div class="flex items-center justify-end mb-4">
<span class="px-2.5 py-1 rounded-lg text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200">
Kendaraan Ringan (LV)
</span>
</div>
<h2 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight mb-1">
Timesheet Kendaraan Ringan
</h2>
<p class="text-xs sm:text-sm text-slate-500 leading-relaxed mb-4">
Pencatatan aktivitas mobilisasi harian light vehicle (LV), odometer kilometer (KM), tujuan penugasan operasional, dan verifikasi pos gerbang.
</p>
<div class="text-xs text-slate-600 bg-slate-50 p-3 rounded-xl border border-slate-100 flex items-center justify-between">
<span class="text-slate-400">Armada Tersedia:</span>
<span class="font-extrabold text-[#1b5e20]">{{ $totalLv }} Unit Kendaraan Ringan</span>
</div>
</div>
<div class="mt-6 pt-4 border-t border-slate-100">
<a href="{{ route('timesheet.index') }}" class="w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-3 px-4 rounded-xl shadow-sm transition flex items-center justify-center space-x-2 text-xs sm:text-sm">
<span>Buka Modul Timesheet LV</span>
<i class="fa-solid fa-arrow-right text-xs"></i>
</a>
</div>
</div>
</div>
</div>
@endsection
+69 -175
View File
@@ -25,8 +25,8 @@
</h2> </h2>
</div> </div>
<!-- Tombol Aksi Kanan (Pada Mobile: Lebar Sama / Proporsional 50-50) --> <!-- Tombol Aksi Kanan -->
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto"> <div class="w-full sm:w-auto">
<!-- Tombol Ekspor Dropdown --> <!-- Tombol Ekspor Dropdown -->
<button type="button" <button type="button"
onclick="alert('Fitur ekspor spreadsheet SIMPER sedang disiapkan')" onclick="alert('Fitur ekspor spreadsheet SIMPER sedang disiapkan')"
@@ -35,14 +35,6 @@
<span>Ekspor Simper</span> <span>Ekspor Simper</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-0.5 sm:ml-1"></i> <i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-0.5 sm:ml-1"></i>
</button> </button>
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
<button type="button"
onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Karyawan</span>
</button>
</div> </div>
</div> </div>
@@ -190,7 +182,7 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverSimperEmptyRow">
<td colspan="8" class="py-12 text-center text-slate-400"> <td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i> <i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search')) @if(request('search'))
@@ -216,99 +208,16 @@
</tbody> </tbody>
</table> </table>
</div> </div>
@if($employees->hasPages())
<div class="p-4 border-t border-slate-100 bg-white">
{{ $employees->links() }}
</div>
@endif
</div> </div>
</div> </div>
<!-- Modal Dialog Add Karyawan (Persis Format Gambar IT All Role) -->
<div id="addKaryawanModal" onclick="if(event.target === this) this.classList.add('hidden')" 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) --> <!-- Modal Dialog Perpanjang SIMPER (Clean White Card) -->
<div id="renewModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4"> <div id="renewModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
@@ -358,9 +267,12 @@
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden"> <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 --> <!-- Header Modal -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100"> <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"> <div>
Edit Data Simper <h3 class="text-xl font-bold text-slate-900 tracking-tight">
</h3> Kelola SIMPER Karyawan
</h3>
<p class="text-xs text-slate-500 mt-0.5">Kelola status pengemudi dan masa berlaku izin SIMPER.</p>
</div>
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1"> <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> <i class="fa-solid fa-xmark text-lg"></i>
</button> </button>
@@ -368,63 +280,49 @@
<form id="editForm" method="POST" action="" class="mt-5 space-y-4"> <form id="editForm" method="POST" action="" class="mt-5 space-y-4">
@csrf @csrf
<!-- Profil Master Data Karyawan (Read-Only Info Card) -->
<div class="bg-slate-50 border border-slate-200/80 rounded-2xl p-4">
<div class="flex items-center justify-between mb-2 pb-2 border-b border-slate-200/60">
<span class="text-[11px] font-bold text-slate-500 uppercase tracking-wider">Profil Karyawan</span>
<span class="text-[10px] font-semibold text-slate-500 bg-slate-200/70 px-2.5 py-0.5 rounded-full inline-flex items-center">
<i class="fa-solid fa-lock text-[9px] mr-1.5 text-slate-400"></i>Master Super Admin
</span>
</div>
<div class="grid grid-cols-2 gap-3 text-xs">
<div>
<span class="text-slate-400 block text-[11px]">NIK:</span>
<span id="editNikDisplay" class="font-bold text-slate-800 font-mono"></span>
</div>
<div>
<span class="text-slate-400 block text-[11px]">Nama Lengkap:</span>
<span id="editNameDisplay" class="font-bold text-slate-900"></span>
</div>
<div>
<span class="text-slate-400 block text-[11px]">Unit Kerja:</span>
<span id="editUnitKerjaDisplay" class="font-semibold text-slate-700"></span>
</div>
<div>
<span class="text-slate-400 block text-[11px]">Divisi / Jabatan:</span>
<span id="editDivisionPositionDisplay" class="font-semibold text-slate-700"></span>
</div>
</div>
</div>
<!-- Bagian yang Dikelola HSE -->
<div> <div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nomor Induk Karyawan (NIK) <span class="text-rose-500">*</span></label> <label class="block text-sm font-bold text-slate-800 mb-2">Operator / Driver <span class="text-rose-500">*</span></label>
<input type="text" name="nik" id="editNik" required placeholder="Contoh: 0001" <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 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition"> 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>
<div> <div>
<label class="block text-sm font-bold text-slate-800 mb-2">Nama Lengkap <span class="text-rose-500">*</span></label> <label class="block text-sm font-bold text-slate-800 mb-2">Masa Berlaku SIMPER</label>
<input type="text" name="name" id="editName" required placeholder="Contoh: Ahmad Budi" <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 placeholder-slate-400 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition"> 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> <p class="text-[11px] text-slate-400 mt-1">Kosongkan jika bukan driver atau belum memiliki SIMPER.</p>
<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> </div>
<!-- Footer Tombol --> <!-- Footer Tombol -->
@@ -502,12 +400,12 @@
<!-- Fitur 3 (Amber) --> <!-- Fitur 3 (Amber) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5"> <div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50"> <div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50">
<i class="fa-solid fa-user-plus"></i> <i class="fa-solid fa-id-badge"></i>
</div> </div>
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Tambah & Perbarui Data Karyawan</h4> <h4 class="text-xs font-bold text-slate-900">Kelola Status Driver & SIMPER</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed"> <p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Mendaftarkan karyawan baru melalui tombol '+ Tambah Karyawan', serta mengedit informasi jabatan atau unit kerja melalui tombol aksi di tabel. Mengatur status kelayakan driver dan memperbarui tanggal SIMPER. Pendaftaran dan master data profil karyawan dikelola terpusat oleh Super Admin.
</p> </p>
</div> </div>
</div> </div>
@@ -550,10 +448,7 @@
// Logika Penguncian Input SIMPER jika Bukan Driver // Logika Penguncian Input SIMPER jika Bukan Driver
function toggleSimperInput(type) { function toggleSimperInput(type) {
let opSelect, dateInput; let opSelect, dateInput;
if (type === 'add') { if (type === 'edit') {
opSelect = document.getElementById('addOperator');
dateInput = document.getElementById('addSimperDate');
} else if (type === 'edit') {
opSelect = document.getElementById('editOperator'); opSelect = document.getElementById('editOperator');
dateInput = document.getElementById('editSimperDate'); dateInput = document.getElementById('editSimperDate');
} else if (type === 'renew') { } else if (type === 'renew') {
@@ -579,11 +474,10 @@
} }
function openEditModal(emp) { function openEditModal(emp) {
document.getElementById('editNik').value = emp.nik || ''; document.getElementById('editNikDisplay').textContent = emp.nik || '-';
document.getElementById('editName').value = emp.name || ''; document.getElementById('editNameDisplay').textContent = emp.name || '-';
document.getElementById('editUnitKerja').value = emp.unit_kerja || ''; document.getElementById('editUnitKerjaDisplay').textContent = emp.unit_kerja || '-';
document.getElementById('editDivision').value = emp.division || ''; document.getElementById('editDivisionPositionDisplay').textContent = (emp.division || '-') + ' / ' + (emp.position || '-');
document.getElementById('editPosition').value = emp.position || '';
document.getElementById('editOperator').value = emp.is_operator ? '1' : '0'; document.getElementById('editOperator').value = emp.is_operator ? '1' : '0';
let expDate = ''; let expDate = '';
@@ -611,11 +505,6 @@
document.getElementById('renewModal').classList.remove('hidden'); document.getElementById('renewModal').classList.remove('hidden');
} }
// Inisialisasi awal untuk modal tambah
document.addEventListener('DOMContentLoaded', function() {
toggleSimperInput('add');
});
// Filter Pencarian Instan Real-time // Filter Pencarian Instan Real-time
const searchInput = document.getElementById('simperSearchInput'); const searchInput = document.getElementById('simperSearchInput');
const resetContainer = document.getElementById('simperResetContainer'); const resetContainer = document.getElementById('simperResetContainer');
@@ -641,6 +530,11 @@
if (match) visibleCount++; if (match) visibleCount++;
}); });
const serverEmptyRow = document.getElementById('serverSimperEmptyRow');
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian jika ada sebelumnya // Hapus baris pesan kosong pencarian jika ada sebelumnya
const existingEmptyRow = document.getElementById('simperEmptySearchRow'); const existingEmptyRow = document.getElementById('simperEmptySearchRow');
if (existingEmptyRow) { if (existingEmptyRow) {
@@ -648,7 +542,7 @@
} }
// Tampilkan pesan jika tidak ada data yang cocok di tabel // Tampilkan pesan jika tidak ada data yang cocok di tabel
if (rows.length > 0 && visibleCount === 0 && query.length > 0) { if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr'); const emptyTr = document.createElement('tr');
emptyTr.id = 'simperEmptySearchRow'; emptyTr.id = 'simperEmptySearchRow';
emptyTr.innerHTML = ` emptyTr.innerHTML = `
+291 -111
View File
@@ -4,8 +4,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Sistem RKM - PT Kerinci Merangin Hidro')</title> <title>@yield('title', 'Sistem RKM - PT Kerinci Merangin Hidro')</title>
<!-- Tailwind CSS CDN --> <!-- Compiled Assets via Vite -->
<script src="https://cdn.tailwindcss.com"></script> @vite(['resources/css/app.css', 'resources/js/app.js'])
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <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.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -96,17 +96,36 @@
body.modal-open { body.modal-open {
scrollbar-color: rgba(255, 255, 255, 0.2) rgba(15, 23, 42, 0.6); scrollbar-color: rgba(255, 255, 255, 0.2) rgba(15, 23, 42, 0.6);
} }
/* Hilangkan Scrollbar pada Sidebar Desktop & Mobile (tetap dapat di-scroll) */
aside .overflow-y-auto,
#mobileDrawerPanel .overflow-y-auto,
.no-scrollbar {
-ms-overflow-style: none !important; /* IE dan Edge */
scrollbar-width: none !important; /* Firefox */
}
aside .overflow-y-auto::-webkit-scrollbar,
#mobileDrawerPanel .overflow-y-auto::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
display: none !important;
width: 0 !important;
height: 0 !important;
}
</style> </style>
</head> </head>
<body class="bg-slate-50 text-slate-800 antialiased font-sans min-h-screen"> <body class="bg-slate-50 text-slate-800 antialiased font-sans min-h-screen">
@php @php
$isFormMobil = request()->routeIs('vehicle.activity.*') || request()->is('gate-activity*'); $isStandaloneForm = request()->routeIs('vehicle.activity.*')
|| request()->is('gate-activity*')
|| request()->routeIs('p2h.form', 'p2h.store')
|| (request()->is('p2h/*') && !request()->routeIs('qma.*'));
$isFormMobil = $isStandaloneForm;
@endphp @endphp
@if($isFormMobil) @if($isStandaloneForm)
<!-- ========================================================================= --> <!-- ========================================================================= -->
<!-- LAYOUT KHUSUS FORM UNIT MOBIL (TANPA SIDEBAR & TOPBAR) --> <!-- LAYOUT KHUSUS FORM STANDALONE / FORM MOBIL & P2H (TANPA SIDEBAR & TOPBAR) -->
<!-- ========================================================================= --> <!-- ========================================================================= -->
<div class="min-h-screen bg-slate-50 flex flex-col justify-between py-6 px-4 sm:px-6"> <div class="min-h-screen bg-slate-50 flex flex-col justify-between py-6 px-4 sm:px-6">
<main class="w-full"> <main class="w-full">
@@ -135,8 +154,34 @@
</div> </div>
<!-- Menu Navigasi Sidebar --> <!-- Menu Navigasi Sidebar -->
<div class="flex-1 overflow-y-auto px-4 py-5 space-y-6"> <div class="flex-1 overflow-y-auto px-4 py-5 space-y-6 no-scrollbar">
<!-- Grup: Navigasi Utama --> @if(auth()->user()->isSuperAdmin())
<!-- Kategori Khusus Super Admin: Dashboard & Manajemen Role -->
<div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MENU ADMIN
</p>
<nav class="space-y-1">
<a href="{{ route('superadmin.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('superadmin.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('superadmin.roles.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('superadmin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-users-gear text-base w-5 text-center"></i>
<span>Manajemen Role</span>
</a>
</nav>
</div>
@else
<!-- Grup: Navigasi Utama (Departemen Lain) -->
<div> <div>
<nav class="space-y-1"> <nav class="space-y-1">
@if(auth()->user()->isHseAdmin()) @if(auth()->user()->isHseAdmin())
@@ -178,18 +223,39 @@
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i> <i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span> <span>Verifikasi Pos Gerbang</span>
</a> </a>
@elseif(auth()->user()->isEmployee())
<a href="{{ route('employee.dashboard') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('employee.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('p2h.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('p2h.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-check text-base w-5 text-center"></i>
<span>Pemeriksaan P2H</span>
</a>
<a href="{{ route('timesheet.index') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('timesheet.*') || request()->routeIs('mobilisasi.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-car text-base w-5 text-center"></i>
<span>Timesheet</span>
</a>
@endif @endif
</nav> </nav>
</div> </div>
<!-- Grup: Modul Operasional RKM --> <!-- Grup: Modul Operasional Departemen RKM -->
@if(!auth()->user()->isGateOfficer()) @if(!auth()->user()->isGateOfficer())
<div> <div>
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2"> <p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
MANAJEMEN SISTEM MANAJEMEN SISTEM
</p> </p>
<nav class="space-y-1"> <nav class="space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin()) @if(auth()->user()->isHseAdmin())
<a href="{{ route('hse.employees.index') }}" <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' }}"> 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> <i class="fa-solid fa-id-card text-base w-5 text-center"></i>
@@ -197,7 +263,7 @@
</a> </a>
@endif @endif
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin()) @if(auth()->user()->isQmaAdmin())
@php @php
$isVehicleRoute = request()->routeIs('qma.vehicles.*'); $isVehicleRoute = request()->routeIs('qma.vehicles.*');
@endphp @endphp
@@ -227,20 +293,45 @@
</div> </div>
</div> </div>
<a href="{{ route('qma.activity.log') }}" @php
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' }}"> $isActivityRoute = request()->routeIs('qma.activity.log') || request()->routeIs('qma.p2h.index') || request()->routeIs('qma.p2h.show');
<i class="fa-solid fa-clipboard-list text-base w-5 text-center"></i> @endphp
<span>Log Aktivitas Kendaraan</span> <!-- Dropdown Menu: Log Aktifitas -->
<div>
<button type="button"
onclick="toggleActivityMenu('desktop')"
class="w-full flex items-center justify-between px-3.5 py-2.5 text-sm rounded-xl transition group {{ $isActivityRoute ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<div class="flex items-center space-x-3">
<i class="fa-solid fa-clipboard-list text-base w-5 text-center {{ $isActivityRoute ? 'text-[#1b5e20]' : '' }}"></i>
<span>Log Aktifitas</span>
</div>
<i id="activityChevronDesktop" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isActivityRoute ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
</button>
<!-- Submenu Dropdown: Timesheet LV & P2H Unit Support (Tanpa Icon) -->
<div id="activitySubmenuDesktop" class="{{ $isActivityRoute ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<a href="{{ route('qma.activity.log') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.activity.log') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Timesheet LV</span>
</a>
<a href="{{ route('qma.p2h.index') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.p2h.index') || request()->routeIs('qma.p2h.show') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>P2H Unit Support</span>
</a>
</div>
</div>
<a href="{{ route('qma.p2h.templates') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.p2h.templates*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-layer-group text-base w-5 text-center"></i>
<span>Master Template P2H</span>
</a> </a>
<a href="{{ route('qma.activity.summary') }}"
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-chart-pie text-base w-5 text-center"></i>
<span>Summary Aktivitas</span>
</a>
@endif @endif
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin()) @if(auth()->user()->isPgAdmin())
<a href="{{ route('pg.guards.index') }}" <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' }}"> 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> <i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
@@ -256,6 +347,7 @@
</nav> </nav>
</div> </div>
@endif @endif
@endif
<!-- Grup: Pengaturan Akun --> <!-- Grup: Pengaturan Akun -->
<div class="mt-6"> <div class="mt-6">
@@ -311,96 +403,156 @@
</button> </button>
</div> </div>
<div class="p-4 space-y-4 flex-1 overflow-y-auto"> <div class="p-4 space-y-4 flex-1 overflow-y-auto no-scrollbar">
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2">NAVIGASI</p> @if(auth()->user()->isSuperAdmin())
<div class="space-y-1"> <div class="mb-3 space-y-1">
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin()) <p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mb-1">MENU ADMIN</p>
<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' }}"> <a href="{{ route('superadmin.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('superadmin.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"> <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="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="3" width="7" height="7" rx="2"></rect>
<rect x="14" y="14" 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> <rect x="3" y="14" width="7" height="7" rx="2"></rect>
</svg> </svg>
<span>Dashboard</span> <span>Dashboard</span>
</a> </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' }}"> <a href="{{ route('superadmin.roles.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('superadmin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-id-card w-5 text-center"></i> <i class="fa-solid fa-users-gear w-5 text-center"></i>
<span>Data Simper</span> <span>Manajemen Role</span>
</a> </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> </div>
@else
@if(auth()->user()->isHseAdmin())
<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())
<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>
<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' }}"> @php
<i class="fa-solid fa-clipboard-list w-5 text-center"></i> $isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
<span>Log Aktivitas Kendaraan</span> @endphp
</a> <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>
<a href="{{ route('qma.activity.summary') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}"> <div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
<i class="fa-solid fa-chart-pie w-5 text-center"></i> <a href="{{ route('qma.vehicles.lv') }}"
<span>Summary Aktivitas</span> 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' }}">
</a> <span>Light Vehicle</span>
@endif </a>
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}"> <a href="{{ route('qma.vehicles.support') }}"
<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"> 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' }}">
<rect x="3" y="3" width="7" height="7" rx="2"></rect> <span>Unit Support</span>
<rect x="14" y="3" width="7" height="7" rx="2"></rect> </a>
<rect x="14" y="14" width="7" height="7" rx="2"></rect> </div>
<rect x="3" y="14" width="7" height="7" rx="2"></rect> </div>
</svg>
<span>Dashboard</span> @php
</a> $isActivityRouteMob = request()->routeIs('qma.activity.log') || request()->routeIs('qma.p2h.index') || request()->routeIs('qma.p2h.show');
<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' }}"> @endphp
<i class="fa-solid fa-user-shield w-5 text-center"></i> <div>
<span>Data Satpam</span> <button type="button"
</a> onclick="toggleActivityMenu('mobile')"
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}"> class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isActivityRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i> <div class="flex items-center space-x-3">
<span>Log Verifikasi Gerbang</span> <i class="fa-solid fa-clipboard-list w-5 text-center {{ $isActivityRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
</a> <span>Log Aktifitas</span>
@endif </div>
@if(auth()->user()->isGateOfficer()) <i id="activityChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isActivityRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
<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' }}"> </button>
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
<span>Verifikasi Pos Gerbang</span> <div id="activitySubmenuMobile" class="{{ $isActivityRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
</a> <a href="{{ route('qma.activity.log') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.activity.log') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>Timesheet LV</span>
</a>
<a href="{{ route('qma.p2h.index') }}"
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.p2h.index') || request()->routeIs('qma.p2h.show') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
<span>P2H Unit Support</span>
</a>
</div>
</div>
<a href="{{ route('qma.p2h.templates') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.p2h.templates*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-layer-group w-5 text-center"></i>
<span>Master Template P2H</span>
</a>
@endif
@if(auth()->user()->isEmployee())
<a href="{{ route('employee.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('employee.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('p2h.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('p2h.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clipboard-check w-5 text-center"></i>
<span>Pemeriksaan P2H</span>
</a>
<a href="{{ route('timesheet.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('timesheet.*') || request()->routeIs('mobilisasi.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-car w-5 text-center"></i>
<span>Timesheet</span>
</a>
@endif
@if(auth()->user()->isPgAdmin())
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.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('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>Data Satpam</span>
</a>
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i>
<span>Log Verifikasi Gerbang</span>
</a>
@endif
@if(auth()->user()->isGateOfficer())
<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>Verifikasi Pos Gerbang</span>
</a>
@endif
@endif @endif
</div> </div>
@@ -444,7 +596,11 @@
<i class="fa-solid fa-bars text-base"></i> <i class="fa-solid fa-bars text-base"></i>
</button> </button>
<h1 class="text-lg sm:text-xl font-bold text-slate-900 tracking-tight"> <h1 class="text-lg sm:text-xl font-bold text-slate-900 tracking-tight">
@if(request()->routeIs('hse.dashboard') || request()->routeIs('qma.dashboard')) @if(request()->routeIs('superadmin.dashboard'))
Dashboard Admin
@elseif(request()->routeIs('superadmin.roles.*') || request()->routeIs('superadmin.users.*'))
Manajemen Role
@elseif(request()->routeIs('hse.dashboard') || request()->routeIs('qma.dashboard'))
Dashboard Dashboard
@elseif(request()->routeIs('hse.employees.*')) @elseif(request()->routeIs('hse.employees.*'))
Data Simper Data Simper
@@ -455,9 +611,15 @@
@elseif(request()->routeIs('qma.vehicles.*')) @elseif(request()->routeIs('qma.vehicles.*'))
Data Kendaraan Data Kendaraan
@elseif(request()->routeIs('qma.activity.log')) @elseif(request()->routeIs('qma.activity.log'))
Log Aktivitas Kendaraan Timesheet LV
@elseif(request()->routeIs('qma.p2h.summary'))
Summary P2H Unit Support
@elseif(request()->routeIs('qma.p2h.templates*'))
Master Template P2H
@elseif(request()->routeIs('qma.p2h.*'))
P2H Unit Support
@elseif(request()->routeIs('qma.activity.summary')) @elseif(request()->routeIs('qma.activity.summary'))
Summary Aktivitas Summary Timesheet LV
@elseif(request()->routeIs('profile.*')) @elseif(request()->routeIs('profile.*'))
Profil Saya Profil Saya
@elseif(request()->routeIs('pg.dashboard')) @elseif(request()->routeIs('pg.dashboard'))
@@ -468,6 +630,12 @@
Data Satpam Data Satpam
@elseif(request()->routeIs('pg.logs.*')) @elseif(request()->routeIs('pg.logs.*'))
Log Verifikasi Gerbang Log Verifikasi Gerbang
@elseif(request()->routeIs('employee.dashboard'))
Dashboard
@elseif(request()->routeIs('p2h.*'))
Pemeriksaan P2H
@elseif(request()->routeIs('timesheet.*') || request()->routeIs('mobilisasi.*'))
Timesheet
@else @else
Dashboard Dashboard
@endif @endif
@@ -518,7 +686,7 @@
</header> </header>
<!-- 4. KONTEN UTAMA DASHBOARD (ATURAN EMAS: WRAPPER MAX-WIDTH HANYA DI SATU TEMPAT) --> <!-- 4. KONTEN UTAMA DASHBOARD (ATURAN EMAS: WRAPPER MAX-WIDTH HANYA DI SATU TEMPAT) -->
<main class="md:ml-64 flex-1 min-h-[calc(100vh-4rem)]"> <main class="md:ml-64 flex-1 overflow-y-auto min-h-[calc(100vh-4rem)]">
<div class="p-4 md:p-8 max-w-[1400px] mx-auto w-full"> <div class="p-4 md:p-8 max-w-[1400px] mx-auto w-full">
@yield('content') @yield('content')
</div> </div>
@@ -792,6 +960,18 @@
} }
} }
// Toggle Dropdown Menu Log Aktifitas (Desktop & Mobile)
function toggleActivityMenu(target) {
const submenu = document.getElementById(target === 'desktop' ? 'activitySubmenuDesktop' : 'activitySubmenuMobile');
const chevron = document.getElementById(target === 'desktop' ? 'activityChevronDesktop' : 'activityChevronMobile');
if (submenu) {
submenu.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
// Toggle Dropdown Menu Profil Pengguna di Pojok Kanan Atas // Toggle Dropdown Menu Profil Pengguna di Pojok Kanan Atas
function toggleProfileDropdown() { function toggleProfileDropdown() {
const dropdown = document.getElementById('userProfileDropdownMenu'); const dropdown = document.getElementById('userProfileDropdownMenu');
+260
View File
@@ -0,0 +1,260 @@
@extends('layouts.app')
@section('title', 'Katalog Kendaraan Ringan (LV) - Mobilisasi Operasional')
@section('content')
<div class="w-full space-y-6">
<!-- Header Halaman Simple Kayak Satpam (Seamless, Tanpa Card Wrapper) -->
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-slate-200/80">
<div class="min-w-0">
<div class="flex items-center flex-wrap gap-2.5">
<h1 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight">
Timesheet Kendaraan Ringan
</h1>
<span class="px-2.5 py-1 rounded-lg text-xs font-black bg-emerald-50 text-emerald-800 border border-emerald-200">
Kendaraan Ringan (LV)
</span>
</div>
<div class="text-sm sm:text-base text-slate-600 font-medium truncate mt-1 flex items-center flex-wrap gap-1.5">
<span>Pengemudi: <strong class="text-slate-900 font-bold">{{ $employee ? $employee->name : auth()->user()->name }}</strong></span>
@if($employee && $employee->nik)
<span class="text-slate-500 font-mono text-xs sm:text-sm font-semibold">({{ $employee->nik }})</span>
@endif
@if($employee && $employee->hasValidSimper())
<span class="inline-flex items-center text-[10px] font-bold text-emerald-700 bg-emerald-100/80 px-2 py-0.5 rounded-md ml-1">
<i class="fa-solid fa-circle-check mr-1 text-emerald-600"></i> SIMPER Aktif
</span>
@elseif($employee)
<span class="inline-flex items-center text-[10px] font-bold text-rose-700 bg-rose-100/80 px-2 py-0.5 rounded-md ml-1">
<i class="fa-solid fa-circle-xmark mr-1 text-rose-600"></i> SIMPER Exp
</span>
@endif
</div>
</div>
</div>
<!-- Filter & Search Bar (Tanpa Card Wrapper, Format Referensi Sesuai Standar) -->
<form method="GET" action="{{ route('mobilisasi.index') }}" id="lvFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<!-- Pencarian Cepat di Kiri -->
<div class="relative w-full 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"
name="search"
id="lvSearchInput"
value="{{ request('search') }}"
placeholder="Cari kode unit (LV01), nopol, atau model..."
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-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
</div>
<!-- Tombol Reset Filter di Kanan -->
<div id="lvResetContainer" class="flex items-center justify-end">
@if(request()->filled('search'))
<a href="{{ route('mobilisasi.index') }}"
id="lvResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</form>
<!-- Grid Kartu Kendaraan Ringan (LV) -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" id="lvCardsContainer">
@forelse($vehicles as $v)
<div class="lv-card bg-white rounded-2xl border border-slate-200 shadow-sm hover:shadow-md transition p-5 flex flex-col justify-between">
<div>
<!-- Badge Kategori & Status -->
<div class="flex items-center justify-between mb-3">
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200">
Kendaraan Ringan (LV)
</span>
@php
$statusBadge = match($v->status) {
'Operation' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
'Standby' => 'bg-amber-50 text-amber-700 border-amber-200',
'Breakdown' => 'bg-rose-50 text-rose-700 border-rose-200',
default => 'bg-slate-50 text-slate-700 border-slate-200',
};
$nextDir = $v->determineNextAllowedDirection();
@endphp
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold border {{ $statusBadge }}">
{{ $v->status }}
</span>
</div>
<!-- Kode & Nopol -->
<div class="flex items-baseline justify-between">
<h3 class="text-xl font-black text-slate-900 leading-tight">{{ $v->code }}</h3>
<span class="font-mono text-xs font-bold text-amber-700 bg-amber-50 border border-amber-200/80 px-2 py-0.5 rounded-md">
{{ $v->license_plate ?? 'Tanpa Plat' }}
</span>
</div>
<p class="text-xs text-slate-600 font-medium mt-1 line-clamp-1">{{ $v->brand_type }}</p>
<!-- Info Atribut -->
<div class="mt-4 space-y-1.5 text-xs text-slate-500 bg-slate-50 p-3 rounded-xl border border-slate-100">
<div class="flex items-center justify-between">
<span class="text-slate-400">Odometer Terakhir:</span>
<span class="font-extrabold text-slate-800">{{ number_format($v->current_km, 0, ',', '.') }} KM</span>
</div>
<div class="flex items-center justify-between">
<span class="text-slate-400">Penanggung Jawab:</span>
<span class="font-semibold text-slate-700 truncate max-w-[150px]">{{ $v->ownership ?? '-' }}</span>
</div>
<div class="flex items-center justify-between">
<span class="text-slate-400">Status Pergerakan:</span>
<span class="font-bold {{ $nextDir === 'Keluar' ? 'text-amber-700' : 'text-blue-700' }}">
Menunggu {{ $nextDir }}
</span>
</div>
</div>
</div>
<!-- Tombol Buka Form Mobilisasi -->
<div class="mt-5 pt-3 border-t border-slate-100">
@if($v->status === 'Breakdown')
<div class="w-full bg-rose-50 border border-rose-200 text-rose-700 font-bold py-2.5 px-4 rounded-xl text-center text-xs">
<i class="fa-solid fa-triangle-exclamation mr-1.5"></i>
<span>Unit Sedang Breakdown</span>
</div>
@else
<a href="{{ route('vehicle.activity.form', ['code' => $v->code]) }}" class="w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-2.5 px-4 rounded-xl shadow-sm transition text-center block text-xs">
Isi Form Mobilisasi LV
</a>
@endif
</div>
</div>
@empty
<div id="lvServerEmptyCard" class="col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center">
<div class="w-16 h-16 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
</div>
@if(request('search'))
<h3 class="text-base font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h3>
<p class="text-xs text-slate-500 mt-1">Pastikan kode unit atau nopol kendaraan yang dicari sudah benar.</p>
<div class="mt-4">
<a href="{{ route('mobilisasi.index') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<h3 class="text-base font-bold text-slate-800">Kendaraan Ringan Tidak Ditemukan</h3>
<p class="text-xs text-slate-500 mt-1">Belum ada unit kendaraan LV yang terdaftar.</p>
@endif
</div>
@endforelse
</div>
<!-- Pagination -->
@if($vehicles->hasPages())
<div class="bg-white p-4 rounded-2xl border border-slate-200 shadow-sm" id="lvPaginationContainer">
{{ $vehicles->links() }}
</div>
@endif
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Search Real-Time Client-Side
const searchInput = document.getElementById('lvSearchInput');
const resetContainer = document.getElementById('lvResetContainer');
const cardsContainer = document.getElementById('lvCardsContainer');
const paginationContainer = document.getElementById('lvPaginationContainer');
const serverEmptyCard = document.getElementById('lvServerEmptyCard');
const hasServerFilters = {{ request()->filled('search') ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
searchInput?.addEventListener('input', function(e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const items = document.querySelectorAll('#lvCardsContainer .lv-card');
let visibleCount = 0;
items.forEach(item => {
const text = item.textContent.toLowerCase();
const match = text.includes(query);
item.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan pesan SSR kosong saat mengetik
if (serverEmptyCard) {
serverEmptyCard.style.display = query.length > 0 ? 'none' : '';
}
// Hapus pesan kosong pencarian jika ada sebelumnya
const existingEmptyCard = document.getElementById('lvEmptySearchCard');
if (existingEmptyCard) {
existingEmptyCard.remove();
}
// Tampilkan pesan kosong jika tidak ada data yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyDiv = document.createElement('div');
emptyDiv.id = 'lvEmptySearchCard';
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center shadow-sm';
emptyDiv.innerHTML = `
<div class="w-16 h-16 rounded-full bg-rose-50 text-rose-500 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
</div>
<h3 class="text-base font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h3>
<p class="text-xs text-slate-500 mt-1">
Pastikan kode unit atau nopol kendaraan yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('lvSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
`;
cardsContainer?.appendChild(emptyDiv);
}
// Sembunyikan pagination saat client-side search aktif
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
// Tampilkan / sembunyikan tombol Reset Filter (merah fa-rotate-left) secara real-time
let resetBtn = document.getElementById('lvResetBtn');
if (query.length > 0) {
if (!resetBtn && resetContainer) {
resetBtn = document.createElement('a');
resetBtn.id = 'lvResetBtn';
resetBtn.href = "{{ route('mobilisasi.index') }}";
resetBtn.className = "text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0";
const resetIcon = document.createElement('i');
resetIcon.className = "fa-solid fa-rotate-left text-[11px]";
const resetText = document.createElement('span');
resetText.textContent = "Reset Filter";
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
});
});
</script>
@endsection
+425
View File
@@ -0,0 +1,425 @@
@extends('layouts.app')
@section('title', 'Form P2H Unit Support - ' . $vehicle->code)
@section('content')
<div class="max-w-3xl mx-auto space-y-4">
<!-- Navigasi Kembali & Logo -->
<div class="flex items-center justify-between pb-1">
<a href="{{ route('p2h.index') }}" class="inline-flex items-center space-x-1.5 text-xs font-bold text-slate-600 hover:text-[#1b5e20] transition bg-white px-3 py-1.5 rounded-xl border border-slate-200 shadow-sm">
<i class="fa-solid fa-arrow-left text-[11px]"></i>
<span>Kembali ke Katalog Unit</span>
</a>
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-7 w-auto object-contain">
</div>
<!-- Header Info Unit Support (Readonly Card - Selaras dengan Form LV) -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 text-white p-5 rounded-2xl shadow-sm border 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-amber-500/20 text-amber-300 border border-amber-500/30">
Unit Support
</span>
<span class="text-xs text-slate-400 flex items-center">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse mr-1.5"></span>
Checksheet: <span class="text-emerald-300 font-bold ml-1">{{ $template->code ?? 'P2H' }}</span>
</span>
</div>
<h2 class="text-xl font-bold tracking-tight text-white mb-3">Pemeriksaan Pra-Harian (P2H) Unit Support</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-xl border border-slate-700/80">
<div><span class="text-slate-400 font-medium">Kode Unit:</span> <span class="font-black text-white text-sm ml-1">{{ $vehicle->code }}</span></div>
<div><span class="text-slate-400 font-medium">Kategori Alat:</span> <span class="font-bold text-amber-300 text-sm ml-1">{{ $vehicle->unit_category ?? ($template->name ?? '-') }}</span></div>
<div class="col-span-1 sm:col-span-2"><span class="text-slate-400 font-medium">Merek / Tipe Model:</span> <span class="text-white ml-1 font-semibold">{{ $vehicle->brand_type }}</span></div>
<div><span class="text-slate-400 font-medium">Lokasi Operasi:</span> <span class="text-slate-200 ml-1">{{ $vehicle->location ?? '-' }}</span></div>
<div><span class="text-slate-400 font-medium">HM Terakhir:</span> <span class="font-bold text-emerald-400 text-sm ml-1">{{ number_format($vehicle->current_km, 1, ',', '.') }} HM</span></div>
</div>
</div>
<!-- Alert Jika Terjadi Masalah SIMPER atau Autentikasi -->
@if($simperError)
@if(auth()->user()->isQmaAdmin() || auth()->user()->isSuperAdmin())
<div class="p-4 sm:p-5 bg-blue-50 border border-blue-200 rounded-2xl text-blue-900 text-xs flex items-start space-x-3.5 shadow-sm">
<div class="w-9 h-9 rounded-xl bg-blue-100 text-blue-700 flex items-center justify-center font-bold text-base flex-shrink-0">
<i class="fa-solid fa-user-shield"></i>
</div>
<div class="flex-1">
<span class="font-bold block text-sm mb-1 text-blue-950">Wewenang Role: Admin QMA (Validator / Verifikator)</span>
<p class="leading-relaxed text-blue-800">{{ $simperError }}</p>
<div class="mt-3 flex items-center gap-2">
<a href="{{ route('qma.p2h.index') }}"
class="inline-flex items-center justify-center space-x-1.5 px-3 py-2 sm:px-3.5 sm:py-1.5 rounded-xl bg-[#1b5e20] text-white font-bold text-xs hover:bg-[#144919] transition shadow-xs flex-shrink-0"
title="Buka Verifikasi & Approval P2H di Menu QMA">
<i class="fa-solid fa-clipboard-check text-xs"></i>
<span class="hidden sm:inline">Buka Verifikasi & Approval P2H di Menu QMA</span>
</a>
<a href="{{ route('p2h.index') }}" class="inline-flex items-center justify-center space-x-1 px-3 py-2 sm:py-1.5 rounded-xl bg-white border border-blue-200 text-blue-700 font-semibold text-xs hover:bg-blue-100/50 transition">
<span>Kembali ke Katalog Unit</span>
</a>
</div>
</div>
</div>
@else
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl text-rose-800 text-xs flex items-start space-x-3 shadow-sm">
<div class="w-8 h-8 rounded-xl bg-rose-100 text-rose-600 flex items-center justify-center font-bold text-base flex-shrink-0">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<div class="flex-1">
<span class="font-bold block text-sm mb-0.5 text-rose-900">Akses Pengoperasian Tidak Diizinkan</span>
<p class="leading-relaxed">{{ $simperError }}</p>
<p class="mt-2 text-[11px] font-semibold text-rose-700">Hubungi Divisi HSE untuk pendaftaran atau perpanjangan lisensi SIMPER Anda.</p>
</div>
</div>
@endif
@endif
<!-- Card Operator Terverifikasi (Otomatis Terisi dari Akun Login) -->
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-4 sm:p-5 flex items-center justify-between gap-3">
<div class="flex items-center space-x-3 min-w-0">
@if(auth()->user()->isQmaAdmin() || auth()->user()->isSuperAdmin())
<div class="w-10 h-10 rounded-full bg-blue-100 text-blue-700 flex items-center justify-center font-bold text-base flex-shrink-0">
<i class="fa-solid fa-user-shield"></i>
</div>
<div class="min-w-0">
<div class="flex items-center space-x-2 flex-wrap">
<span class="text-sm font-bold text-slate-900">{{ auth()->user()->name }}</span>
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-blue-100 text-blue-800">
<i class="fa-solid fa-shield-halved mr-1"></i> Admin QMA
</span>
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
<i class="fa-solid fa-lock text-slate-400 mr-1"></i> Akun Login Terverifikasi
</span>
</div>
<p class="text-xs text-slate-500 mt-0.5 truncate">
<span>Username: {{ auth()->user()->username }}</span> &bull;
<span>Departemen QMA</span> &bull;
<span class="text-blue-700 font-medium">Wewenang: Verifikator / Validator</span>
</p>
</div>
@else
<div class="w-10 h-10 rounded-full {{ $employee && $employee->hasValidSimper() ? 'bg-emerald-100 text-[#1b5e20]' : 'bg-rose-100 text-rose-700' }} flex items-center justify-center font-bold text-base flex-shrink-0">
<i class="fa-solid {{ $employee && $employee->hasValidSimper() ? 'fa-user-check' : 'fa-user-xmark' }}"></i>
</div>
<div class="min-w-0">
<div class="flex items-center space-x-2 flex-wrap">
<span class="text-sm font-bold text-slate-900">{{ $employee->name ?? auth()->user()->name }}</span>
@if($employee && $employee->hasValidSimper())
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-emerald-100 text-emerald-800">
<i class="fa-solid fa-shield-check mr-1"></i> SIMPER Aktif
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold bg-rose-100 text-rose-800">
<i class="fa-solid fa-circle-xmark mr-1"></i> SIMPER Tidak Aktif
</span>
@endif
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
<i class="fa-solid fa-lock text-slate-400 mr-1"></i> Akun Login Terverifikasi
</span>
</div>
<p class="text-xs text-slate-500 mt-0.5 truncate">
<span>NIK: {{ $employee->nik ?? auth()->user()->username }}</span> &bull;
<span>{{ $employee->division ?? 'Operasional' }}</span> &bull;
<span class="{{ $employee && $employee->hasValidSimper() ? 'text-emerald-700 font-medium' : 'text-rose-700 font-medium' }}">
Masa Berlaku: {{ $employee && $employee->simper_expired_at ? $employee->simper_expired_at->format('d/m/Y') : 'Tidak Ada' }}
</span>
</p>
</div>
@endif
</div>
</div>
<!-- Form Utama P2H Unit Support -->
<form action="{{ route('p2h.store', ['code' => $vehicle->code]) }}" method="POST" id="p2hForm" class="space-y-4">
@csrf
<input type="hidden" name="template_id" value="{{ $template->id }}">
<!-- Card Input Operasional (Hour Meter) -->
<input type="hidden" name="shift" value="Shift 1 (Siang)">
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-4 sm:p-5">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div>
<label for="start_hm" class="block text-xs font-bold uppercase tracking-wider text-slate-700">
Hour Meter (HM) Saat Ini <span class="text-rose-500">*</span>
</label>
<p class="text-xs text-slate-400 mt-0.5">HM sebelumnya: <span class="font-semibold text-slate-600">{{ number_format($vehicle->current_km, 1, ',', '.') }} HM</span></p>
</div>
<div class="relative w-full sm:w-64">
<input type="number" step="0.1" name="start_hm" id="start_hm"
value="{{ old('start_hm', $vehicle->current_km) }}"
min="{{ $vehicle->current_km }}"
required
placeholder="0,00"
class="w-full rounded-xl border border-slate-300 bg-white pl-4 pr-12 py-2.5 text-sm text-slate-800 font-bold focus:border-emerald-500 focus:ring-4 focus:ring-emerald-500/10 transition">
<div class="absolute inset-y-0 right-0 pr-3.5 flex items-center pointer-events-none text-xs font-extrabold text-slate-400">
HM
</div>
</div>
</div>
</div>
@php
$sectionKeys = [];
foreach ($groupedItems as $sName => $sItems) {
$sectionKeys[] = 'sec_' . md5($sName);
}
@endphp
<!-- Section Kuesioner P2H dengan Format Tab Horizontal Kesamping -->
<div class="space-y-3">
<!-- Header Judul & Tombol Tandai Semua Baik -->
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-2.5 px-1">
<div>
<h3 class="font-extrabold text-slate-900 text-base">Checklist Pemeriksaan Kelaikan (P2H)</h3>
<p class="text-xs text-slate-500">Pilih opsi <strong>Baik</strong> jika kondisi normal, atau <strong>Rusak</strong> jika ada abnormalitas.</p>
</div>
<button type="button" onclick="setAllBaik()" class="text-xs font-bold text-[#1b5e20] hover:text-[#144918] bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 px-3 py-1.5 rounded-xl transition flex items-center justify-center space-x-1.5 shadow-sm self-start sm:self-auto cursor-pointer">
<i class="fa-solid fa-check-double text-[11px]"></i>
<span>Tandai Semua Baik</span>
</button>
</div>
<!-- 1. Baris Section Horizontal (Dari Kiri ke Kanan Sesuai Format Master Template) -->
<div class="flex items-center gap-2 overflow-x-auto pb-2 scrollbar-thin" id="p2hTabsContainer">
@foreach($groupedItems as $sectionName => $itemsInSection)
@php
$secKey = 'sec_' . md5($sectionName);
$isFirst = $loop->first;
@endphp
<button type="button"
onclick="switchP2hSection('{{ $secKey }}')"
id="p2h-tab-{{ $secKey }}"
data-section-key="{{ $secKey }}"
class="p2h-section-tab group inline-flex items-center px-4 py-2.5 rounded-xl text-xs font-bold transition whitespace-nowrap cursor-pointer shrink-0 {{ $isFirst ? 'bg-[#1b5e20] text-white shadow-xs border border-[#1b5e20]' : 'bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 hover:border-slate-300' }}">
<span>{{ $sectionName }}</span>
</button>
@endforeach
</div>
<!-- 2. Panel Konten List Pertanyaan Berdasarkan Section yang Dipilih -->
<div id="p2hPanelsContainer" class="space-y-4">
@foreach($groupedItems as $sectionName => $itemsInSection)
@php
$secKey = 'sec_' . md5($sectionName);
$isFirst = $loop->first;
$prevKey = isset($sectionKeys[$loop->index - 1]) ? $sectionKeys[$loop->index - 1] : null;
$nextKey = isset($sectionKeys[$loop->index + 1]) ? $sectionKeys[$loop->index + 1] : null;
@endphp
<div class="p2h-section-content bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden transition-all duration-200 {{ $isFirst ? '' : 'hidden' }}"
id="p2h-content-{{ $secKey }}">
<!-- Header Panel Section Aktif Sesuai Referensi Master Template -->
<div class="p-4 sm:p-5 border-b border-slate-100 flex items-center justify-between gap-3 bg-white">
<div class="min-w-0">
<div class="flex flex-wrap items-center gap-2 sm:gap-3">
<h3 class="font-bold text-slate-900 text-base sm:text-lg tracking-tight truncate">
{{ $sectionName }}
</h3>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-50 text-[#1b5e20] border border-emerald-200/80">
{{ count($itemsInSection) }} Pertanyaan
</span>
</div>
<p class="text-xs text-slate-400 mt-0.5 truncate hidden sm:block">
Daftar butir pertanyaan inspeksi pra-harian pada bagian ini.
</p>
</div>
</div>
<!-- List Pertanyaan di Bagian Ini -->
<div class="divide-y divide-slate-100 p-2 sm:p-4 space-y-1">
@foreach($itemsInSection as $item)
<div class="p-3 rounded-xl hover:bg-slate-50/70 transition space-y-2">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div class="flex-1 pr-2">
<div class="flex items-start space-x-2">
<span class="text-xs font-bold text-slate-400 mt-0.5">{{ $item->sequence ?? $loop->iteration }}.</span>
<span class="text-xs font-semibold text-slate-800 leading-snug">{{ $item->title }}</span>
</div>
</div>
@if(in_array($item->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix']))
<!-- Opsi Jawaban Radio: Baik & Rusak -->
<div class="flex items-center space-x-2 flex-shrink-0">
<label class="cursor-pointer">
<input type="radio"
name="items[{{ $item->id }}][condition]"
value="baik"
checked
onchange="handleConditionChange({{ $item->id }}, 'baik')"
class="peer sr-only">
<span class="inline-flex items-center justify-center min-w-[62px] px-3.5 py-1.5 rounded-xl text-xs font-bold border border-slate-300 text-slate-600 bg-white peer-checked:bg-[#1b5e20] peer-checked:text-white peer-checked:border-[#1b5e20] peer-checked:shadow-sm transition">
<span>Baik</span>
</span>
</label>
<label class="cursor-pointer">
<input type="radio"
name="items[{{ $item->id }}][condition]"
value="rusak"
onchange="handleConditionChange({{ $item->id }}, 'rusak')"
class="peer sr-only">
<span class="inline-flex items-center justify-center space-x-1.5 min-w-[68px] px-3.5 py-1.5 rounded-xl text-xs font-bold border border-slate-300 text-slate-600 bg-white peer-checked:bg-rose-600 peer-checked:text-white peer-checked:border-rose-600 peer-checked:shadow-sm transition">
<i class="fa-solid fa-triangle-exclamation text-[11px]"></i>
<span>Rusak</span>
</span>
</label>
</div>
@elseif(in_array($item->question_type, ['multiple_choice', 'Multiple choice: multiple answers allowed']))
<!-- Checkbox Pilihan Ganda -->
<div class="flex items-center space-x-2 flex-shrink-0">
<label class="cursor-pointer inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-xl text-xs font-bold border border-slate-300 text-slate-700 bg-white hover:bg-slate-50 transition">
<input type="checkbox"
name="items[{{ $item->id }}][answer]"
value="Sesuai"
class="rounded text-[#1b5e20] focus:ring-[#1b5e20]">
<span>Sesuai Standar</span>
</label>
</div>
@elseif(in_array($item->question_type, ['number', 'Numerical Value']))
<div class="sm:w-48 flex-shrink-0">
<input type="number" step="0.1" name="items[{{ $item->id }}][answer]" placeholder="Nilai angka..." class="w-full text-xs font-semibold px-3 py-1.5 rounded-xl border border-slate-300 focus:border-emerald-500">
</div>
@elseif(in_array($item->question_type, ['date', 'Date']))
<div class="sm:w-48 flex-shrink-0">
<input type="date" name="items[{{ $item->id }}][answer]" value="{{ date('Y-m-d') }}" class="w-full text-xs font-semibold px-3 py-1.5 rounded-xl border border-slate-300 focus:border-emerald-500">
</div>
@elseif(in_array($item->question_type, ['datetime', 'Datetime']))
<div class="sm:w-48 flex-shrink-0">
<input type="datetime-local" name="items[{{ $item->id }}][answer]" value="{{ date('Y-m-d\TH:i') }}" class="w-full text-xs font-semibold px-3 py-1.5 rounded-xl border border-slate-300 focus:border-emerald-500">
</div>
@elseif(in_array($item->question_type, ['textarea', 'Multiple Lines Text Box']))
<div class="sm:w-72 flex-shrink-0">
<textarea rows="2" name="items[{{ $item->id }}][answer]" placeholder="Catatan lengkap..." class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-300 focus:border-emerald-500"></textarea>
</div>
@else
<div class="sm:w-64 flex-shrink-0">
<input type="text" name="items[{{ $item->id }}][answer]" placeholder="Catatan singkat..." class="w-full text-xs px-3 py-1.5 rounded-xl border border-slate-300 focus:border-emerald-500">
</div>
@endif
</div>
<!-- Box Keterangan Tambahan Jika Rusak -->
<div id="notes_box_{{ $item->id }}" class="hidden mt-2 pt-2 border-t border-rose-100/80 transition-all">
<div class="relative flex items-center">
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-rose-500 text-xs">
<i class="fa-solid fa-triangle-exclamation"></i>
</span>
<input type="text"
name="items[{{ $item->id }}][notes]"
placeholder="Jelaskan detail kerusakan pada bagian ini..."
class="w-full text-xs pl-10 pr-3.5 py-2 rounded-xl border border-rose-300 bg-rose-50/50 text-rose-900 placeholder:text-rose-400 focus:outline-none focus:border-rose-600 focus:ring-2 focus:ring-rose-500/20 shadow-2xs transition">
</div>
</div>
</div>
@endforeach
</div>
<!-- Navigasi Cepat Antar Section (Sebelumnya & Selanjutnya) -->
@if(count($groupedItems) > 1)
<div class="px-4 py-3 bg-slate-50/80 border-t border-slate-100 flex items-center justify-between">
@if($prevKey)
<button type="button"
onclick="switchP2hSection('{{ $prevKey }}')"
class="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-slate-600 hover:text-slate-900 bg-white border border-slate-200 hover:bg-slate-100 transition shadow-2xs cursor-pointer">
<i class="fa-solid fa-chevron-left text-[10px]"></i>
<span>Bagian Sebelumnya</span>
</button>
@else
<div></div>
@endif
@if($nextKey)
<button type="button"
onclick="switchP2hSection('{{ $nextKey }}')"
class="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-bold text-emerald-800 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 transition shadow-2xs cursor-pointer">
<span>Bagian Selanjutnya</span>
<i class="fa-solid fa-chevron-right text-[10px]"></i>
</button>
@else
<span class="text-[11px] font-semibold text-slate-400 flex items-center">
<i class="fa-solid fa-flag-checkered mr-1.5 text-emerald-600"></i> Bagian Terakhir
</span>
@endif
</div>
@endif
</div>
@endforeach
</div>
</div>
<!-- Card Catatan Umum Operator -->
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-5 space-y-3">
<label for="general_notes" class="block text-xs font-bold uppercase tracking-wider text-slate-700">
Catatan Umum / Keterangan Tambahan Operator
</label>
<textarea name="general_notes" id="general_notes" rows="3" placeholder="Tuliskan temuan atau catatan umum lainnya mengenai kondisi unit support hari ini..." class="w-full rounded-xl border border-slate-300 bg-white px-3.5 py-2.5 text-xs text-slate-800 focus:border-emerald-500 focus:ring-4 focus:ring-emerald-500/10 transition resize-none">{{ old('general_notes') }}</textarea>
</div>
<!-- Tombol Aksi Submit -->
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-4 sm:p-5 flex items-center justify-between gap-3">
<a href="{{ route('p2h.index') }}" class="bg-slate-100 hover:bg-slate-200 text-slate-600 font-semibold py-2.5 px-4 rounded-xl transition text-xs">
Batal
</a>
<button type="submit"
id="btnSubmitP2h"
{{ $simperError ? 'disabled' : '' }}
class="bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-2.5 px-6 rounded-xl shadow-sm hover:shadow transition flex items-center space-x-2 text-xs sm:text-sm disabled:bg-slate-200 disabled:text-slate-400 disabled:cursor-not-allowed cursor-pointer">
<i class="fa-solid fa-paper-plane text-xs"></i>
<span>Kirim Formulir P2H ke QMA</span>
</button>
</div>
</form>
</div>
@endsection
@section('scripts')
<script>
function switchP2hSection(secKey) {
// 1. Update tab styling
const allTabs = document.querySelectorAll('.p2h-section-tab');
allTabs.forEach(tab => {
const key = tab.dataset.sectionKey;
if (key === secKey) {
tab.className = 'p2h-section-tab group inline-flex items-center px-4 py-2.5 rounded-xl text-xs font-bold transition whitespace-nowrap cursor-pointer shrink-0 bg-[#1b5e20] text-white shadow-xs border border-[#1b5e20]';
tab.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
} else {
tab.className = 'p2h-section-tab group inline-flex items-center px-4 py-2.5 rounded-xl text-xs font-bold transition whitespace-nowrap cursor-pointer shrink-0 bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 hover:border-slate-300';
}
});
// 2. Show active panel, hide others
const allPanels = document.querySelectorAll('.p2h-section-content');
allPanels.forEach(panel => {
if (panel.id === 'p2h-content-' + secKey) {
panel.classList.remove('hidden');
} else {
panel.classList.add('hidden');
}
});
}
function handleConditionChange(itemId, condition) {
const notesBox = document.getElementById('notes_box_' + itemId);
if (notesBox) {
if (condition === 'rusak') {
notesBox.classList.remove('hidden');
const input = notesBox.querySelector('input');
if (input) input.focus();
} else {
notesBox.classList.add('hidden');
}
}
}
function setAllBaik() {
const radiosBaik = document.querySelectorAll('input[type="radio"][value="baik"]');
radiosBaik.forEach(r => {
r.checked = true;
const match = r.name.match(/items\[(\d+)\]/);
if (match && match[1]) {
handleConditionChange(match[1], 'baik');
}
});
}
</script>
@endsection
+263
View File
@@ -0,0 +1,263 @@
@extends('layouts.app')
@section('title', 'Pemeriksaan Pra-Harian (P2H) Unit Support')
@section('content')
<div class="w-full space-y-6">
<!-- Header Halaman Simple Kayak Satpam (Seamless, Tanpa Card Wrapper) -->
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-slate-200/80">
<div class="min-w-0">
<div class="flex items-center flex-wrap gap-2.5">
<h1 class="text-lg sm:text-xl font-black text-slate-900 tracking-tight">
Katalog Pemeriksaan Pra-Harian (P2H)
</h1>
<span class="px-2.5 py-1 rounded-lg text-xs font-black bg-amber-50 text-amber-800 border border-amber-200">
Unit Support
</span>
</div>
<div class="text-sm sm:text-base text-slate-600 font-medium truncate mt-1 flex items-center flex-wrap gap-1.5">
<span>Operator: <strong class="text-slate-900 font-bold">{{ $employee ? $employee->name : auth()->user()->name }}</strong></span>
@if($employee && $employee->nik)
<span class="text-slate-500 font-mono text-xs sm:text-sm font-semibold">({{ $employee->nik }})</span>
@endif
@if($employee && $employee->hasValidSimper())
<span class="inline-flex items-center text-[10px] font-bold text-emerald-700 bg-emerald-100/80 px-2 py-0.5 rounded-md ml-1">
<i class="fa-solid fa-circle-check mr-1 text-emerald-600"></i> SIMPER Aktif
</span>
@elseif($employee)
<span class="inline-flex items-center text-[10px] font-bold text-rose-700 bg-rose-100/80 px-2 py-0.5 rounded-md ml-1">
<i class="fa-solid fa-circle-xmark mr-1 text-rose-600"></i> SIMPER Exp
</span>
@endif
</div>
</div>
</div>
<!-- Filter & Search Bar (Tanpa Card Wrapper, Format Referensi Data Karyawan) -->
<form method="GET" action="{{ route('p2h.index') }}" id="p2hFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
<!-- Pencarian Cepat di Kiri -->
<div class="relative w-full 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"
name="search"
id="p2hSearchInput"
value="{{ request('search') }}"
placeholder="Cari kode unit (EX01), model, atau lokasi..."
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-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
</div>
<!-- Filter Dropdown & Tombol di Kanan -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-2 sm:gap-2.5 w-full sm:w-auto">
<div class="w-full sm:w-auto">
<select name="unit_category"
id="p2hCategorySelect"
onchange="this.form.submit()"
class="w-full sm:w-auto text-xs rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition truncate">
<option value="">Semua Kategori Alat</option>
@foreach($categories as $cat)
<option value="{{ $cat }}" {{ request('unit_category') == $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
</div>
<!-- Tombol Reset Filter (Merah / Rose Clean Text Persis Halaman Karyawan) -->
<div id="p2hResetContainer">
@if(request()->anyFilled(['search', 'unit_category']))
<a href="{{ route('p2h.index') }}"
id="p2hResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
</form>
<!-- Grid Kartu Unit Support -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" id="p2hCardsContainer">
@forelse($vehicles as $v)
<div class="p2h-card bg-white rounded-2xl border border-slate-200 shadow-sm hover:shadow-md transition p-5 flex flex-col justify-between">
<div>
<!-- Badge Kategori & Status -->
<div class="flex items-center justify-between mb-3">
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-[11px] font-bold bg-amber-50 text-amber-800 border border-amber-200">
{{ $v->unit_category ?? 'Unit Support' }}
</span>
@php
$statusBadge = match($v->status) {
'Operation' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
'Standby' => 'bg-amber-50 text-amber-700 border-amber-200',
'Breakdown' => 'bg-rose-50 text-rose-700 border-rose-200',
default => 'bg-slate-50 text-slate-700 border-slate-200',
};
@endphp
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold border {{ $statusBadge }}">
{{ $v->status }}
</span>
</div>
<!-- Kode & Tipe Unit -->
<h3 class="text-lg font-black text-slate-900 leading-tight">{{ $v->code }}</h3>
<p class="text-xs text-slate-600 font-medium mt-0.5 line-clamp-1">{{ $v->brand_type }}</p>
<!-- Info Atribut -->
<div class="mt-4 space-y-1.5 text-xs text-slate-500 bg-slate-50 p-3 rounded-xl border border-slate-100">
<div class="flex items-center justify-between">
<span class="text-slate-400">Hour Meter (HM):</span>
<span class="font-extrabold text-slate-800">{{ number_format($v->current_km, 1, ',', '.') }} HM</span>
</div>
<div class="flex items-center justify-between">
<span class="text-slate-400">Lokasi Operasional:</span>
<span class="font-semibold text-slate-700 truncate max-w-[150px]">{{ $v->location ?? '-' }}</span>
</div>
<div class="flex items-center justify-between">
<span class="text-slate-400">Checksheet P2H:</span>
<span class="font-bold text-[#1b5e20] truncate max-w-[150px]">
{{ $v->p2hTemplate ? $v->p2hTemplate->name : ($v->unit_category ?? 'Standar') }}
</span>
</div>
</div>
</div>
<!-- Tombol Buka Form P2H -->
<div class="mt-5 pt-3 border-t border-slate-100">
<a href="{{ route('p2h.form', ['code' => $v->code]) }}" class="w-full bg-[#1b5e20] hover:bg-[#144918] active:scale-[0.99] text-white font-bold py-2.5 px-4 rounded-xl shadow-sm transition text-center block text-xs">
Isi Formulir P2H Unit
</a>
</div>
</div>
@empty
<div id="p2hServerEmptyCard" class="col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center">
<div class="w-16 h-16 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
</div>
@if(request('search'))
<h3 class="text-base font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h3>
<p class="text-xs text-slate-500 mt-1">Pastikan kode unit atau kategori alat berat yang dicari sudah benar.</p>
<div class="mt-4">
<a href="{{ route('p2h.index') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<h3 class="text-base font-bold text-slate-800">Unit Support Tidak Ditemukan</h3>
<p class="text-xs text-slate-500 mt-1">Coba sesuaikan kata kunci pencarian atau filter kategori alat berat Anda.</p>
@endif
</div>
@endforelse
</div>
<!-- Pagination -->
@if($vehicles->hasPages())
<div class="bg-white p-4 rounded-2xl border border-slate-200 shadow-sm" id="p2hPaginationContainer">
{{ $vehicles->links() }}
</div>
@endif
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Search Real-Time Client-Side
const searchInput = document.getElementById('p2hSearchInput');
const resetContainer = document.getElementById('p2hResetContainer');
const cardsContainer = document.getElementById('p2hCardsContainer');
const paginationContainer = document.getElementById('p2hPaginationContainer');
const serverEmptyCard = document.getElementById('p2hServerEmptyCard');
const hasServerFilters = {{ request()->anyFilled(['search', 'unit_category']) ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
searchInput?.addEventListener('input', function(e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
// Pencarian multi-field ke kartu/baris unit
const items = document.querySelectorAll('#p2hCardsContainer .p2h-card, #p2hCardsContainer tr.p2h-row');
let visibleCount = 0;
items.forEach(item => {
const text = item.textContent.toLowerCase();
const match = text.includes(query);
item.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan pesan SSR kosong saat mengetik
if (serverEmptyCard) {
serverEmptyCard.style.display = query.length > 0 ? 'none' : '';
}
// Hapus pesan kosong pencarian jika ada sebelumnya
const existingEmptyCard = document.getElementById('p2hEmptySearchCard');
if (existingEmptyCard) {
existingEmptyCard.remove();
}
// Tampilkan pesan kosong jika tidak ada data yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyDiv = document.createElement('div');
emptyDiv.id = 'p2hEmptySearchCard';
emptyDiv.className = 'col-span-full bg-white rounded-2xl border border-slate-200 p-12 text-center shadow-sm';
emptyDiv.innerHTML = `
<div class="w-16 h-16 rounded-full bg-rose-50 text-rose-500 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass text-2xl"></i>
</div>
<h3 class="text-base font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h3>
<p class="text-xs text-slate-500 mt-1">
Pastikan kode unit atau kategori alat berat yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('p2hSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
`;
cardsContainer?.appendChild(emptyDiv);
}
// Sembunyikan pagination saat client-side search aktif
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
// Tampilkan/sembunyikan tombol Reset Filter (merah fa-rotate-left) secara real-time
let resetBtn = document.getElementById('p2hResetBtn');
if (query.length > 0) {
if (!resetBtn && resetContainer) {
resetBtn = document.createElement('a');
resetBtn.id = 'p2hResetBtn';
resetBtn.href = "{{ route('p2h.index') }}";
resetBtn.className = "text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center justify-center sm:justify-start space-x-1.5 transition whitespace-nowrap py-1 sm:py-0 sm:ml-2";
const resetIcon = document.createElement('i');
resetIcon.className = "fa-solid fa-rotate-left text-[11px]";
const resetText = document.createElement('span');
resetText.textContent = "Reset Filter";
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
});
});
</script>
@endsection
+15 -4
View File
@@ -196,12 +196,12 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverGuardEmptyRow">
<td colspan="7" class="py-12 text-center text-slate-400"> <td colspan="7" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i> <i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search')) @if(request('search'))
<p class="text-sm font-semibold text-slate-700"> <p class="text-sm font-semibold text-slate-700">
<span class="inline-block mr-1">🔍</span>Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p> </p>
<p class="text-xs text-slate-400 mt-1">Pastikan ejaan ID Satpam atau nama petugas yang dicari sudah benar.</p> <p class="text-xs text-slate-400 mt-1">Pastikan ejaan ID Satpam atau nama petugas yang dicari sudah benar.</p>
@elseif(request()->anyFilled(['team', 'gate_id'])) @elseif(request()->anyFilled(['team', 'gate_id']))
@@ -226,6 +226,12 @@
</tbody> </tbody>
</table> </table>
</div> </div>
@if($guards->hasPages())
<div class="p-4 border-t border-slate-100 bg-white">
{{ $guards->links() }}
</div>
@endif
</div> </div>
</div> </div>
@@ -636,6 +642,11 @@
if (match) visibleCount++; if (match) visibleCount++;
}); });
const serverEmptyRow = document.getElementById('serverGuardEmptyRow');
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian jika ada sebelumnya // Hapus baris pesan kosong pencarian jika ada sebelumnya
const existingEmptyRow = document.getElementById('guardEmptySearchRow'); const existingEmptyRow = document.getElementById('guardEmptySearchRow');
if (existingEmptyRow) { if (existingEmptyRow) {
@@ -643,14 +654,14 @@
} }
// Tampilkan pesan jika tidak ada data yang cocok di tabel // Tampilkan pesan jika tidak ada data yang cocok di tabel
if (rows.length > 0 && visibleCount === 0 && query.length > 0) { if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr'); const emptyTr = document.createElement('tr');
emptyTr.id = 'guardEmptySearchRow'; emptyTr.id = 'guardEmptySearchRow';
emptyTr.innerHTML = ` emptyTr.innerHTML = `
<td colspan="7" class="py-12 text-center text-slate-400"> <td colspan="7" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i> <i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700"> <p class="text-sm font-semibold text-slate-700">
<span class="inline-block mr-1">🔍</span>Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p> </p>
<p class="text-xs text-slate-400 mt-1"> <p class="text-xs text-slate-400 mt-1">
Pastikan ejaan ID Satpam atau nama petugas yang dicari sudah benar. Pastikan ejaan ID Satpam atau nama petugas yang dicari sudah benar.
@@ -366,7 +366,7 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverVerificationEmptyRow">
<td colspan="10" class="py-12 text-center text-slate-400"> <td colspan="10" class="py-12 text-center text-slate-400">
<div class="flex flex-col items-center justify-center space-y-2"> <div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-lg"> <div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-lg">
@@ -535,6 +535,11 @@
if (match) visibleCount++; if (match) visibleCount++;
}); });
const serverEmptyRow = document.getElementById('serverVerificationEmptyRow');
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian jika ada sebelumnya // Hapus baris pesan kosong pencarian jika ada sebelumnya
const existingEmptyRow = document.getElementById('verificationEmptySearchRow'); const existingEmptyRow = document.getElementById('verificationEmptySearchRow');
if (existingEmptyRow) { if (existingEmptyRow) {
@@ -542,7 +547,7 @@
} }
// Tampilkan pesan instan jika tidak ada baris yang cocok di tabel // Tampilkan pesan instan jika tidak ada baris yang cocok di tabel
if (rows.length > 0 && visibleCount === 0 && query.length > 0) { if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr'); const emptyTr = document.createElement('tr');
emptyTr.id = 'verificationEmptySearchRow'; emptyTr.id = 'verificationEmptySearchRow';
emptyTr.innerHTML = ` emptyTr.innerHTML = `
@@ -4,8 +4,16 @@
@section('content') @section('content')
<div class="max-w-2xl mx-auto space-y-4"> <div class="max-w-2xl mx-auto space-y-4">
<!-- Logo Perusahaan KMH --> <!-- Navigasi Kembali & Logo Perusahaan KMH -->
<div class="flex items-center justify-center pb-1"> <div class="flex items-center justify-between pb-1">
@if(auth()->check())
<a href="{{ route('mobilisasi.index') }}" class="inline-flex items-center space-x-1.5 text-xs font-bold text-slate-600 hover:text-[#1b5e20] transition bg-white px-3 py-1.5 rounded-xl border border-slate-200 shadow-sm">
<i class="fa-solid fa-arrow-left text-[11px]"></i>
<span>Kembali ke Katalog LV</span>
</a>
@else
<div></div>
@endif
<img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-8 w-auto object-contain"> <img src="{{ asset('images/logo-kerinci.png') }}" alt="Kerinci Hydropower" class="h-8 w-auto object-contain">
</div> </div>
+76 -43
View File
@@ -1,6 +1,6 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', 'Log Aktivitas Kendaraan QMA') @section('title', 'Timesheet LV QMA')
@section('content') @section('content')
<div class="w-full space-y-6"> <div class="w-full space-y-6">
@@ -15,12 +15,12 @@
<button type="button" <button type="button"
onclick="openGuideModal()" onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none" class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Log Aktivitas Kendaraan"> title="Panduan Halaman Timesheet LV">
<i class="fa-solid fa-info"></i> <i class="fa-solid fa-info"></i>
</button> </button>
</div> </div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight"> <h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Log Aktivitas Kendaraan Timesheet LV
</h2> </h2>
</div> </div>
@@ -286,46 +286,48 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverActivityEmptyRow">
<td colspan="11" class="py-12 px-4 text-center"> <td colspan="11" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3"> <div class="flex flex-col items-center justify-center space-y-3">
<div class="w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-2xl"> <div class="w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-2xl">
<i class="fa-solid fa-route"></i> <i class="fa-solid fa-magnifying-glass"></i>
</div> </div>
<div class="text-sm font-bold text-slate-700">Belum Ada Data Log Aktivitas</div> @if(request('search'))
<p class="text-xs text-slate-400 max-w-sm"> <p class="text-sm font-semibold text-slate-700">
Tidak ditemukan catatan aktivitas kendaraan yang sesuai dengan kriteria filter saat ini. Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p> </p>
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'gate_id', 'direction', 'status'])) <p class="text-xs text-slate-400 mt-1">
<a href="{{ route('qma.activity.log') }}" class="mt-2 inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-[#1b5e20] bg-emerald-50 border border-emerald-200 hover:bg-emerald-100 transition"> Pastikan kata kunci yang dicari sudah benar.
<i class="fa-solid fa-rotate-left text-[11px]"></i> </p>
<span>Reset Filter</span> <div class="mt-4">
</a> <a href="{{ route('qma.activity.log') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Log Aktivitas</div>
<p class="text-xs text-slate-400 max-w-sm">
Tidak ditemukan catatan aktivitas kendaraan yang sesuai dengan kriteria filter saat ini.
</p>
@if(request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']))
<a href="{{ route('qma.activity.log') }}" class="mt-2 inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-[#1b5e20] bg-emerald-50 border border-emerald-200 hover:bg-emerald-100 transition">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
@endif @endif
</div> </div>
</td> </td>
</tr> </tr>
@endforelse @endforelse
<!-- Baris Hasil Pencarian Real-Time Kosong -->
<tr id="clientSearchEmptyRow" class="hidden">
<td colspan="11" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-xl">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<div class="text-sm font-bold text-slate-700">Tidak Ada Hasil Pencarian</div>
<p class="text-xs text-slate-400">Tidak ditemukan log aktivitas yang sesuai dengan kata kunci pencarian Anda.</p>
</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Pagination --> <!-- Pagination -->
@if($activities->hasPages()) @if($activities->hasPages())
<div class="p-4 bg-slate-50 border-t border-slate-100"> <div id="activityPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-100">
{{ $activities->links() }} {{ $activities->links() }}
</div> </div>
@endif @endif
@@ -333,16 +335,24 @@
</div> </div>
<script> <script>
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('activityLogSearchInput'); const searchInput = document.getElementById('activityLogSearchInput');
const tableBody = document.getElementById('activityLogTableBody'); const tableBody = document.getElementById('activityLogTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer'); const resetContainer = document.getElementById('headerResetFilterContainer');
const emptyRow = document.getElementById('clientSearchEmptyRow'); const paginationContainer = document.getElementById('activityPaginationContainer');
const serverEmptyRow = document.getElementById('serverActivityEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']) ? 'true' : 'false' }}; const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'gate_id', 'direction', 'status']) ? 'true' : 'false' }};
if (searchInput && tableBody) { if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) { searchInput.addEventListener('input', function (e) {
const query = e.target.value.toLowerCase().trim(); const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.activity-row'); const rows = tableBody.querySelectorAll('tr.activity-row');
let visibleCount = 0; let visibleCount = 0;
@@ -356,16 +366,42 @@ document.addEventListener('DOMContentLoaded', function () {
} }
}); });
// Tampilkan pesan kosong jika tidak ada baris yang cocok secara instan if (paginationContainer) {
if (emptyRow) { paginationContainer.style.display = query.length > 0 ? 'none' : '';
if (rows.length > 0 && visibleCount === 0) { }
emptyRow.classList.remove('hidden');
} else { const existingEmptyRow = document.getElementById('clientSearchEmptyRow');
emptyRow.classList.add('hidden'); if (existingEmptyRow) existingEmptyRow.remove();
}
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSearchEmptyRow';
emptyTr.innerHTML = `
<td colspan="11" class="py-12 px-4 text-center">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('activityLogSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
} }
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) { if (resetContainer) {
let resetBtn = document.getElementById('headerResetFilterBtn'); let resetBtn = document.getElementById('headerResetFilterBtn');
if (query.length > 0 || hasServerFilters) { if (query.length > 0 || hasServerFilters) {
@@ -374,7 +410,6 @@ document.addEventListener('DOMContentLoaded', function () {
resetBtn.href = "{{ route('qma.activity.log') }}"; resetBtn.href = "{{ route('qma.activity.log') }}";
resetBtn.id = 'headerResetFilterBtn'; resetBtn.id = 'headerResetFilterBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition'; resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition';
const resetIcon = document.createElement('i'); const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]'; resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span'); const resetText = document.createElement('span');
@@ -384,10 +419,8 @@ document.addEventListener('DOMContentLoaded', function () {
resetBtn.appendChild(resetText); resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn); resetContainer.appendChild(resetBtn);
} }
} else { } else if (!hasServerFilters && resetBtn) {
if (resetBtn && !hasServerFilters) { resetBtn.remove();
resetBtn.remove();
}
} }
} }
}); });
+75 -32
View File
@@ -307,26 +307,33 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverSummaryEmptyRow">
<td colspan="9" class="py-10 text-center text-slate-400"> <td colspan="9" class="py-12 px-4 text-center">
<i class="fa-solid fa-chart-simple text-3xl mb-2 block"></i> <div class="flex flex-col items-center justify-center space-y-3">
Belum ada data aktivitas kendaraan untuk periode yang dipilih. <div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<a href="{{ route('qma.activity.summary') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Rekapitulasi</div>
<p class="text-xs text-slate-400">Belum ada data aktivitas kendaraan untuk periode yang dipilih.</p>
@endif
</div>
</td> </td>
</tr> </tr>
@endforelse @endforelse
<!-- Baris Hasil Pencarian Real-Time Kosong -->
<tr id="clientSearchEmptyRow" class="hidden">
<td colspan="9" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-2">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 text-xl">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<div class="text-sm font-bold text-slate-700">Tidak Ada Hasil Pencarian</div>
<p class="text-xs text-slate-400">Tidak ditemukan armada yang sesuai dengan kata kunci pencarian Anda.</p>
</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -517,32 +524,68 @@ document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('summarySearchInput'); const searchInput = document.getElementById('summarySearchInput');
const tableBody = document.getElementById('summaryTableBody'); const tableBody = document.getElementById('summaryTableBody');
const resetContainer = document.getElementById('headerResetFilterContainer'); const resetContainer = document.getElementById('headerResetFilterContainer');
const emptyRow = document.getElementById('clientSearchEmptyRow'); const serverEmptyRow = document.getElementById('serverSummaryEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'type', 'gate_id']) ? 'true' : 'false' }}; const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'type', 'gate_id']) ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) { if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) { searchInput.addEventListener('input', function (e) {
const query = e.target.value.toLowerCase().trim(); const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.summary-vehicle-row'); const rows = tableBody.querySelectorAll('tr.summary-vehicle-row');
let visibleCount = 0; let visibleCount = 0;
rows.forEach(row => { rows.forEach(row => {
const text = row.textContent.toLowerCase(); const text = row.textContent.toLowerCase();
if (text.includes(query)) { const match = text.includes(query);
row.style.display = ''; row.style.display = match ? '' : 'none';
visibleCount++; if (match) visibleCount++;
} else {
row.style.display = 'none';
}
}); });
// Tampilkan pesan kosong jika tidak ada baris yang cocok secara instan // Sembunyikan pesan SSR kosong saat user mengetik
if (emptyRow) { if (serverEmptyRow) {
if (rows.length > 0 && visibleCount === 0) { serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
emptyRow.classList.remove('hidden'); }
} else {
emptyRow.classList.add('hidden'); // Hapus baris pesan kosong pencarian client jika ada sebelumnya
} const existingEmptyRow = document.getElementById('summaryClientEmptyRow');
if (existingEmptyRow) {
existingEmptyRow.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok di tabel
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'summaryClientEmptyRow';
emptyTr.innerHTML = `
<td colspan="9" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('summarySearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
} }
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time // Tampilkan atau sembunyikan tombol Reset Filter secara real-time
+8 -1
View File
@@ -55,7 +55,14 @@
<a href="{{ route('qma.activity.log') }}" <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"> 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> <i class="fa-solid fa-clipboard-list"></i>
<span>Buka Log Aktivitas Kendaraan</span> <span>Log Timesheet LV</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a>
<a href="{{ route('qma.p2h.index') }}"
class="inline-flex items-center space-x-2 bg-amber-600 hover:bg-amber-700 text-white font-bold text-xs py-3 px-5 rounded-xl shadow-md hover:shadow-lg transition">
<i class="fa-solid fa-clipboard-check"></i>
<span>Log P2H Unit Support</span>
<i class="fa-solid fa-arrow-right text-[10px] ml-1"></i> <i class="fa-solid fa-arrow-right text-[10px] ml-1"></i>
</a> </a>
</div> </div>
+415
View File
@@ -0,0 +1,415 @@
@extends('layouts.app')
@section('title', 'P2H Unit Support - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul & Tombol Aksi (Tanpa Card Pembungkus Sesuai Panduan Desain QMA) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman P2H Unit Support">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
P2H Unit Support
</h2>
</div>
<div class="flex items-center space-x-2.5 w-full sm:w-auto">
<a href="{{ route('qma.p2h.summary') }}" class="w-full sm:w-auto inline-flex items-center justify-center space-x-2 px-4 py-2.5 rounded-xl border border-slate-200 text-xs font-bold text-slate-700 bg-white hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-chart-pie text-slate-400 group-hover:text-slate-700"></i>
<span>Summary Aktivitas</span>
</a>
</div>
</div>
<!-- Kotak Pencarian & Filter Status P2H (Tanpa Card Pembungkus Sesuai Gambar Referensi) -->
<form method="GET" action="{{ route('qma.p2h.index') }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
@if(request('date'))
<input type="hidden" name="date" value="{{ request('date') }}">
@endif
<!-- Sisi Kiri: Kotak Pencarian -->
<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="p2hSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari No. TRX, kode unit (EX01), nama/NIK operator..."
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>
<!-- Sisi Kanan: Filter Dropdown & Reset -->
<div class="flex flex-wrap items-center gap-2">
<!-- Filter Status Approval -->
<select name="validation_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] shadow-sm">
<option value="">Semua Status Approval</option>
<option value="pending" {{ request('validation_status') === 'pending' ? 'selected' : '' }}>Menunggu Approval</option>
<option value="approved" {{ request('validation_status') === 'approved' ? 'selected' : '' }}>Disetujui (Approved)</option>
<option value="rejected" {{ request('validation_status') === 'rejected' ? 'selected' : '' }}>Ditolak (Rejected)</option>
</select>
<!-- Filter Kondisi Fisik -->
<select name="summary_condition" 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] shadow-sm">
<option value="">Semua Kondisi Fisik</option>
<option value="good" {{ request('summary_condition') === 'good' ? 'selected' : '' }}>Semua Baik (Normal)</option>
<option value="has_defect" {{ request('summary_condition') === 'has_defect' ? 'selected' : '' }}>Ada Temuan Rusak</option>
</select>
<div id="p2hResetWrapper">
@if(request('search') || request('validation_status') || request('summary_condition') || request('date'))
<a id="p2hResetBtn" href="{{ route('qma.p2h.index') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1" title="Reset Semua Filter">
<i class="fa-solid fa-rotate-left"></i>
<span>Reset</span>
</a>
@endif
</div>
</div>
</form>
<!-- Tabel Data Riwayat P2H -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left text-xs text-slate-600">
<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">Waktu Inspeksi</th>
<th class="py-3.5 px-4">No. Transaksi</th>
<th class="py-3.5 px-4">Unit Support</th>
<th class="py-3.5 px-4">Operator (SIMPER)</th>
<th class="py-3.5 px-4 text-center">Shift</th>
<th class="py-3.5 px-4 text-right">HM Operasi</th>
<th class="py-3.5 px-4 text-center">Kondisi Fisik</th>
<th class="py-3.5 px-4 text-center">Status QMA</th>
<th class="py-3.5 px-4 text-center w-24">Aksi</th>
</tr>
</thead>
<tbody id="p2hTableBody" class="divide-y divide-slate-100">
@forelse($records as $rec)
<tr class="p2h-row hover:bg-slate-50/80 transition">
<td class="py-3.5 px-4 text-center text-slate-400 font-medium">
{{ ($records->currentPage() - 1) * $records->perPage() + $loop->iteration }}
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $rec->inspected_at->format('d/m/Y') }}</span>
<span class="text-slate-400 block text-[10px]">{{ $rec->inspected_at->format('H:i') }} WIB</span>
</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-mono font-bold text-slate-700 bg-slate-100 px-2 py-0.5 rounded text-[11px]">{{ $rec->transaction_no }}</span>
</td>
<td class="py-3.5 px-4">
<div class="font-extrabold text-slate-900 text-sm leading-tight">{{ $rec->vehicle->code }}</div>
<div class="text-[11px] text-slate-500 truncate max-w-[160px]">{{ $rec->vehicle->brand_type }}</div>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-800">{{ $rec->employee->name ?? '-' }}</div>
<div class="text-[10px] text-slate-400">NIK: {{ $rec->employee->nik ?? '-' }}</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="px-2 py-0.5 rounded-md text-[10px] font-semibold bg-slate-100 text-slate-700">
{{ Str::contains($rec->shift, '1') ? 'Shift 1' : 'Shift 2' }}
</span>
</td>
<td class="py-3.5 px-4 text-right whitespace-nowrap">
<span class="font-black text-slate-900">{{ number_format($rec->start_hm, 1, ',', '.') }}</span>
<span class="text-[10px] text-slate-400 font-bold ml-0.5">HM</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($rec->hasDefects())
<span class="inline-flex items-center px-2 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-rose-600"></i> {{ $rec->defect_count }} Item Rusak
</span>
@else
<span class="inline-flex items-center px-2 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-emerald-600"></i> Normal (Baik)
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($rec->isPending())
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200">
<span class="w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse mr-1.5"></span>
Menunggu Review
</span>
@elseif($rec->isApproved())
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-200">
<i class="fa-solid fa-check mr-1"></i> Disetujui QMA
</span>
@else
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-[10px] font-bold bg-rose-50 text-rose-800 border border-rose-200">
<i class="fa-solid fa-xmark mr-1"></i> Ditolak
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<a href="{{ route('qma.p2h.show', $rec->id) }}" class="inline-flex items-center space-x-1 px-3 py-1.5 rounded-xl text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144918] shadow-sm transition">
<i class="fa-solid fa-magnifying-glass text-[10px]"></i>
<span>Review</span>
</a>
</td>
</tr>
@empty
<tr id="serverEmptyRow">
<td colspan="10" class="py-12 text-center text-slate-400">
@if(request('search'))
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.index') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<i class="fa-solid fa-clipboard-question text-3xl mb-2 text-slate-300 block"></i>
<span class="font-bold text-slate-600">Belum ada catatan riwayat P2H Unit Support</span>
<p class="text-[11px] text-slate-400 mt-0.5">Form P2H yang dikirim oleh operator alat berat akan muncul pada daftar ini.</p>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($records->hasPages())
<div id="p2hPaginationContainer" class="p-4 border-t border-slate-100">
{{ $records->links() }}
</div>
@endif
</div>
</div>
<!-- ========================================================================= -->
<!-- ========================================================================= -->
<!-- JAVASCRIPT: REAL-TIME CLIENT SEARCH & MODAL -->
<!-- ========================================================================= -->
<script>
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('p2hSearchInput');
const tableBody = document.getElementById('p2hTableBody');
const resetWrapper = document.getElementById('p2hResetWrapper');
const serverEmptyRow = document.getElementById('serverEmptyRow');
const paginationContainer = document.getElementById('p2hPaginationContainer');
const hasServerFilters = {{ request()->anyFilled(['validation_status', 'summary_condition', 'date']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.p2h-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
// Sembunyikan pagination saat client-side search aktif
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientSearchEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
// Sembunyikan server empty row saat mengetik jika ada
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Tampilkan pesan kosong jika tidak ada baris yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSearchEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('p2hSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetWrapper) {
let resetBtn = document.getElementById('p2hResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'p2hResetBtn';
resetBtn.href = "{{ route('qma.p2h.index') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.title = 'Reset Semua Filter';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left';
const resetText = document.createElement('span');
resetText.textContent = 'Reset';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetWrapper.appendChild(resetBtn);
}
} else {
if (resetBtn && !hasServerFilters) {
resetBtn.remove();
}
}
}
});
}
});
function openGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.remove('hidden');
document.documentElement.classList.add('modal-open');
document.body.classList.add('modal-open');
}
}
function closeGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.add('hidden');
document.documentElement.classList.remove('modal-open');
document.body.classList.remove('modal-open');
}
}
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeGuideModal();
}
});
</script>
<!-- ========================================================================= -->
<!-- MODAL POPUP: PANDUAN HALAMAN (LOG P2H UNIT SUPPORT) -->
<!-- ========================================================================= -->
<div id="guideModal"
onclick="if(event.target === this) closeGuideModal()"
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
<!-- Header Modal -->
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<div class="flex items-center space-x-3">
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-700 flex items-center justify-center font-bold text-sm border border-slate-200">
<i class="fa-solid fa-info"></i>
</div>
<div>
<h3 class="text-base font-bold text-slate-900 tracking-tight leading-tight">Panduan Halaman</h3>
<p class="text-xs text-slate-500">P2H Unit Support</p>
</div>
</div>
<button type="button"
onclick="closeGuideModal()"
class="text-slate-400 hover:text-slate-600 transition p-1.5 rounded-lg hover:bg-slate-100 cursor-pointer">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="mt-4 space-y-4">
<p class="text-xs text-slate-600 leading-relaxed">
Halaman <strong>P2H Unit Support</strong> digunakan untuk memantau, memeriksa, dan memvalidasi riwayat pemeriksaan kelayakan operasi harian alat berat proyek yang diajukan oleh operator.
</p>
<div class="space-y-3">
<!-- Fitur 1 (Hijau) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-emerald-100/70 text-emerald-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-emerald-200/50">
<i class="fa-solid fa-clipboard-check"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Review & Validasi Kelayakan</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Buka detail setiap pengajuan P2H untuk meninjau status checklist kelayakan alat dan beri persetujuan (Approve) atau penolakan (Reject).
</p>
</div>
</div>
<!-- Fitur 2 (Amber) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50">
<i class="fa-solid fa-triangle-exclamation"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Deteksi Temuan Kerusakan</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Pantau kartu statistik 'Temuan Rusak' dan 'Menunggu QMA' untuk memprioritaskan unit yang membutuhkan perbaikan atau tindakan cepat.
</p>
</div>
</div>
<!-- Fitur 3 (Biru) -->
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-blue-100/70 text-blue-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-blue-200/50">
<i class="fa-solid fa-layer-group"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Master Checksheet P2H</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Akses daftar 28 standarisasi template checksheet pertanyaan P2H melalui tombol 'Master 28 Template' di bagian kanan atas.
</p>
</div>
</div>
</div>
</div>
<!-- Footer Tombol -->
<div class="pt-4 mt-5 border-t border-slate-100 flex items-center justify-end">
<button type="button"
onclick="closeGuideModal()"
class="px-6 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold text-xs transition cursor-pointer shadow-2xs">
Saya Mengerti
</button>
</div>
</div>
</div>
@endsection
+217
View File
@@ -0,0 +1,217 @@
@extends('layouts.app')
@section('title', 'Review P2H Unit ' . $record->vehicle->code . ' - ' . $record->transaction_no)
@section('content')
<div class="w-full space-y-6">
<!-- Top Action Bar -->
<div class="flex items-center justify-between pb-1">
<a href="{{ route('qma.p2h.index') }}" class="inline-flex items-center space-x-1.5 text-xs font-bold text-slate-600 hover:text-[#1b5e20] transition bg-white px-3 py-1.5 rounded-xl border border-slate-200 shadow-sm">
<i class="fa-solid fa-arrow-left text-[11px]"></i>
<span>Kembali ke P2H Unit Support</span>
</a>
<!-- Badge Status Validasi -->
<div>
@if($record->isPending())
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-800 border border-amber-300">
<span class="w-2 h-2 rounded-full bg-amber-500 animate-pulse mr-2"></span>
Menunggu Approval QMA
</span>
@elseif($record->isApproved())
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-800 border border-emerald-300">
<i class="fa-solid fa-check mr-1.5 text-emerald-600"></i> Disetujui (Approved)
</span>
@else
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-rose-50 text-rose-800 border border-rose-300">
<i class="fa-solid fa-xmark mr-1.5 text-rose-600"></i> Ditolak (Rejected)
</span>
@endif
</div>
</div>
<!-- Header Transaksi & Metadata -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 text-white p-6 rounded-2xl shadow-sm border border-slate-700">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border-b border-slate-700 pb-4 mb-4">
<div>
<span class="text-xs font-semibold text-slate-400 uppercase tracking-wider block">LEMBAR PEMERIKSAAN PRA-HARIAN (P2H)</span>
<h1 class="text-2xl font-black text-white mt-0.5">{{ $record->transaction_no }}</h1>
</div>
<div class="text-left sm:text-right text-xs text-slate-300">
<span class="text-slate-400">Waktu Pemeriksaan:</span>
<span class="font-bold text-white block text-sm">{{ $record->inspected_at->format('d F Y, H:i') }} WIB</span>
</div>
</div>
<!-- 3 Kolom Info: Unit, Operator, Ringkasan HM -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-xs">
<!-- Kolom 1: Unit Support -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-amber-400 uppercase tracking-wider block">UNIT SUPPORT</span>
<p class="text-base font-black text-white leading-tight">{{ $record->vehicle->code }}</p>
<p class="text-slate-300 font-medium">{{ $record->vehicle->brand_type }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Kategori:</span>
<span class="text-slate-200 font-semibold">{{ $record->vehicle->unit_category ?? ($record->template->name ?? '-') }}</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>Lokasi:</span>
<span class="text-slate-200 font-semibold">{{ $record->vehicle->location ?? '-' }}</span>
</div>
</div>
<!-- Kolom 2: Operator -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-emerald-400 uppercase tracking-wider block">OPERATOR (HSE)</span>
<p class="text-base font-black text-white leading-tight">{{ $record->employee->name ?? '-' }}</p>
<p class="text-slate-300 font-medium">NIK: {{ $record->employee->nik ?? '-' }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Divisi:</span>
<span class="text-slate-200 font-semibold">{{ $record->employee->division ?? '-' }}</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>SIMPER:</span>
<span class="text-emerald-400 font-semibold">Aktif (s.d {{ $record->employee->simper_expired_at ? $record->employee->simper_expired_at->format('d/m/Y') : '-' }})</span>
</div>
</div>
<!-- Kolom 3: Operasional Shift & HM -->
<div class="bg-slate-800/80 p-3.5 rounded-xl border border-slate-700/80 space-y-1.5">
<span class="text-[10px] font-bold text-blue-400 uppercase tracking-wider block">OPERASIONAL SHIFT</span>
<p class="text-base font-black text-white leading-tight">{{ $record->shift }}</p>
<div class="pt-1 text-[11px] text-slate-400 border-t border-slate-700/60 flex items-center justify-between">
<span>Hour Meter (HM):</span>
<span class="text-emerald-300 font-extrabold text-sm">{{ number_format($record->start_hm, 1, ',', '.') }} HM</span>
</div>
<div class="text-[11px] text-slate-400 flex items-center justify-between">
<span>Kondisi Fisik:</span>
@if($record->hasDefects())
<span class="text-rose-400 font-bold">{{ $record->defect_count }} Item Rusak</span>
@else
<span class="text-emerald-400 font-bold">Semua Normal</span>
@endif
</div>
</div>
</div>
</div>
<!-- Catatan Umum Operator (Jika ada) -->
@if($record->general_notes)
<div class="bg-amber-50/60 border border-amber-200 rounded-2xl p-4 text-xs space-y-1 shadow-sm">
<span class="font-bold text-amber-900 block flex items-center space-x-1.5">
<i class="fa-solid fa-comment-dots text-amber-600"></i>
<span>Catatan Umum dari Operator:</span>
</span>
<p class="text-slate-700 leading-relaxed italic">"{{ $record->general_notes }}"</p>
</div>
@endif
<!-- Panel Keputusan Approval Admin QMA -->
<div class="bg-white rounded-2xl p-6 border border-slate-200 shadow-sm space-y-4">
<h3 class="font-bold text-slate-900 text-sm flex items-center space-x-2 border-b border-slate-100 pb-3">
<i class="fa-solid fa-stamp text-[#1b5e20]"></i>
<span>Verifikasi & Keputusan Approval Admin QMA</span>
</h3>
@if($record->isPending())
<!-- Form Aksi Approval / Reject -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- Form Approve -->
<form action="{{ route('qma.p2h.approve', $record->id) }}" method="POST" class="bg-emerald-50/50 border border-emerald-200 p-4 rounded-xl space-y-3">
@csrf
<div>
<span class="font-bold text-emerald-900 text-xs block mb-1">Setujui Hasil Pemeriksaan</span>
<input type="text" name="validation_notes" placeholder="Catatan persetujuan (opsional)..." class="w-full text-xs px-3 py-2 rounded-xl border border-emerald-300 focus:border-emerald-600 bg-white">
</div>
<button type="submit" onclick="return confirm('Apakah Anda yakin ingin MENYETUJUI hasil P2H untuk unit ini?')" class="w-full bg-[#1b5e20] hover:bg-[#144918] text-white font-bold py-2 px-4 rounded-xl text-xs shadow-sm transition flex items-center justify-center space-x-2">
<i class="fa-solid fa-circle-check"></i>
<span>Setujui P2H (Approve)</span>
</button>
</form>
<!-- Form Reject -->
<form action="{{ route('qma.p2h.reject', $record->id) }}" method="POST" class="bg-rose-50/50 border border-rose-200 p-4 rounded-xl space-y-3">
@csrf
<div>
<span class="font-bold text-rose-900 text-xs block mb-1">Tolak Hasil Pemeriksaan <span class="text-rose-600">*</span></span>
<input type="text" name="validation_notes" required placeholder="Tuliskan alasan penolakan / instruksi perbaikan..." class="w-full text-xs px-3 py-2 rounded-xl border border-rose-300 focus:border-rose-600 bg-white">
</div>
<button type="submit" onclick="return confirm('Apakah Anda yakin ingin MENOLAK hasil P2H untuk unit ini?')" class="w-full bg-rose-600 hover:bg-rose-700 text-white font-bold py-2 px-4 rounded-xl text-xs shadow-sm transition flex items-center justify-center space-x-2">
<i class="fa-solid fa-circle-xmark"></i>
<span>Tolak P2H (Reject)</span>
</button>
</form>
</div>
@else
<!-- Info Hasil Validasi Sebelumnya -->
<div class="bg-slate-50 p-4 rounded-xl border border-slate-200 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 text-xs">
<div>
<span class="text-slate-400 block">Diverifikasi Oleh:</span>
<span class="font-bold text-slate-800 text-sm">{{ $record->validator->name ?? 'Admin QMA' }}</span>
<span class="text-slate-500 block text-[11px]">Pada {{ $record->validated_at ? $record->validated_at->format('d/m/Y H:i') . ' WIB' : '-' }}</span>
</div>
<div class="sm:text-right">
<span class="text-slate-400 block">Catatan Verifikator:</span>
<span class="font-medium text-slate-700">{{ $record->validation_notes ?? '-' }}</span>
</div>
</div>
@endif
</div>
<!-- Detail Hasil Cek Per Section (Checklist Butir Soal) -->
<div class="space-y-4">
<h3 class="font-extrabold text-slate-900 text-base px-1">Rincian Butir Pemeriksaan Pra-Harian</h3>
@foreach($groupedItems as $sectionName => $itemsInSection)
<div class="bg-white rounded-none sm:rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
<div class="p-3.5 bg-slate-50 border-b border-slate-200 flex items-center justify-between">
<div class="flex items-center space-x-2">
<span class="w-2 h-2 rounded-full bg-[#1b5e20]"></span>
<h4 class="font-bold text-slate-800 text-xs uppercase tracking-wide">{{ $sectionName }}</h4>
</div>
<span class="text-[10px] font-semibold text-slate-500 bg-white border border-slate-200 px-2 py-0.5 rounded-full">
{{ count($itemsInSection) }} butir
</span>
</div>
<div class="divide-y divide-slate-100 p-2 sm:p-4 text-xs">
@foreach($itemsInSection as $item)
<div class="p-2.5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 hover:bg-slate-50/60 rounded-xl transition">
<div class="flex items-start space-x-2 flex-1 pr-2">
<span class="font-bold text-slate-400">{{ $loop->iteration }}.</span>
<div>
<span class="font-semibold text-slate-800 leading-snug">{{ $item->title }}</span>
@if($item->notes)
<p class="text-[11px] text-rose-600 font-medium mt-0.5 flex items-center space-x-1">
<i class="fa-solid fa-circle-exclamation text-[10px]"></i>
<span>Catatan: {{ $item->notes }}</span>
</p>
@endif
</div>
</div>
<div class="flex-shrink-0">
@if(in_array($item->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix']) || !empty($item->condition_status))
@if($item->condition_status === 'rusak')
<span class="inline-flex items-center px-2.5 py-1 rounded-xl text-xs font-bold bg-rose-50 text-rose-700 border border-rose-200">
<i class="fa-solid fa-triangle-exclamation mr-1 text-rose-600"></i> Rusak
</span>
@else
<span class="inline-flex items-center px-2.5 py-1 rounded-xl text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
<i class="fa-solid fa-check mr-1 text-emerald-600"></i> Baik
</span>
@endif
@else
<span class="font-semibold text-slate-700 bg-slate-100 px-2.5 py-1 rounded-lg text-xs">
{{ $item->answer_value ?? '-' }}
</span>
@endif
</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
@endsection
+527
View File
@@ -0,0 +1,527 @@
@extends('layouts.app')
@section('title', 'Summary P2H Unit Support - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Halaman Summary P2H -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
<!-- Tombol Info Panduan Halaman Sejajar Kicker -->
<button type="button"
onclick="openGuideModal()"
class="w-3.5 h-3.5 rounded-full bg-slate-200/90 hover:bg-slate-300 text-slate-500 hover:text-slate-800 text-[8px] inline-flex items-center justify-center font-bold transition shadow-2xs cursor-pointer focus:outline-none"
title="Panduan Halaman Summary P2H">
<i class="fa-solid fa-info"></i>
</button>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Summary P2H Unit Support
</h2>
</div>
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<a href="{{ route('qma.p2h.index') }}" class="w-full sm:w-auto flex items-center justify-center space-x-2 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white border border-slate-200 hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-clipboard-check text-slate-400 group-hover:text-slate-700"></i>
<span class="truncate">Detail P2H</span>
</a>
<a href="{{ route('qma.p2h.templates') }}" class="w-full sm:w-auto flex items-center justify-center space-x-2 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white border border-slate-200 hover:bg-slate-50 shadow-sm transition group">
<i class="fa-solid fa-layer-group text-slate-400 group-hover:text-slate-700"></i>
<span class="truncate">Master Template</span>
</a>
</div>
</div>
@php
$activeFilterCount = count(array_filter(request()->only(['search', 'start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift'])));
$isFilterOpen = request()->anyFilled(['start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']);
@endphp
<!-- Form Filter & Pencarian Cepat -->
<form method="GET" action="{{ route('qma.p2h.summary') }}" class="space-y-3">
<!-- Baris Atas: Search Bar Mandiri di Luar Card Filter & Tombol Toggle -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-3">
<!-- Search Bar Utama (Real-Time) -->
<div class="relative flex-1">
<div 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>
</div>
<input type="text"
name="search"
id="p2hSummarySearchInput"
value="{{ request('search') }}"
placeholder="Cari No. TRX, kode unit (EX01), model, nama operator..."
class="w-full text-xs rounded-xl border border-slate-200 bg-white hover:border-slate-300 focus:bg-white pl-9 pr-3.5 py-2.5 text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition shadow-2xs">
</div>
<!-- Tombol Buka/Tutup Filter Card & Reset Filter -->
<div class="flex items-center gap-2.5 self-end sm:self-auto w-full sm:w-auto justify-between sm:justify-start">
<button type="button"
id="filterToggleBtn"
onclick="toggleFilterCard()"
class="inline-flex items-center justify-center px-4 py-2.5 rounded-xl text-xs font-bold text-slate-700 bg-white hover:bg-slate-50 border border-slate-200 shadow-2xs transition group cursor-pointer">
<i class="fa-solid fa-sliders text-slate-500 mr-2 group-hover:text-[#1b5e20] transition-colors"></i>
<span>Filter</span>
@if($activeFilterCount > 0)
<span class="ml-1.5 px-1.5 py-0.5 rounded-full text-[10px] font-extrabold bg-[#1b5e20] text-white">
{{ $activeFilterCount }}
</span>
@endif
<i id="filterChevron" class="fa-solid fa-chevron-down ml-2 text-[10px] text-slate-400 transition-transform duration-200 {{ $isFilterOpen ? 'rotate-180' : '' }}"></i>
</button>
<div id="p2hSummaryResetContainer">
@if(request()->anyFilled(['search', 'start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']))
<a href="{{ route('qma.p2h.summary') }}"
id="p2hSummaryResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
</div>
<!-- Card Filter Lanjutan (Bisa Di Buka-Tutup / Collapsible) -->
<div id="collapsibleFilterCard" class="{{ $isFilterOpen ? '' : 'hidden ' }}bg-white rounded-2xl border border-slate-200 shadow-sm p-4 sm:p-5 transition-all">
<div class="flex items-center justify-between pb-3 border-b border-slate-100 mb-3.5">
<div class="flex items-center space-x-2">
<span class="text-slate-800 font-bold text-xs uppercase tracking-wider">
Opsi Filter Lanjutan
</span>
@if($activeFilterCount > 0)
<span class="text-[11px] text-slate-400 font-medium">({{ $activeFilterCount }} filter aktif)</span>
@endif
</div>
<button type="button"
onclick="toggleFilterCard()"
class="text-xs text-slate-400 hover:text-slate-600 transition flex items-center space-x-1 cursor-pointer">
<span>Tutup</span>
<i class="fa-solid fa-xmark text-[11px]"></i>
</button>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3.5">
<!-- Mulai Tanggal -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Mulai Tanggal</label>
<input type="date"
name="start_date"
value="{{ request('start_date', $startDate ?? now()->startOfMonth()->format('Y-m-d')) }}"
onchange="this.form.submit()"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Sampai Tanggal -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Sampai Tanggal</label>
<input type="date"
name="end_date"
value="{{ request('end_date', $endDate ?? now()->format('Y-m-d')) }}"
onchange="this.form.submit()"
class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
</div>
<!-- Unit Support -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Unit Support</label>
<select name="vehicle_id" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Unit Support</option>
@foreach($supportVehicles as $sv)
<option value="{{ $sv->id }}" {{ request('vehicle_id') == $sv->id ? 'selected' : '' }}>
{{ $sv->code }} - {{ $sv->brand_type }}
</option>
@endforeach
</select>
</div>
<!-- Status Validasi -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Status Validasi</label>
<select name="validation_status" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Status</option>
<option value="pending" {{ request('validation_status') === 'pending' ? 'selected' : '' }}>Menunggu Approval</option>
<option value="approved" {{ request('validation_status') === 'approved' ? 'selected' : '' }}>Disetujui (Approved)</option>
<option value="rejected" {{ request('validation_status') === 'rejected' ? 'selected' : '' }}>Ditolak (Rejected)</option>
</select>
</div>
<!-- Shift Kerja -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Shift Kerja</label>
<select name="shift" onchange="this.form.submit()" class="w-full text-xs rounded-xl border border-slate-200 bg-slate-50/50 hover:bg-white focus:bg-white px-3.5 py-2.5 text-slate-800 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
<option value="">Semua Shift</option>
<option value="1" {{ request('shift') === '1' ? 'selected' : '' }}>Shift 1 (Pagi)</option>
<option value="2" {{ request('shift') === '2' ? 'selected' : '' }}>Shift 2 (Malam)</option>
</select>
</div>
</div>
</div>
</form>
<!-- 4 Kartu KPI Metrik Ringkasan P2H -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4">
<!-- 1. Total Inspeksi P2H -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Total Inspeksi P2H</p>
<h3 class="text-xl sm:text-2xl font-black text-slate-900 mt-1">{{ number_format($totalInspections, 0, ',', '.') }}</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-emerald-700 font-semibold"><i class="fa-solid fa-check mr-0.5"></i> {{ $totalApproved }} Disetujui</span>
<span class="text-slate-300 hidden sm:inline">•</span>
<span class="text-amber-600 font-semibold"><i class="fa-solid fa-hourglass-half mr-0.5"></i> {{ $totalPending }} Menunggu</span>
</div>
</div>
<!-- 2. Kondisi Fisik Alat Berat -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Kondisi Alat Berat</p>
<h3 class="text-xl sm:text-2xl font-black text-emerald-700 mt-1">
{{ $totalInspections > 0 ? round(($totalNormal / $totalInspections) * 100) : 0 }}% <span class="text-xs font-sans font-bold text-slate-500">Normal</span>
</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-emerald-700 font-semibold">{{ $totalNormal }} Unit Baik</span>
<span class="text-slate-300 hidden sm:inline">•</span>
<span class="text-rose-600 font-semibold">{{ $totalDefects }} Ada Temuan Rusak</span>
</div>
</div>
<!-- 3. Status Penolakan / Tindak Lanjut -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Unit Ditolak / Reject</p>
<h3 class="text-xl sm:text-2xl font-black text-rose-600 mt-1">{{ number_format($totalRejected, 0, ',', '.') }}</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-rose-600 font-semibold"><i class="fa-solid fa-triangle-exclamation mr-0.5"></i> {{ $totalRejected }} Perlu Perbaikan</span>
</div>
</div>
<!-- 4. Total Akumulasi Hour Meter (HM) -->
<div class="bg-white rounded-2xl p-4 sm:p-5 border border-slate-200 shadow-sm flex flex-col justify-between">
<div>
<p class="text-[11px] sm:text-xs font-bold text-slate-400 uppercase tracking-wider">Total HM Tercatat</p>
<h3 class="text-xl sm:text-2xl font-black text-slate-900 font-mono mt-1">
{{ number_format($totalHm, 1, ',', '.') }} <span class="text-xs font-sans font-bold text-slate-500">Jam</span>
</h3>
</div>
<div class="flex flex-wrap items-center gap-1 sm:space-x-2 mt-2 text-[10px] sm:text-[11px]">
<span class="text-slate-500 font-semibold"><i class="fa-solid fa-clock mr-0.5"></i> Hour Meter Operasi</span>
</div>
</div>
</div>
<!-- Tabel Rekapitulasi per Unit Support -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="px-5 py-4 border-b border-slate-100 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
<div>
<h3 class="text-sm font-bold text-slate-900">Rekapitulasi Pemeriksaan per Unit Support</h3>
<p class="text-xs text-slate-400 mt-0.5">Ringkasan kepatuhan dan status kelayakan inspeksi masing-masing unit alat berat.</p>
</div>
<span class="text-xs font-semibold px-2.5 py-1 rounded-full bg-slate-100 text-slate-600">
{{ $unitSummary->count() }} Unit Aktif
</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left text-xs text-slate-600">
<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">Model & Kategori</th>
<th class="py-3.5 px-4 text-center">Total P2H</th>
<th class="py-3.5 px-4 text-center">Disetujui</th>
<th class="py-3.5 px-4 text-center">Menunggu</th>
<th class="py-3.5 px-4 text-center">Ditolak</th>
<th class="py-3.5 px-4 text-center">Temuan Rusak</th>
<th class="py-3.5 px-4 text-right">HM Terakhir</th>
<th class="py-3.5 px-4 text-center">Terakhir Diperiksa</th>
</tr>
</thead>
<tbody id="p2hSummaryTableBody" class="divide-y divide-slate-100">
@forelse($unitSummary as $idx => $us)
<tr class="p2h-summary-row hover:bg-slate-50/80 transition">
<td class="py-3.5 px-4 text-center text-slate-400 font-medium">{{ $loop->iteration }}</td>
<td class="py-3.5 px-4 whitespace-nowrap">
<span class="font-bold text-slate-900">{{ $us['vehicle']->code ?? '-' }}</span>
</td>
<td class="py-3.5 px-4">
<span class="text-slate-800 font-semibold block">{{ $us['vehicle']->brand_type ?? '-' }}</span>
<span class="text-slate-400 text-[10px]">{{ $us['vehicle']->unit_category ?? 'Alat Berat' }}</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-bold text-slate-900">
{{ number_format($us['total']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold text-emerald-700">
{{ number_format($us['approved']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold text-amber-600">
{{ number_format($us['pending']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap font-semibold {{ $us['rejected'] > 0 ? 'text-rose-600' : 'text-slate-400' }}">
{{ number_format($us['rejected']) }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($us['has_defect'] > 0)
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
{{ $us['has_defect'] }} Temuan
</span>
@else
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
Normal
</span>
@endif
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ $us['latest_hm'] ? number_format($us['latest_hm'], 1, ',', '.') : '-' }}
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap text-slate-500">
{{ $us['latest_inspection'] ? \Carbon\Carbon::parse($us['latest_inspection'])->format('d/m/Y H:i') : '-' }}
</td>
</tr>
@empty
<tr id="serverP2hSummaryEmptyRow">
<td colspan="10" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.summary') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Data Rekapitulasi</div>
<p class="text-xs text-slate-400">Tidak ada data rekapitulasi P2H untuk rentang tanggal yang dipilih.</p>
@endif
</div>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- ========================================================================= -->
<!-- JAVASCRIPT MODAL PANDUAN HALAMAN -->
<!-- ========================================================================= -->
<script>
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('p2hSummarySearchInput');
const tableBody = document.getElementById('p2hSummaryTableBody');
const resetContainer = document.getElementById('p2hSummaryResetContainer');
const serverEmptyRow = document.getElementById('serverP2hSummaryEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['start_date', 'end_date', 'vehicle_id', 'validation_status', 'shift']) ? 'true' : 'false' }};
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.p2h-summary-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
const match = text.includes(query);
row.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan baris SSR jika user sedang mengetik
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris pesan kosong pencarian client jika ada sebelumnya
const existingEmptyRow = document.getElementById('p2hSummaryClientEmptyRow');
if (existingEmptyRow) {
existingEmptyRow.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok di tabel
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'p2hSummaryClientEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 px-4 text-center">
<div class="flex flex-col items-center justify-center space-y-3">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm">
Pastikan kata kunci yang dicari sudah benar atau gunakan filter lainnya.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('p2hSummarySearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) {
let resetBtn = document.getElementById('p2hSummaryResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.href = "{{ route('qma.p2h.summary') }}";
resetBtn.id = 'p2hSummaryResetBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span');
resetText.textContent = 'Reset Filter';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else {
if (resetBtn && !hasServerFilters) {
resetBtn.remove();
}
}
}
});
}
});
function toggleFilterCard() {
const card = document.getElementById('collapsibleFilterCard');
const chevron = document.getElementById('filterChevron');
if (card) {
card.classList.toggle('hidden');
}
if (chevron) {
chevron.classList.toggle('rotate-180');
}
}
function openGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.remove('hidden');
document.documentElement.classList.add('modal-open');
document.body.classList.add('modal-open');
}
}
function closeGuideModal() {
const modal = document.getElementById('guideModal');
if (modal) {
modal.classList.add('hidden');
document.documentElement.classList.remove('modal-open');
document.body.classList.remove('modal-open');
}
}
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeGuideModal();
}
});
</script>
<!-- ========================================================================= -->
<!-- MODAL POPUP: PANDUAN HALAMAN (SUMMARY P2H) -->
<!-- ========================================================================= -->
<div id="guideModal"
onclick="if(event.target === this) closeGuideModal()"
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
<div class="flex items-center space-x-3">
<div class="w-9 h-9 rounded-full bg-slate-100 text-slate-700 flex items-center justify-center font-bold text-sm border border-slate-200">
<i class="fa-solid fa-info"></i>
</div>
<div>
<h3 class="text-base font-bold text-slate-900 tracking-tight leading-tight">Panduan Halaman</h3>
<p class="text-xs text-slate-500">Summary P2H Unit Support</p>
</div>
</div>
<button type="button"
onclick="closeGuideModal()"
class="text-slate-400 hover:text-slate-600 transition p-1.5 rounded-lg hover:bg-slate-100 cursor-pointer">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="mt-4 space-y-4">
<p class="text-xs text-slate-600 leading-relaxed">
Halaman <strong>Summary P2H Unit Support</strong> menampilkan rekapitulasi performa dan tingkat kelaikan operasi harian alat berat.
</p>
<div class="space-y-3">
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-emerald-100/70 text-emerald-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-emerald-200/50">
<i class="fa-solid fa-chart-pie"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Rekapitulasi per Unit Support</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Melihat total inspeksi, jumlah lolos persetujuan, unit dengan temuan kerusakan, serta catatan jam kerja (HM) setiap alat.
</p>
</div>
</div>
<div class="bg-slate-50/70 border border-slate-100 rounded-2xl p-3.5 flex items-start space-x-3.5">
<div class="w-9 h-9 rounded-xl bg-amber-100/70 text-amber-700 flex items-center justify-center flex-shrink-0 mt-0.5 text-sm border border-amber-200/50">
<i class="fa-solid fa-filter"></i>
</div>
<div class="min-w-0 flex-1">
<h4 class="text-xs font-bold text-slate-900">Filter Fleksibel</h4>
<p class="text-[11px] text-slate-500 mt-0.5 leading-relaxed">
Pilih rentang tanggal, filter berdasarkan unit spesifik, status approval, atau shift kerja.
</p>
</div>
</div>
</div>
</div>
<div class="pt-4 mt-5 border-t border-slate-100 flex items-center justify-end">
<button type="button"
onclick="closeGuideModal()"
class="px-6 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold text-xs transition cursor-pointer shadow-2xs">
Saya Mengerti
</button>
</div>
</div>
</div>
@endsection
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
@extends('layouts.app')
@section('title', 'Master Template P2H - Admin QMA')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul (Tanpa Card Pembungkus Sesuai Referensi) -->
<div>
<div class="flex items-center space-x-1.5 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN SISTEM
</span>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
Master Template P2H Unit Support
</h2>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Daftar checksheet resmi pemeriksaan pra-harian untuk setiap kategori unit alat berat di proyek PLTA Merangin.
</p>
</div>
<!-- Kotak Pencarian & Reset Filter -->
<form method="GET" action="{{ route('qma.p2h.templates') }}" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
<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="templateSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari nama template alat (Excavator, Crane, Vibro) atau kode..."
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>
<div id="templateResetContainer">
@if(request('search'))
<a href="{{ route('qma.p2h.templates') }}"
id="templateResetBtn"
class="text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</form>
<!-- Tabel Master Template P2H Unit Support (Tampilan Tabel Bukan Card) -->
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden" id="templatesTableContainer">
<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 text-center w-32">KODE TEMPLATE</th>
<th class="py-3.5 px-4">NAMA TEMPLATE ALAT</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">BUTIR CEK</th>
<th class="py-3.5 px-4 text-center">UNIT TERKAIT</th>
<th class="py-3.5 px-4 text-center">RIWAYAT P2H</th>
<th class="py-3.5 px-4 text-center w-52">AKSI</th>
</tr>
</thead>
<tbody id="templatesTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($templates as $index => $tmpl)
<tr class="template-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $index + 1 }}
</td>
<td class="py-3.5 px-4 text-center font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
<span class="bg-blue-50 text-blue-800 px-2.5 py-1 rounded-lg border border-blue-200">
{{ $tmpl->code }}
</span>
</td>
<td class="py-3.5 px-4">
<div class="font-bold text-slate-900 text-sm leading-snug">{{ $tmpl->name }}</div>
<div class="text-[11px] text-slate-400 mt-0.5 line-clamp-1 max-w-lg">{{ $tmpl->description }}</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($tmpl->items_count > 0)
<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> Aktif
</span>
@else
<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-triangle-exclamation mr-1 text-[9px]"></i> Template Baru (Kosong)
</span>
@endif
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-bold {{ $tmpl->items_count > 0 ? 'bg-slate-100 text-slate-800 border border-slate-200' : 'bg-slate-50 text-slate-400' }}">
{{ $tmpl->items_count }} Butir
</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $tmpl->vehicles_count }}</span>
<span class="text-[10px] text-slate-400">Unit</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<span class="font-bold text-slate-800">{{ $tmpl->records_count }}</span>
<span class="text-[10px] text-slate-400">Laporan</span>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
<a href="{{ route('qma.p2h.templates.show', $tmpl->id) }}"
class="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-xl text-xs font-bold transition shadow-2xs {{ $tmpl->items_count > 0 ? 'bg-[#1b5e20] hover:bg-[#144919] text-white' : 'bg-emerald-50 hover:bg-emerald-100 text-[#1b5e20] border border-emerald-200' }}"
title="Buka & Kelola Pertanyaan Template {{ $tmpl->name }}">
<i class="fa-solid fa-list-check text-[11px]"></i>
<span>{{ $tmpl->items_count > 0 ? 'Lihat & Kelola Pertanyaan' : 'Kelola & Isi Pertanyaan' }}</span>
</a>
</td>
</tr>
@empty
<tr id="serverTemplateEmptyRow">
<td colspan="8" class="py-12 px-4 text-center text-slate-400">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
@if(request('search'))
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm mx-auto mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.p2h.templates') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="text-sm font-bold text-slate-700">Belum Ada Template</div>
<p class="text-xs text-slate-400 mt-1">Belum ada template checksheet P2H yang terdaftar.</p>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('templateSearchInput');
const tableBody = document.getElementById('templatesTableBody');
const resetContainer = document.getElementById('templateResetContainer');
const serverEmptyRow = document.getElementById('serverTemplateEmptyRow');
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.template-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
const match = text.includes(query);
row.style.display = match ? '' : 'none';
if (match) visibleCount++;
});
// Sembunyikan baris SSR empty jika sedang mengetik
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
// Hapus baris empty client jika ada sebelumnya
const existingClientEmpty = document.getElementById('clientTemplateEmptyRow');
if (existingClientEmpty) {
existingClientEmpty.remove();
}
// Tampilkan pesan jika tidak ada data yang cocok
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientTemplateEmptyRow';
emptyTr.innerHTML = `
<td colspan="8" class="py-12 px-4 text-center text-slate-400">
<div class="w-12 h-12 rounded-2xl bg-rose-50 text-rose-500 flex items-center justify-center text-xl shadow-xs mx-auto mb-3">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
<h4 class="text-sm font-bold text-slate-800">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</h4>
<p class="text-xs text-slate-400 max-w-sm mx-auto mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('templateSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
// Tampilkan atau sembunyikan tombol Reset Filter secara real-time
if (resetContainer) {
let resetBtn = document.getElementById('templateResetBtn');
if (query.length > 0) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.href = "{{ route('qma.p2h.templates') }}";
resetBtn.id = 'templateResetBtn';
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-700 font-semibold flex items-center space-x-1 transition px-3 py-2 rounded-xl hover:bg-rose-50 border border-transparent hover:border-rose-100';
const resetIcon = document.createElement('i');
resetIcon.className = 'fa-solid fa-rotate-left text-[11px]';
const resetText = document.createElement('span');
resetText.textContent = 'Reset Filter';
resetBtn.appendChild(resetIcon);
resetBtn.appendChild(resetText);
resetContainer.appendChild(resetBtn);
}
} else {
if (resetBtn && !{{ request()->filled('search') ? 'true' : 'false' }}) {
resetBtn.remove();
}
}
}
});
}
});
</script>
@endsection
+129 -25
View File
@@ -26,19 +26,19 @@
</div> </div>
<!-- Tombol Aksi Kanan --> <!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto"> <div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<button type="button" <button type="button"
onclick="alert('Fitur ekspor spreadsheet Light Vehicle sedang disiapkan')" 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"> class="w-full sm:w-auto flex items-center justify-center space-x-2 border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i> <i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Light Vehicle</span> <span class="truncate">Ekspor LV</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i> <i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button> </button>
<button onclick="openAddModal()" <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"> class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i> <i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Light Vehicle</span> <span class="truncate">Tambah LV</span>
</button> </button>
</div> </div>
</div> </div>
@@ -46,19 +46,17 @@
<!-- Kotak Pencarian & Filter Status --> <!-- Kotak Pencarian & Filter Status -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3"> <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"> <div 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"> <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> <i class="fa-solid fa-magnifying-glass text-xs"></i>
</span> </span>
<input type="text" <input type="text"
id="lvSearchInput"
name="search" name="search"
value="{{ request('search') }}" value="{{ request('search') }}"
placeholder="Cari kode LV, nopol, merek, tipe, atau pemilik..." 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"> 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>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<form method="GET" action="{{ route('qma.vehicles.lv') }}"> <form method="GET" action="{{ route('qma.vehicles.lv') }}">
@@ -74,17 +72,19 @@
</select> </select>
</form> </form>
@if(request('search') || request('status')) <div id="lvResetWrapper" class="flex items-center">
<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"> @if(request('search') || request('status'))
<i class="fa-solid fa-rotate-left"></i> <a id="lvResetBtn" 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">
<span>Reset Filter</span> <i class="fa-solid fa-rotate-left"></i>
</a> <span>Reset Filter</span>
@endif </a>
@endif
</div>
</div> </div>
</div> </div>
<!-- Tabel Data Light Vehicle (Header Navy Solid #06213f) --> <!-- Tabel Data Light Vehicle (Header Navy Solid #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden"> <div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse"> <table class="min-w-full text-xs text-left border-collapse">
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider"> <thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
@@ -101,9 +101,9 @@
<th class="py-3.5 px-4 text-center">AKSI</th> <th class="py-3.5 px-4 text-center">AKSI</th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white"> <tbody id="lvTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v) @forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition"> <tr class="lv-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400"> <td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }} {{ $vehicles->firstItem() + $index }}
</td> </td>
@@ -119,12 +119,11 @@
<button type="button" <button type="button"
onclick="openQrModal('{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}', '{{ addslashes($v->license_plate ?? '-') }}', '{{ addslashes($v->division ?? '-') }}', '{{ url('/gate-activity/' . $v->code) }}', this)" onclick="openQrModal('{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}', '{{ addslashes($v->license_plate ?? '-') }}', '{{ addslashes($v->division ?? '-') }}', '{{ url('/gate-activity/' . $v->code) }}', this)"
data-qr-base64="{{ base64_encode(\SimpleSoftwareIO\QrCode\Facades\QrCode::size(240)->margin(1)->generate(url('/gate-activity/' . $v->code))) }}" data-qr-base64="{{ base64_encode(\SimpleSoftwareIO\QrCode\Facades\QrCode::size(240)->margin(1)->generate(url('/gate-activity/' . $v->code))) }}"
class="group inline-flex items-center space-x-1.5 px-2 py-1 rounded-xl bg-slate-50 hover:bg-emerald-50 border border-slate-200 hover:border-emerald-300 transition shadow-2xs cursor-pointer" class="group inline-flex items-center justify-center p-1 rounded-xl bg-slate-50 hover:bg-emerald-50 border border-slate-200 hover:border-emerald-300 transition shadow-2xs cursor-pointer"
title="Klik untuk Lihat, Unduh & Cetak Stiker QR {{ $v->code }}"> title="Klik untuk Lihat, Unduh & Cetak Stiker QR {{ $v->code }}">
<div class="w-7 h-7 bg-white rounded-lg border border-slate-200 group-hover:border-emerald-300 flex items-center justify-center p-0.5 overflow-hidden [&>svg]:w-full [&>svg]:h-full shadow-2xs"> <div class="w-7 h-7 bg-white rounded-lg border border-slate-200 group-hover:border-emerald-300 flex items-center justify-center p-0.5 overflow-hidden [&>svg]:w-full [&>svg]:h-full shadow-2xs">
{!! \SimpleSoftwareIO\QrCode\Facades\QrCode::size(24)->margin(0)->generate(url('/gate-activity/' . $v->code)) !!} {!! \SimpleSoftwareIO\QrCode\Facades\QrCode::size(24)->margin(0)->generate(url('/gate-activity/' . $v->code)) !!}
</div> </div>
<i class="fa-solid fa-expand text-[10px] text-slate-400 group-hover:text-emerald-600"></i>
</button> </button>
</td> </td>
@@ -197,10 +196,26 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverLvEmptyRow">
<td colspan="10" class="py-12 text-center text-slate-400"> <td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-car text-3xl mb-2 block text-slate-300"></i> <i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
Belum ada armada Light Vehicle yang sesuai dengan kriteria pencarian. @if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.lv') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<p class="text-sm font-semibold text-slate-700">Belum ada armada Light Vehicle</p>
<p class="text-xs text-slate-400 mt-0.5">Belum ada data armada Light Vehicle yang sesuai dengan kriteria filter.</p>
@endif
</td> </td>
</tr> </tr>
@endforelse @endforelse
@@ -208,7 +223,7 @@
</table> </table>
</div> </div>
<div class="p-4 bg-slate-50 border-t border-slate-200"> <div id="lvPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }} {{ $vehicles->links() }}
</div> </div>
</div> </div>
@@ -857,6 +872,95 @@
document.getElementById('deleteVehicleModal').classList.add('hidden'); document.getElementById('deleteVehicleModal').classList.add('hidden');
} }
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('lvSearchInput');
const tableBody = document.getElementById('lvTableBody');
const resetWrapper = document.getElementById('lvResetWrapper');
const paginationContainer = document.getElementById('lvPaginationContainer');
const serverEmptyRow = document.getElementById('serverLvEmptyRow');
const hasServerFilters = {{ request()->filled('status') ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.lv-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientLvEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientLvEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('lvSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('lvResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'lvResetBtn';
resetBtn.href = "{{ route('qma.vehicles.lv') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-2';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left"></i><span>Reset Filter</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
}
});
@if($errors->any()) @if($errors->any())
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
openAddModal(); openAddModal();
+293 -379
View File
@@ -26,19 +26,19 @@
</div> </div>
<!-- Tombol Aksi Kanan --> <!-- Tombol Aksi Kanan -->
<div class="flex items-center space-x-3 w-full sm:w-auto"> <div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<button type="button" <button type="button"
onclick="alert('Fitur ekspor spreadsheet Unit Support sedang disiapkan')" 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"> class="w-full sm:w-auto flex items-center justify-center space-x-2 border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm">
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i> <i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
<span>Ekspor Unit Support</span> <span class="truncate">Ekspor Data</span>
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i> <i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
</button> </button>
<button onclick="openAddModal()" <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"> class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i> <i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Support</span> <span class="truncate">Tambah Kategori</span>
</button> </button>
</div> </div>
</div> </div>
@@ -46,22 +46,17 @@
<!-- Kotak Pencarian & Filter Kategori Alat Berat --> <!-- Kotak Pencarian & Filter Kategori Alat Berat -->
<div class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3"> <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"> <div 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"> <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> <i class="fa-solid fa-magnifying-glass text-xs"></i>
</span> </span>
<input type="text" <input type="text"
id="supportSearchInput"
name="search" name="search"
value="{{ request('search') }}" value="{{ request('search') }}"
placeholder="Cari kode unit, model, tipe, lokasi, dokumen..." 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"> 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>
<div class="flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<!-- Filter Kategori Alat Berat --> <!-- Filter Kategori Alat Berat -->
@@ -69,9 +64,6 @@
@if(request('search')) @if(request('search'))
<input type="hidden" name="search" value="{{ request('search') }}"> <input type="hidden" name="search" value="{{ request('search') }}">
@endif @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]"> <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> <option value="">Semua Kategori Alat</option>
@foreach($availableCategories as $cat) @foreach($availableCategories as $cat)
@@ -80,159 +72,121 @@
</select> </select>
</form> </form>
<!-- Filter Status Operasional --> <div id="supportResetWrapper" class="flex items-center">
<form method="GET" action="{{ route('qma.vehicles.support') }}" class="flex items-center space-x-2"> @if(request('search') || request('unit_category'))
@if(request('search')) <a id="supportResetBtn" 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">
<input type="hidden" name="search" value="{{ request('search') }}"> <i class="fa-solid fa-rotate-left"></i>
<span>Reset</span>
</a>
@endif @endif
@if(request('unit_category')) </div>
<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>
</div> </div>
<!-- Tabel Data Unit Support (Header Navy Solid #06213f) --> <!-- Tabel Data Kategori Unit Support (Header Navy Solid #06213f) -->
<div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden"> <div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="min-w-full text-xs text-left border-collapse"> <table class="min-w-full text-xs text-left border-collapse">
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider"> <thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
<tr> <tr>
<th class="py-3.5 px-4 text-center w-12">NO</th> <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">KODE KATEGORI</th>
<th class="py-3.5 px-4">KATEGORI & MODEL</th> <th class="py-3.5 px-4">KATEGORI ALAT</th>
<th class="py-3.5 px-4">MEREK & SPESIFIKASI</th> <th class="py-3.5 px-4 text-center">JUMLAH (QTY)</th>
<th class="py-3.5 px-4">LOKASI KERJA</th> <th class="py-3.5 px-4">MEREK & MODEL</th>
<th class="py-3.5 px-4 text-right">ODOMETER (HM/KM)</th> <th class="py-3.5 px-4">SPESIFIKASI</th>
<th class="py-3.5 px-4 text-center">DOKUMEN IZIN</th> <th class="py-3.5 px-4">DIVISI & KEPEMILIKAN</th>
<th class="py-3.5 px-4 text-center">STATUS</th>
<th class="py-3.5 px-4 text-center">AKSI</th> <th class="py-3.5 px-4 text-center">AKSI</th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white"> <tbody id="supportTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($vehicles as $index => $v) @forelse($vehicles as $index => $v)
<tr class="hover:bg-slate-50/70 transition"> <tr class="support-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400"> <td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $vehicles->firstItem() + $index }} {{ $vehicles->firstItem() + $index }}
</td> </td>
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap"> <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"> <span class="bg-blue-50 text-blue-800 px-2.5 py-1 rounded border border-blue-200">
{{ $v->code }} {{ $v->code }}
</span> </span>
</td> </td>
<td class="py-3.5 px-4 whitespace-nowrap"> <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="font-bold text-slate-900 block text-xs">{{ $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 text-center whitespace-nowrap">
<a href="{{ route('qma.vehicles.support.units', $v->id) }}"
class="inline-flex items-center space-x-1.5 px-3.5 py-1.5 rounded-full text-xs font-bold bg-[#e8f8f0] text-[#00897b] border border-[#a7f3d0] hover:bg-[#d1fae5] transition shadow-2xs group cursor-pointer"
title="Buka daftar {{ $v->units_count ?? 0 }} unit fisik">
<span>{{ $v->units_count ?? 0 }} Unit</span>
<i class="fa-solid fa-chevron-right text-[10px] ml-1 transition group-hover:translate-x-0.5"></i>
</a>
</td> </td>
<td class="py-3.5 px-4"> <td class="py-3.5 px-4">
<div class="font-bold text-slate-900">{{ $v->brand_type }}</div> <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->model_number)
@if($v->unit_type) <div class="text-[10px] text-slate-500 font-mono mt-0.5">Model: {{ $v->model_number }}</div>
<span>{{ $v->unit_type }}</span> @endif
@endif </td>
@if($v->production_year)
<span>&bull; Thn {{ $v->production_year }}</span> <td class="py-3.5 px-4 text-slate-700">
@endif @if($v->unit_type)
</div> <span class="font-medium text-xs">{{ $v->unit_type }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</td> </td>
<td class="py-3.5 px-4 text-slate-600"> <td class="py-3.5 px-4 text-slate-600">
<div class="font-medium text-slate-800"> <div class="font-medium text-slate-800">{{ $v->division ?? '-' }}</div>
@if($v->location) <span class="text-[10px] text-slate-400 block">{{ $v->ownership ?? 'PT Kerinci Merangin Hidro' }}</span>
<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>
<td class="py-3.5 px-4 text-center whitespace-nowrap"> <td class="py-3.5 px-4 text-center whitespace-nowrap">
<div class="flex items-center justify-center space-x-1.5"> <div class="flex items-center justify-center space-x-1.5">
<button onclick='openDetailModal(@json($v))' <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" 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"> title="Lihat Spesifikasi Kategori">
<i class="fa-regular fa-eye text-sm"></i> <i class="fa-regular fa-eye text-sm"></i>
</button> </button>
<button onclick='openEditModal(@json($v))' <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" 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"> title="Edit Data Kategori">
<i class="fa-regular fa-pen-to-square text-sm"></i> <i class="fa-regular fa-pen-to-square text-sm"></i>
</button> </button>
<button type="button" <button type="button"
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')" 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" 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"> title="Hapus Kategori">
<i class="fa-regular fa-trash-can text-sm"></i> <i class="fa-regular fa-trash-can text-sm"></i>
</button> </button>
</div> </div>
</td> </td>
</tr> </tr>
@empty @empty
<tr> <tr id="serverSupportEmptyRow">
<td colspan="9" class="py-12 text-center text-slate-400"> <td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-tractor text-3xl mb-2 block text-slate-300"></i> <i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
Belum ada unit alat berat yang sesuai dengan filter. @if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.support') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<p class="text-sm font-semibold text-slate-700">Belum ada unit alat berat</p>
<p class="text-xs text-slate-400 mt-0.5">Belum ada unit alat berat yang sesuai dengan filter.</p>
@endif
</td> </td>
</tr> </tr>
@endforelse @endforelse
@@ -240,7 +194,7 @@
</table> </table>
</div> </div>
<div class="p-4 bg-slate-50 border-t border-slate-200"> <div id="supportPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
{{ $vehicles->links() }} {{ $vehicles->links() }}
</div> </div>
</div> </div>
@@ -252,39 +206,41 @@
<div id="addVehicleModal" <div id="addVehicleModal"
onclick="if(event.target === this) closeAddModal()" onclick="if(event.target === this) closeAddModal()"
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"> 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"> <div class="bg-white rounded-3xl shadow-2xl max-w-xl 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"> <div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight"> <div>
Tambah Unit Support <h3 class="text-xl font-bold text-slate-900 tracking-tight">
</h3> Tambah Kategori Unit Support
</h3>
<p class="text-xs text-slate-500 mt-0.5">Mendaftarkan kategori/tipe master aset baru ke sistem.</p>
</div>
<button type="button" onclick="closeAddModal()" class="text-slate-400 hover:text-slate-600 transition p-1"> <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> <i class="fa-solid fa-xmark text-lg"></i>
</button> </button>
</div> </div>
<form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-3"> <form id="addVehicleForm" action="{{ route('qma.vehicles.store') }}" method="POST" class="space-y-3.5">
@csrf @csrf
<input type="hidden" name="category" value="unit_support"> <input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kode Unit <span class="text-rose-500">*</span></label> <label class="block text-xs font-bold text-slate-800 mb-1">Kode Kategori <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="addCodeInput" required placeholder="MISAL: EX01, CR01, DT05" value="{{ old('code') }}" <input type="text" name="code" id="addCodeInput" required placeholder="MISAL: EX01, CR01, BL01" 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"> class="w-full text-xs px-3.5 py-2.5 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 font-bold">
<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"> <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> <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> <span id="codeErrorText">{{ $errors->first('code') ?? 'Kode unit sudah ada, silakan gunakan kode lain.' }}</span>
</p> </p>
<p id="codeHint" class="text-[11px] text-slate-400 mt-0.5 @if($errors->has('code')) hidden @endif"> <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. * Digunakan sebagai dasar kode unit fisik (contoh: BL01-001).
</p> </p>
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kategori Alat Berat <span class="text-rose-500">*</span></label> <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" <input type="text" name="unit_category" required placeholder="Contoh: Excavator / Mobile Crane / Boomlift"
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"> 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 font-medium">
</div> </div>
</div> </div>
@@ -292,99 +248,47 @@
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Merek & Tipe Lengkap <span class="text-rose-500">*</span></label> <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" <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"> 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> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Tipe / Model Khusus</label> <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" <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"> 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-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> </div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Lokasi Kerja Lapangan</label> <label class="block text-xs font-bold text-slate-800 mb-1">Nomor Model</label>
<input type="text" name="location" placeholder="Contoh: Beringin Tunggal / CCR DAM / Tunnel" <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"> 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 font-mono">
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label> <label class="block text-xs font-bold text-slate-800 mb-1">Estimasi Konsumsi BBM (Liter/Jam)</label>
<input type="text" name="division" placeholder="Contoh: Civil & Inviro / Mechanical" <input type="number" step="0.01" name="fuel_consumption" placeholder="Contoh: 18.5"
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"> 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 font-mono">
</div> </div>
</div> </div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset</label> <label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
<input type="text" name="ownership" placeholder="Contoh: PT Kerinci Merangin Hidro" <select name="division"
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"> 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-medium">
</div> <option value="">-- Pilih Divisi Penanggung Jawab --</option>
<div> @foreach($availableDivisions as $div)
<label class="block text-xs font-bold text-slate-800 mb-1">Status Operasi <span class="text-rose-500">*</span></label> <option value="{{ $div }}" {{ old('division') === $div ? 'selected' : '' }}>{{ $div }}</option>
<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"> @endforeach
<option value="Operation">Operation (Siap Kerja)</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select> </select>
</div> </div>
<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> <label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset</label>
<input type="number" step="0.01" name="current_km" required value="0" <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 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-mono"> 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> </div>
<!-- Bagian Perizinan & Dokumen --> <!-- Footer Tombol -->
<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"> <div class="pt-3 flex items-center justify-end space-x-3">
<button type="button" onclick="closeAddModal()" <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"> 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">
@@ -392,7 +296,7 @@
</button> </button>
<button type="submit" <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"> 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 Simpan Kategori
</button> </button>
</div> </div>
</form> </form>
@@ -400,42 +304,44 @@
</div> </div>
<!-- ========================================================================= --> <!-- ========================================================================= -->
<!-- MODAL: EDIT UNIT SUPPORT --> <!-- MODAL: EDIT KATEGORI UNIT SUPPORT -->
<!-- ========================================================================= --> <!-- ========================================================================= -->
<div id="editVehicleModal" <div id="editVehicleModal"
onclick="if(event.target === this) closeEditModal()" onclick="if(event.target === this) closeEditModal()"
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"> 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"> <div class="bg-white rounded-3xl shadow-2xl max-w-xl 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"> <div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight"> <div>
Edit Unit Support <h3 class="text-xl font-bold text-slate-900 tracking-tight">
</h3> Edit Kategori Unit Support
</h3>
<p class="text-xs text-slate-500 mt-0.5">Memperbarui informasi master kategori aset.</p>
</div>
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1"> <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> <i class="fa-solid fa-xmark text-lg"></i>
</button> </button>
</div> </div>
<form id="editVehicleForm" action="" method="POST" class="space-y-4"> <form id="editVehicleForm" action="" method="POST" class="space-y-3.5">
@csrf @csrf
<input type="hidden" name="category" value="unit_support"> <input type="hidden" name="category" value="unit_support">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit <span class="text-rose-500">*</span></label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Kategori <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="editCode" required <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"> 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 font-bold">
<p id="editCodeError" class="text-xs text-rose-600 font-semibold mt-1.5 hidden flex items-center"> <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> <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> <span id="editCodeErrorText">Kode unit sudah ada, silakan gunakan kode lain.</span>
</p> </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> <p id="editCodeHint" class="text-[11px] text-slate-400 mt-1">* Jika diubah, kode seluruh unit fisik di bawahnya akan otomatis menyesuaikan.</p>
</div> </div>
<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> <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 <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"> 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-medium">
</div> </div>
</div> </div>
@@ -452,90 +358,38 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Model</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Model</label>
<input type="text" name="model_number" id="editModelNumber" <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"> 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>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM Standar (L/Jam)</label>
<input type="number" name="production_year" id="editProductionYear" <input type="number" step="0.01" name="fuel_consumption" id="editFuelConsumption"
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"> 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>
<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> </div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Penanggung Jawab</label>
<input type="text" name="location" id="editLocation" <select 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"> 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-medium">
<option value="">-- Pilih Divisi Penanggung Jawab --</option>
@foreach($availableDivisions as $div)
<option value="{{ $div }}">{{ $div }}</option>
@endforeach
</select>
</div> </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> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Kepemilikan</label>
<input type="text" name="ownership" id="editOwnership" <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"> 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>
<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> </div>
<!-- Bagian Perizinan di Edit --> <!-- Footer Tombol -->
<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"> <div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()" <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"> 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">
@@ -543,7 +397,7 @@
</button> </button>
<button type="submit" <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"> class="px-6 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white font-bold text-xs transition shadow-sm">
Perbarui Data Perbarui Kategori
</button> </button>
</div> </div>
</form> </form>
@@ -551,15 +405,17 @@
</div> </div>
<!-- ========================================================================= --> <!-- ========================================================================= -->
<!-- MODAL: DETAIL UNIT SUPPORT --> <!-- MODAL: DETAIL SPESIFIKASI KATEGORI UNIT SUPPORT -->
<!-- ========================================================================= --> <!-- ========================================================================= -->
<div id="detailVehicleModal" onclick="if(event.target === this) closeDetailModal()" 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 id="detailVehicleModal" onclick="if(event.target === this) closeDetailModal()" 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"> <div class="bg-white rounded-3xl shadow-2xl max-w-xl 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"> <div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-slate-900 tracking-tight"> <div>
Detail Unit Support <h3 class="text-xl font-bold text-slate-900 tracking-tight">
</h3> Detail Spesifikasi Kategori
</h3>
<p class="text-xs text-slate-500 mt-0.5">Informasi master kategori aset Unit Support.</p>
</div>
<button type="button" onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600 transition p-1"> <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> <i class="fa-solid fa-xmark text-lg"></i>
</button> </button>
@@ -568,15 +424,15 @@
<div class="space-y-4"> <div class="space-y-4">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Unit</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Kode Kategori</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"> <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> <span id="detailCode" class="bg-blue-50 text-blue-800 px-2.5 py-0.5 rounded border border-blue-200">-</span>
</div> </div>
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori & Model</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Kategori Alat</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"> <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> <span id="detailCategory">-</span>
</div> </div>
</div> </div>
</div> </div>
@@ -589,89 +445,58 @@
</div> </div>
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor Polisi (Nopol)</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Tipe / Model Khusus</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"> <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="detailNopol">-</span> <span id="detailUnitType">-</span>
</div> </div>
</div> </div>
</div> </div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Tahun Produksi</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Nomor 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-medium flex items-center"> <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 flex items-center">
<span id="detailYear">-</span> <span id="detailModelNumber">-</span>
</div> </div>
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Lokasi Kerja</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Konsumsi BBM Standar</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"> <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> <span id="detailFuel">-</span>
</div> </div>
</div> </div>
</div> </div>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3.5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi & Kepemilikan</label> <label class="block text-xs font-bold text-slate-800 mb-1.5">Divisi Penanggung Jawab</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"> <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> <span id="detailDivision">-</span>
</div> </div>
</div> </div>
<div> <div>
<label class="block text-xs font-bold text-slate-800 mb-1.5">Status Operasi</label> <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 rounded-xl border border-slate-200 bg-white flex items-center"> <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="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="detailOwnership">-</span>
<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> </div>
</div> </div>
<!-- Bagian Legalitas & Perizinan --> <!-- Card Unit Fisik Terdaftar -->
<div class="p-4 rounded-2xl bg-slate-50 border border-slate-200 space-y-3"> <div class="p-4 rounded-2xl bg-emerald-50/70 border border-emerald-200/80 flex items-center justify-between">
<div class="flex items-center space-x-2 text-slate-800 font-bold text-xs"> <div>
<i class="fa-solid fa-file-contract text-emerald-600"></i> <span class="text-xs font-bold text-emerald-950 block">Unit Fisik Terdaftar</span>
<span>Dokumen Legalitas & Perizinan Kelayakan</span> <span id="detailUnitCountText" class="text-xs text-emerald-800 font-medium">0 Unit Fisik</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>
<a id="detailManageUnitsBtn" href="#" class="px-4 py-2 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white text-xs font-bold transition shadow-sm inline-flex items-center justify-center">
<span>Kelola Unit Fisik</span>
</a>
</div> </div>
<!-- Footer Tombol Bersih Sesuai Referensi Tambah Aset --> <!-- Footer Tombol Tutup -->
<div class="pt-4 flex items-center justify-end"> <div class="pt-2 flex items-center justify-end">
<button type="button" onclick="closeDetailModal()" <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"> class="px-6 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-900 text-white font-bold text-xs transition shadow-sm cursor-pointer">
Tutup Tutup
</button> </button>
</div> </div>
@@ -722,6 +547,95 @@
</div> </div>
<script> <script>
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('supportSearchInput');
const tableBody = document.getElementById('supportTableBody');
const resetWrapper = document.getElementById('supportResetWrapper');
const paginationContainer = document.getElementById('supportPaginationContainer');
const serverEmptyRow = document.getElementById('serverSupportEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['status', 'unit_category']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.support-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientSupportEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientSupportEmptyRow';
emptyTr.innerHTML = `
<td colspan="8" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('supportSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('supportResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'supportResetBtn';
resetBtn.href = "{{ route('qma.vehicles.support') }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left"></i><span>Reset</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
}
});
// Daftar semua kode kendaraan unit support yang sudah terdaftar di sistem // 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 existingVehicleCodes = @json($existingCodes ?? \App\Models\Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c))));
@@ -878,16 +792,28 @@
document.getElementById('editBrandType').value = v.brand_type || ''; document.getElementById('editBrandType').value = v.brand_type || '';
document.getElementById('editUnitType').value = v.unit_type || ''; document.getElementById('editUnitType').value = v.unit_type || '';
document.getElementById('editModelNumber').value = v.model_number || ''; document.getElementById('editModelNumber').value = v.model_number || '';
document.getElementById('editProductionYear').value = v.production_year || ''; const divSelect = document.getElementById('editDivision');
document.getElementById('editLicensePlate').value = v.license_plate || ''; if (divSelect) {
document.getElementById('editLocation').value = v.location || ''; if (v.division) {
document.getElementById('editDivision').value = v.division || ''; let found = false;
for (let i = 0; i < divSelect.options.length; i++) {
if (divSelect.options[i].value === v.division) {
found = true;
break;
}
}
if (!found) {
const newOpt = document.createElement('option');
newOpt.value = v.division;
newOpt.textContent = v.division;
divSelect.appendChild(newOpt);
}
divSelect.value = v.division;
} else {
divSelect.value = '';
}
}
document.getElementById('editOwnership').value = v.ownership || ''; 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 || ''; document.getElementById('editFuelConsumption').value = v.fuel_consumption || '';
} }
function closeEditModal() { function closeEditModal() {
@@ -898,31 +824,19 @@
function openDetailModal(v) { function openDetailModal(v) {
document.getElementById('detailVehicleModal').classList.remove('hidden'); document.getElementById('detailVehicleModal').classList.remove('hidden');
document.getElementById('detailCode').innerText = v.code || '-'; document.getElementById('detailCode').innerText = v.code || '-';
document.getElementById('detailCategory').innerText = v.unit_category || '-';
document.getElementById('detailBrand').innerText = v.brand_type || '-'; document.getElementById('detailBrand').innerText = v.brand_type || '-';
document.getElementById('detailCategoryModel').innerText = (v.unit_category || '-') + (v.model_number ? ` (${v.model_number})` : ''); document.getElementById('detailUnitType').innerText = v.unit_type || '-';
document.getElementById('detailStatus').innerText = v.status || '-'; document.getElementById('detailModelNumber').innerText = v.model_number || '-';
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('detailFuel').innerText = v.fuel_consumption ? `${v.fuel_consumption} L/Jam` : '-';
document.getElementById('detailOwnerDiv').innerText = (v.division || '-') + ' / ' + (v.ownership || '-'); document.getElementById('detailDivision').innerText = v.division || '-';
document.getElementById('detailSilo').innerText = v.silo_document || '-'; document.getElementById('detailOwnership').innerText = v.ownership || 'PT Kerinci Merangin Hidro';
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'); const count = v.units_count !== undefined ? v.units_count : 0;
if (badge) { document.getElementById('detailUnitCountText').innerText = count + ' Unit Fisik';
badge.className = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold border '; const manageBtn = document.getElementById('detailManageUnitsBtn');
if (v.status === 'Operation') { if (manageBtn) {
badge.className += 'bg-emerald-50 text-emerald-700 border-emerald-200'; manageBtn.href = `/qma/vehicles/unit-support/${v.id}/units`;
} 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() { function closeDetailModal() {
@@ -0,0 +1,829 @@
@extends('layouts.app')
@section('title', 'Unit Fisik ' . $category->code . ' - Admin QMA | PT Kerinci Merangin Hidro')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul & Tombol Aksi (Pola justify-between antara judul kiri & grup tombol kanan) -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<div class="flex items-center space-x-2 mb-1">
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
MANAJEMEN UNIT FISIK
</span>
</div>
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
{{ $category->unit_category ?? 'Alat Berat' }}
</h2>
<p class="text-xs text-slate-500 mt-1">
{{ $category->brand_type }}{{ $category->model_number ? ' • Model: ' . $category->model_number : '' }}
</p>
</div>
<!-- Tombol Aksi Kanan -->
<div class="grid grid-cols-2 gap-2.5 w-full sm:flex sm:items-center sm:gap-3 sm:w-auto">
<a href="{{ route('qma.vehicles.support') }}"
class="w-full sm:w-auto flex items-center justify-center space-x-2 text-xs font-bold text-slate-700 hover:text-slate-900 bg-white border border-gray-200 rounded-xl px-4 py-2.5 shadow-sm transition hover:bg-gray-50 cursor-pointer">
<i class="fa-solid fa-arrow-left text-xs text-slate-500"></i>
<span>Kembali</span>
</a>
<button onclick="openAddUnitModal()"
class="w-full sm:w-auto flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Baru</span>
</button>
</div>
</div>
{{-- Alert Error / Validasi Form (Pesan sukses telah ditangani oleh Toast Notification global di layout) --}}
@if(session('error'))
<div class="p-3.5 bg-rose-50 border border-rose-200 text-rose-800 rounded-xl text-xs flex items-center space-x-2">
<i class="fa-solid fa-circle-exclamation text-rose-600"></i>
<span class="font-semibold">{{ session('error') }}</span>
</div>
@endif
@if($errors->any())
<div class="p-3.5 bg-rose-50 border border-rose-200 text-rose-800 rounded-xl text-xs">
<div class="font-bold mb-1 flex items-center space-x-1">
<i class="fa-solid fa-triangle-exclamation"></i>
<span>Gagal memproses data:</span>
</div>
<ul class="list-disc pl-5 space-y-0.5">
@foreach($errors->all() as $err)
<li>{{ $err }}</li>
@endforeach
</ul>
</div>
@endif
<!-- Kotak Pencarian & Filter Status Unit Fisik -->
<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.units', $category->id) }}" 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"
id="unitSearchInput"
name="search"
value="{{ request('search') }}"
placeholder="Cari kode unit fisik, lokasi, SILO..."
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 Status Dropdown -->
<form method="GET" action="{{ route('qma.vehicles.support.units', $category->id) }}" class="flex items-center space-x-2">
@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] shadow-sm cursor-pointer">
<option value="">Semua Status</option>
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation</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>
<div id="unitResetWrapper" class="flex items-center">
@if(request('search') || request('status'))
<a id="unitResetBtn" href="{{ route('qma.vehicles.support.units', $category->id) }}" 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 text-[11px]"></i>
<span>Reset Filter</span>
</a>
@endif
</div>
</div>
</div>
<!-- Tabel Data Unit Fisik (Header Navy Solid #06213f) -->
<div class="bg-white rounded-none sm: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">NO. SERI / RANGKA</th>
<th class="py-3.5 px-4 text-center">TAHUN</th>
<th class="py-3.5 px-4 text-center">NO. POLISI</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 id="unitsTableBody" class="divide-y divide-slate-100 text-slate-700 bg-white">
@forelse($units as $index => $u)
<tr class="unit-row hover:bg-slate-50/70 transition">
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
{{ $units->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.5 py-1 rounded-lg border border-blue-200 font-bold">
{{ $u->code }}
</span>
</td>
<td class="py-3.5 px-4 font-mono text-xs text-slate-700 whitespace-nowrap">
@if($u->serial_number)
<span class="font-semibold">{{ $u->serial_number }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-center text-xs text-slate-700 font-medium whitespace-nowrap">
@if($u->production_year)
<span>{{ $u->production_year }}</span>
@else
<span class="text-slate-300">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-center font-mono text-xs whitespace-nowrap">
@if($u->license_plate)
<span class="bg-slate-100 text-slate-800 px-2 py-0.5 rounded border border-slate-200 font-semibold">{{ $u->license_plate }}</span>
@else
<span class="text-slate-300 font-sans font-normal">-</span>
@endif
</td>
<td class="py-3.5 px-4 text-slate-600">
<div class="font-medium text-slate-800">
@if($u->location)
<i class="fa-solid fa-location-dot text-[9px] mr-1 text-rose-500"></i>{{ $u->location }}
@else
<span class="text-slate-400 italic">Belum ditentukan</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-right font-mono font-bold text-slate-800 whitespace-nowrap">
{{ number_format($u->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($u->silo_document)
<span class="inline-flex items-center px-2.5 py-0.5 rounded text-[10px] font-semibold bg-emerald-50 text-emerald-800 border border-emerald-200" title="SILO: {{ $u->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($u->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: {{ $u->kir_document }}
</span>
@endif
</div>
</td>
<td class="py-3.5 px-4 text-center whitespace-nowrap">
@if($u->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">
Operation
</span>
@elseif($u->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">
Standby
</span>
@elseif($u->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">
Breakdown
</span>
@elseif($u->status === 'Maintenance')
<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">
Maintenance
</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">
{{ $u->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">
<a href="{{ route('p2h.form', ['code' => $u->code]) }}"
target="_blank"
class="inline-flex items-center space-x-1 text-[#1b5e20] hover:text-[#144918] hover:bg-emerald-50 px-2 py-1 rounded-lg transition"
title="Buka Form P2H Unit Ini">
<i class="fa-solid fa-file-pen text-sm"></i>
</a>
<button onclick='openDetailModal(@json($u))'
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 Unit">
<i class="fa-regular fa-eye text-sm"></i>
</button>
<button onclick='openEditModal(@json($u))'
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">
<i class="fa-regular fa-pen-to-square text-sm"></i>
</button>
<button type="button"
onclick="openDeleteModal('{{ $u->id }}', '{{ $u->code }}')"
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 Fisik">
<i class="fa-regular fa-trash-can text-sm"></i>
</button>
</div>
</td>
</tr>
@empty
<tr id="serverUnitEmptyRow">
<td colspan="10" class="py-12 px-4 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
@if(request('search'))
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">{{ request('search') }}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<a href="{{ route('qma.vehicles.support.units', array_merge(['id' => $category->id], request()->except('search', 'page'))) }}" class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</a>
</div>
@else
<div class="flex flex-col items-center justify-center">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 mb-3">
<i class="fa-solid fa-cubes text-xl"></i>
</div>
<p class="font-semibold text-slate-700 text-sm">Belum ada unit fisik untuk kategori ini</p>
<p class="text-xs text-slate-400 mt-1 max-w-sm">
Kategori ini belum memiliki armada fisik terdaftar. Silakan klik tombol di bawah untuk menambahkan unit fisik pertama.
</p>
<button onclick="openAddUnitModal()" class="mt-4 bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2 rounded-xl text-xs font-bold transition inline-flex items-center space-x-2">
<i class="fa-solid fa-plus text-xs"></i>
<span>Tambah Unit Baru</span>
</button>
</div>
@endif
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div id="unitsPaginationContainer">
@if($units->hasPages())
<div class="px-6 py-4 border-t border-slate-200">
{{ $units->links() }}
</div>
@endif
</div>
</div>
</div>
<!-- Modal Tambah Unit Baru (Sesuai Referensi Gambar media_1792028135493_30b2da2e.png) -->
<div id="addUnitModal" class="fixed inset-0 z-50 hidden overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" aria-hidden="true" onclick="closeAddUnitModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full border border-slate-200">
<div class="p-6">
<!-- Judul Modal -->
<h3 class="text-xl font-extrabold text-slate-900 tracking-tight mb-5" id="modal-title">
Tambah Unit Baru
</h3>
<form method="POST" action="{{ route('qma.vehicles.support.units.store', $category->id) }}" id="addUnitForm" class="space-y-4">
@csrf
<!-- Aset Induk (Readonly) Sesuai Mockup -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Aset Induk
</label>
<input type="text"
readonly
value="{{ $category->code }} - {{ $category->brand_type ?? $category->unit_category }}"
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-slate-50 text-slate-600 font-medium focus:outline-none cursor-not-allowed">
</div>
<!-- Kode Unit * (Prefix Box + Input Urut Hijau Border Sesuai Mockup) -->
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Kode Unit <span class="text-rose-500">*</span>
</label>
<div class="flex rounded-xl overflow-hidden border-2 border-emerald-700 focus-within:ring-2 focus-within:ring-emerald-600/20 transition shadow-2xs">
<span class="inline-flex items-center px-3.5 py-2 bg-slate-100 text-slate-700 text-xs font-bold font-mono border-r border-slate-200 select-none">
{{ $category->code }}-
</span>
<input type="text"
name="unit_number"
id="unitNumberInput"
required
value="{{ $nextUnitNumber }}"
placeholder="Contoh: 001"
class="w-full text-xs px-3.5 py-2.5 bg-white text-slate-900 font-mono font-bold placeholder-slate-400 focus:outline-none">
</div>
<p class="text-[10px] text-slate-400 mt-1">
Kode lengkap: <span id="fullCodePreview" class="font-mono font-bold text-slate-700">{{ $nextUnitCode }}</span>
</p>
</div>
<!-- Nomor Seri / Rangka & Nomor Polisi / Plat -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No. Seri / Rangka
</label>
<input type="text"
name="serial_number"
placeholder="Contoh: VIN/SN12345"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Nomor Polisi / Plat
</label>
<input type="text"
name="license_plate"
placeholder="Contoh: BH 1234 XX"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono uppercase focus:outline-none focus:border-emerald-600">
</div>
</div>
<!-- Tahun Produksi & Status Operasi Awal -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Tahun Produksi
</label>
<input type="number"
name="production_year"
min="1980"
max="{{ date('Y') + 1 }}"
placeholder="Contoh: 2021"
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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Status Operasional <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 font-semibold focus:outline-none focus:border-emerald-600">
<option value="Operation" selected>Operation (Siap Operasi)</option>
<option value="Standby">Standby (Tersedia)</option>
<option value="Breakdown">Breakdown (Rusak)</option>
<option value="Maintenance">Maintenance (Perawatan)</option>
</select>
</div>
</div>
<!-- Odometer Awal (HM/KM) -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Odometer Awal (HM/KM)
</label>
<input type="number"
name="current_km"
step="0.01"
min="0"
value="0"
placeholder="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-emerald-600 font-mono">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
Lokasi Penempatan
</label>
<select name="location"
class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium focus:outline-none focus:border-emerald-600">
<option value="" disabled {{ empty($category->location) ? 'selected' : '' }}>-- Pilih Lokasi Penempatan --</option>
@foreach($masterLocations as $loc)
<option value="{{ $loc }}" {{ (old('location') ?? $category->location) === $loc ? 'selected' : '' }}>
{{ $loc }}
</option>
@endforeach
</select>
</div>
</div>
<!-- Dokumen SILO & KIR -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No Dokumen SILO
</label>
<input type="text"
name="silo_document"
placeholder="Nomor SILO (opsional)"
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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">
No Dokumen KIR
</label>
<input type="text"
name="kir_document"
placeholder="Nomor KIR (opsional)"
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-emerald-600">
</div>
</div>
<!-- Tombol Aksi Batal & Simpan Unit (Sesuai Desain Mockup) -->
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button"
onclick="closeAddUnitModal()"
class="px-5 py-2.5 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">
Batal
</button>
<button type="submit"
class="px-5 py-2.5 text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144919] rounded-xl transition shadow-sm cursor-pointer">
Simpan Unit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Edit Data Unit Fisik -->
<div id="editModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeEditModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full border border-slate-200">
<div class="p-6">
<h3 class="text-xl font-extrabold text-slate-900 tracking-tight mb-5">
Edit Data Unit Fisik
</h3>
<form id="editUnitForm" method="POST" action="" class="space-y-4">
@csrf
<input type="hidden" name="category" value="unit_support">
<input type="hidden" name="brand_type" id="edit_brand_type">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Kode Unit <span class="text-rose-500">*</span></label>
<input type="text" name="code" id="edit_code" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-slate-100 text-slate-700 font-mono font-bold focus:outline-none" readonly>
</div>
<!-- Nomor Seri / Rangka & Nomor Polisi / Plat -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">No. Seri / Rangka</label>
<input type="text" name="serial_number" id="edit_serial_number" placeholder="Contoh: VIN/SN12345" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Nomor Polisi / Plat</label>
<input type="text" name="license_plate" id="edit_license_plate" placeholder="Contoh: BH 1234 XX" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono uppercase focus:outline-none focus:border-emerald-600">
</div>
</div>
<!-- Tahun Produksi & Status Operasi -->
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Tahun Produksi</label>
<input type="number" name="production_year" id="edit_production_year" min="1980" max="{{ date('Y') + 1 }}" placeholder="Contoh: 2021" 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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Status Operasi <span class="text-rose-500">*</span></label>
<select name="status" id="edit_status" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white font-semibold text-slate-800 focus:outline-none focus:border-emerald-600">
<option value="Operation">Operation</option>
<option value="Standby">Standby</option>
<option value="Breakdown">Breakdown</option>
<option value="Maintenance">Maintenance</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Odometer (HM/KM) <span class="text-rose-500">*</span></label>
<input type="number" step="0.01" name="current_km" id="edit_current_km" required class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono focus:outline-none focus:border-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Lokasi Penempatan</label>
<select name="location" id="edit_location" class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium focus:outline-none focus:border-emerald-600">
<option value="">-- Pilih Lokasi Penempatan --</option>
@foreach($masterLocations as $loc)
<option value="{{ $loc }}">{{ $loc }}</option>
@endforeach
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Dokumen SILO</label>
<input type="text" name="silo_document" id="edit_silo" 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-emerald-600">
</div>
<div>
<label class="block text-xs font-bold text-slate-700 mb-1.5">Dokumen KIR</label>
<input type="text" name="kir_document" id="edit_kir" 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-emerald-600">
</div>
</div>
<div class="pt-4 flex items-center justify-end space-x-3">
<button type="button" onclick="closeEditModal()" class="px-5 py-2.5 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">Batal</button>
<button type="submit" class="px-5 py-2.5 text-xs font-bold text-white bg-[#1b5e20] hover:bg-[#144919] rounded-xl transition shadow-sm cursor-pointer">Simpan Perubahan</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal Detail Unit Fisik -->
<div id="detailModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeDetailModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full border border-slate-200">
<div class="p-6">
<div class="flex items-center justify-between pb-3 border-b border-slate-100">
<div>
<span class="text-[10px] font-bold uppercase tracking-wider text-slate-400">DETAIL UNIT FISIK</span>
<h3 class="text-xl font-extrabold text-slate-900" id="detail_code">-</h3>
</div>
<button onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-lg"></i>
</button>
</div>
<div class="py-4 space-y-3 text-xs">
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Kategori Induk:</span>
<span class="font-bold text-slate-800">{{ $category->code }} - {{ $category->unit_category }}</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Merek & Tipe:</span>
<span class="font-semibold text-slate-800">{{ $category->brand_type }}</span>
</div>
@if($category->model_number)
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Nomor Model:</span>
<span class="font-mono font-medium text-slate-800">{{ $category->model_number }}</span>
</div>
@endif
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">No. Seri / Rangka:</span>
<span id="detail_serial_number" class="font-mono font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Nomor Polisi / Plat:</span>
<span id="detail_plate" class="font-mono font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Tahun Produksi:</span>
<span id="detail_year" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Status Operasi:</span>
<span id="detail_status" class="font-bold">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Odometer:</span>
<span id="detail_km" class="font-mono font-bold text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Lokasi Kerja:</span>
<span id="detail_location" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Dokumen SILO:</span>
<span id="detail_silo" class="font-medium text-slate-800">-</span>
</div>
<div class="flex justify-between py-1.5 border-b border-slate-50">
<span class="text-slate-400">Dokumen KIR:</span>
<span id="detail_kir" class="font-medium text-slate-800">-</span>
</div>
</div>
<div class="pt-3 border-t border-slate-100 flex justify-end">
<button onclick="closeDetailModal()" class="px-5 py-2 text-xs font-bold text-slate-700 bg-slate-100 hover:bg-slate-200 rounded-xl transition">Tutup</button>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Hapus Unit Fisik -->
<div id="deleteModal" class="fixed inset-0 z-50 hidden overflow-y-auto" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-xs" onclick="closeDeleteModal()"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full border border-slate-200">
<div class="p-6 text-center">
<div class="w-12 h-12 rounded-full bg-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4">
<i class="fa-solid fa-triangle-exclamation text-xl"></i>
</div>
<h3 class="text-lg font-bold text-slate-900 mb-2">Hapus Unit Fisik?</h3>
<p class="text-xs text-slate-500 mb-6">
Apakah Anda yakin ingin menghapus unit <span id="deleteUnitCode" class="font-mono font-bold text-slate-800"></span>? Data yang sudah dihapus tidak dapat dipulihkan.
</p>
<form id="deleteForm" method="POST" action="">
@csrf
@method('DELETE')
<div class="flex items-center justify-center space-x-3">
<button type="button" onclick="closeDeleteModal()" class="px-5 py-2 text-xs font-bold text-slate-700 bg-white border border-slate-300 rounded-xl hover:bg-slate-50 transition cursor-pointer">Batal</button>
<button type="submit" class="px-5 py-2 text-xs font-bold text-white bg-rose-600 hover:bg-rose-700 rounded-xl transition shadow-sm cursor-pointer">Ya, Hapus Unit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
const categoryCode = "{{ $category->code }}";
function openAddUnitModal() {
document.getElementById('addUnitModal').classList.remove('hidden');
document.getElementById('unitNumberInput').focus();
}
function closeAddUnitModal() {
document.getElementById('addUnitModal').classList.add('hidden');
}
// Live preview kode lengkap
document.getElementById('unitNumberInput')?.addEventListener('input', function(e) {
let val = e.target.value.trim();
if (val) {
document.getElementById('fullCodePreview').textContent = categoryCode + '-' + val;
} else {
document.getElementById('fullCodePreview').textContent = '-';
}
});
function openEditModal(unit) {
const form = document.getElementById('editUnitForm');
form.action = "{{ url('qma/vehicles') }}/" + unit.id;
document.getElementById('edit_code').value = unit.code;
document.getElementById('edit_brand_type').value = unit.brand_type || "{{ $category->brand_type }}";
document.getElementById('edit_serial_number').value = unit.serial_number || '';
document.getElementById('edit_license_plate').value = unit.license_plate || '';
document.getElementById('edit_production_year').value = unit.production_year || '';
document.getElementById('edit_status').value = unit.status || 'Operation';
document.getElementById('edit_current_km').value = unit.current_km || 0;
const locSelect = document.getElementById('edit_location');
if (locSelect) {
if (unit.location) {
let found = Array.from(locSelect.options).some(opt => opt.value === unit.location);
if (!found) {
const newOpt = document.createElement('option');
newOpt.value = unit.location;
newOpt.textContent = unit.location;
locSelect.appendChild(newOpt);
}
locSelect.value = unit.location;
} else {
locSelect.value = '';
}
}
document.getElementById('edit_silo').value = unit.silo_document || '';
document.getElementById('edit_kir').value = unit.kir_document || '';
document.getElementById('editModal').classList.remove('hidden');
}
function closeEditModal() {
document.getElementById('editModal').classList.add('hidden');
}
function openDetailModal(unit) {
document.getElementById('detail_code').textContent = unit.code;
document.getElementById('detail_serial_number').textContent = unit.serial_number || 'Tidak ada';
document.getElementById('detail_plate').textContent = unit.license_plate || 'Tidak ada';
document.getElementById('detail_year').textContent = unit.production_year || 'Tidak ada';
document.getElementById('detail_status').textContent = unit.status;
document.getElementById('detail_km').textContent = Number(unit.current_km).toLocaleString('id-ID') + ' HM/KM';
document.getElementById('detail_location').textContent = unit.location || '-';
document.getElementById('detail_silo').textContent = unit.silo_document || 'Tidak ada';
document.getElementById('detail_kir').textContent = unit.kir_document || 'Tidak ada';
document.getElementById('detailModal').classList.remove('hidden');
}
function closeDetailModal() {
document.getElementById('detailModal').classList.add('hidden');
}
function openDeleteModal(id, code) {
const form = document.getElementById('deleteForm');
form.action = "{{ url('qma/vehicles') }}/" + id;
document.getElementById('deleteUnitCode').textContent = code;
document.getElementById('deleteModal').classList.remove('hidden');
}
function closeDeleteModal() {
document.getElementById('deleteModal').classList.add('hidden');
}
// =========================================================================
// REAL-TIME CLIENT-SIDE SEARCH WITH MULTI-FIELD MATCHING & EMPTY STATE
// =========================================================================
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('unitSearchInput');
const tableBody = document.getElementById('unitsTableBody');
const resetWrapper = document.getElementById('unitResetWrapper');
const paginationContainer = document.getElementById('unitsPaginationContainer');
const serverEmptyRow = document.getElementById('serverUnitEmptyRow');
const hasServerFilters = {{ request()->anyFilled(['status']) ? 'true' : 'false' }};
if (searchInput && tableBody) {
searchInput.addEventListener('input', function (e) {
const rawValue = e.target.value;
const query = rawValue.toLowerCase().trim();
const rows = tableBody.querySelectorAll('tr.unit-row');
let visibleCount = 0;
rows.forEach(row => {
const text = row.textContent.toLowerCase();
if (text.includes(query)) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
if (paginationContainer) {
paginationContainer.style.display = query.length > 0 ? 'none' : '';
}
const existingEmptyRow = document.getElementById('clientUnitEmptyRow');
if (existingEmptyRow) existingEmptyRow.remove();
if (serverEmptyRow) {
serverEmptyRow.style.display = query.length > 0 ? 'none' : '';
}
if (visibleCount === 0 && query.length > 0) {
const emptyTr = document.createElement('tr');
emptyTr.id = 'clientUnitEmptyRow';
emptyTr.innerHTML = `
<td colspan="10" class="py-12 text-center text-slate-400">
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
<p class="text-sm font-semibold text-slate-700">
Data "<span class="text-rose-600 font-bold">${escapeHtml(rawValue)}</span>" tidak ditemukan di tabel
</p>
<p class="text-xs text-slate-400 mt-1">
Pastikan kata kunci yang dicari sudah benar.
</p>
<div class="mt-4">
<button type="button"
onclick="const inp = document.getElementById('unitSearchInput'); if(inp){ inp.value=''; inp.dispatchEvent(new Event('input')); inp.focus(); }"
class="inline-flex items-center space-x-1.5 px-3.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition cursor-pointer">
<i class="fa-solid fa-rotate-left text-[11px]"></i>
<span>Hapus Pencarian</span>
</button>
</div>
</td>
`;
tableBody.appendChild(emptyTr);
}
if (resetWrapper) {
let resetBtn = document.getElementById('unitResetBtn');
if (query.length > 0 || hasServerFilters) {
if (!resetBtn) {
resetBtn = document.createElement('a');
resetBtn.id = 'unitResetBtn';
resetBtn.href = "{{ route('qma.vehicles.support.units', $category->id) }}";
resetBtn.className = 'text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1';
resetBtn.innerHTML = '<i class="fa-solid fa-rotate-left text-[11px]"></i><span>Reset Filter</span>';
resetWrapper.appendChild(resetBtn);
}
} else if (!hasServerFilters && resetBtn) {
resetBtn.remove();
}
}
});
// Trigger saat awal memuat halaman jika ada nilai pencarian dari SSR
if (searchInput.value.trim() !== '') {
searchInput.dispatchEvent(new Event('input'));
}
}
});
</script>
@endsection
@@ -0,0 +1,39 @@
@extends('layouts.app')
@section('title', 'Dashboard Admin - Super Admin | PT Kerinci Merangin Hidro')
@section('content')
<div class="w-full space-y-6">
<!-- Header Judul Halaman -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
Dashboard Admin
</h2>
<p class="text-xs sm:text-sm text-slate-500 mt-1">
Pusat ikhtisar operasional dan analitik sistem terintegrasi PT Kerinci Merangin Hidro.
</p>
</div>
</div>
<!-- Konten Dashboard Kosong (Placeholder Persiapan Awal) -->
<div class="bg-white rounded-2xl border border-slate-200/80 p-12 sm:p-16 text-center shadow-xs">
<div class="w-16 h-16 mx-auto rounded-2xl bg-slate-100 text-slate-400 flex items-center justify-center text-2xl mb-4">
<i class="fa-solid fa-chart-pie"></i>
</div>
<h3 class="text-base sm:text-lg font-bold text-slate-800">
Halaman Dashboard Sedang Disiapkan
</h3>
<p class="text-xs sm:text-sm text-slate-400 max-w-md mx-auto mt-1 mb-6">
Komponen analitik, grafik metrik aktivitas, dan rekapitulasi data sistem saat ini masih dalam tahap perancangan awal.
</p>
<a href="{{ route('superadmin.roles.index') }}"
class="inline-flex items-center space-x-2 px-4 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white text-xs font-bold transition shadow-sm">
<i class="fa-solid fa-users-gear text-xs"></i>
<span>Buka Manajemen Role</span>
</a>
</div>
</div>
@endsection
File diff suppressed because it is too large Load Diff
+48 -3
View File
@@ -3,6 +3,7 @@
use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\HomeController; use App\Http\Controllers\HomeController;
use App\Http\Controllers\Hse\EmployeeController; use App\Http\Controllers\Hse\EmployeeController;
use App\Http\Controllers\P2h\P2hFormController;
use App\Http\Controllers\Pg\DashboardController as PgDashboardController; use App\Http\Controllers\Pg\DashboardController as PgDashboardController;
use App\Http\Controllers\Pg\GateInspectionController; use App\Http\Controllers\Pg\GateInspectionController;
use App\Http\Controllers\Pg\SecurityGuardController; use App\Http\Controllers\Pg\SecurityGuardController;
@@ -10,7 +11,11 @@ use App\Http\Controllers\Pg\VerificationLogController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\Public\VehicleActivityFormController; use App\Http\Controllers\Public\VehicleActivityFormController;
use App\Http\Controllers\Qma\ActivityLogController; use App\Http\Controllers\Qma\ActivityLogController;
use App\Http\Controllers\Qma\P2hInspectionController;
use App\Http\Controllers\Qma\P2hTemplateController;
use App\Http\Controllers\Qma\VehicleController; use App\Http\Controllers\Qma\VehicleController;
use App\Http\Controllers\SuperAdmin\DashboardController as SuperAdminDashboardController;
use App\Http\Controllers\SuperAdmin\UserController as SuperAdminUserController;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@@ -20,7 +25,7 @@ Route::get('/', [HomeController::class, 'index'])->name('home');
// Autentikasi Pengguna (Login & Logout) // Autentikasi Pengguna (Login & Logout)
Route::middleware('guest')->group(function () { Route::middleware('guest')->group(function () {
Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login'); Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/login', [LoginController::class, 'login'])->name('login.post'); Route::post('/login', [LoginController::class, 'login'])->middleware('throttle:10,1')->name('login.post');
}); });
Route::post('/logout', [LoginController::class, 'logout'])->name('logout')->middleware('auth'); Route::post('/logout', [LoginController::class, 'logout'])->name('logout')->middleware('auth');
@@ -28,13 +33,24 @@ Route::post('/logout', [LoginController::class, 'logout'])->name('logout')->midd
// 1. Modul Publik: Pencatatan Aktivitas Kendaraan Ringan (Via Scan QR Code Mobil Unit di Lapangan) // 1. Modul Publik: Pencatatan Aktivitas Kendaraan Ringan (Via Scan QR Code Mobil Unit di Lapangan)
Route::prefix('gate-activity')->name('vehicle.activity.')->group(function () { Route::prefix('gate-activity')->name('vehicle.activity.')->group(function () {
Route::get('/{code}', [VehicleActivityFormController::class, 'show'])->name('form'); Route::get('/{code}', [VehicleActivityFormController::class, 'show'])->name('form');
Route::post('/{code}/check-nik', [VehicleActivityFormController::class, 'checkNik'])->name('check.nik'); Route::post('/{code}/check-nik', [VehicleActivityFormController::class, 'checkNik'])->middleware('throttle:60,1')->name('check.nik');
Route::post('/{code}', [VehicleActivityFormController::class, 'store'])->name('store'); Route::post('/{code}', [VehicleActivityFormController::class, 'store'])->name('store');
}); });
// Group Terproteksi Autentikasi Sistem // Group Terproteksi Autentikasi Sistem
Route::middleware('auth')->group(function () { Route::middleware('auth')->group(function () {
// 1. Modul Super Admin (Kategori Khusus Admin: Dashboard & Manajemen Role)
Route::prefix('superadmin')->name('superadmin.')->middleware('role:super_admin')->group(function () {
Route::get('/', [SuperAdminDashboardController::class, 'index']);
Route::get('/dashboard', [SuperAdminDashboardController::class, 'index'])->name('dashboard');
Route::get('/roles', [SuperAdminUserController::class, 'index'])->name('roles.index');
Route::post('/users', [SuperAdminUserController::class, 'store'])->name('users.store');
Route::put('/users/{id}', [SuperAdminUserController::class, 'update'])->name('users.update');
Route::post('/users/{id}/reset-password', [SuperAdminUserController::class, 'resetPassword'])->name('users.reset-password');
Route::delete('/users/{id}', [SuperAdminUserController::class, 'destroy'])->name('users.destroy');
});
// 2. Modul HSE: Admin HSE (Mima - 1185) - Kelola Karyawan & SIMPER // 2. Modul HSE: Admin HSE (Mima - 1185) - Kelola Karyawan & SIMPER
Route::prefix('hse')->name('hse.')->middleware('role:hse_admin')->group(function () { Route::prefix('hse')->name('hse.')->middleware('role:hse_admin')->group(function () {
Route::get('/dashboard', [EmployeeController::class, 'dashboard'])->name('dashboard'); Route::get('/dashboard', [EmployeeController::class, 'dashboard'])->name('dashboard');
@@ -51,12 +67,29 @@ Route::middleware('auth')->group(function () {
Route::get('/vehicles', [VehicleController::class, 'index'])->name('vehicles.index'); Route::get('/vehicles', [VehicleController::class, 'index'])->name('vehicles.index');
Route::get('/vehicles/light-vehicle', [VehicleController::class, 'indexLv'])->name('vehicles.lv'); Route::get('/vehicles/light-vehicle', [VehicleController::class, 'indexLv'])->name('vehicles.lv');
Route::get('/vehicles/unit-support', [VehicleController::class, 'indexSupport'])->name('vehicles.support'); Route::get('/vehicles/unit-support', [VehicleController::class, 'indexSupport'])->name('vehicles.support');
Route::get('/vehicles/unit-support/{id}/units', [VehicleController::class, 'indexSupportUnits'])->name('vehicles.support.units');
Route::post('/vehicles/unit-support/{id}/units', [VehicleController::class, 'storeSupportUnit'])->name('vehicles.support.units.store');
Route::post('/vehicles', [VehicleController::class, 'store'])->name('vehicles.store'); Route::post('/vehicles', [VehicleController::class, 'store'])->name('vehicles.store');
Route::post('/vehicles/{id}', [VehicleController::class, 'update'])->name('vehicles.update'); Route::post('/vehicles/{id}', [VehicleController::class, 'update'])->name('vehicles.update');
Route::delete('/vehicles/{id}', [VehicleController::class, 'destroy'])->name('vehicles.destroy'); Route::delete('/vehicles/{id}', [VehicleController::class, 'destroy'])->name('vehicles.destroy');
Route::get('/activity-log', [ActivityLogController::class, 'index'])->name('activity.log'); Route::get('/activity-log', [ActivityLogController::class, 'index'])->name('activity.log');
Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary'); Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary');
// Log Pemeriksaan P2H Unit Support & Approval Admin QMA
Route::get('/p2h-records', [P2hInspectionController::class, 'index'])->name('p2h.index');
Route::get('/p2h-summary', [P2hInspectionController::class, 'summary'])->name('p2h.summary');
Route::get('/p2h-records/{id}', [P2hInspectionController::class, 'show'])->name('p2h.show');
Route::post('/p2h-records/{id}/approve', [P2hInspectionController::class, 'approve'])->name('p2h.approve');
Route::post('/p2h-records/{id}/reject', [P2hInspectionController::class, 'reject'])->name('p2h.reject');
// Master 28 Template Checksheet P2H & Kelola Pertanyaan
Route::get('/p2h-templates', [P2hTemplateController::class, 'index'])->name('p2h.templates');
Route::get('/p2h-templates/{id}', [P2hTemplateController::class, 'show'])->name('p2h.templates.show');
Route::post('/p2h-templates/{templateId}/items', [P2hTemplateController::class, 'storeItem'])->name('p2h.templates.items.store');
Route::match(['PUT', 'POST'], '/p2h-templates/{templateId}/items/{itemId}', [P2hTemplateController::class, 'updateItem'])->name('p2h.templates.items.update');
Route::delete('/p2h-templates/{templateId}/items/{itemId}', [P2hTemplateController::class, 'destroyItem'])->name('p2h.templates.items.destroy');
Route::post('/p2h-templates/{templateId}/sections/reorder', [P2hTemplateController::class, 'reorderSections'])->name('p2h.templates.sections.reorder');
}); });
// 4. Modul Private Guard (PG): Admin PG & Pos Gerbang Satpam // 4. Modul Private Guard (PG): Admin PG & Pos Gerbang Satpam
@@ -81,7 +114,19 @@ Route::middleware('auth')->group(function () {
}); });
}); });
// 5. Modul Profil Saya (Seluruh Pengguna Terautentikasi) // 5. Modul Pengisian Form P2H Unit Support (Operator Wajib Login)
Route::prefix('p2h')->name('p2h.')->group(function () {
Route::get('/', [P2hFormController::class, 'index'])->name('index');
Route::get('/{code}', [P2hFormController::class, 'show'])->name('form');
Route::post('/{code}', [P2hFormController::class, 'store'])->name('store');
});
// 6. Modul Karyawan (Dashboard, P2H, Timesheet)
Route::get('/karyawan/dashboard', [\App\Http\Controllers\Employee\DashboardController::class, 'index'])->name('employee.dashboard');
Route::get('/timesheet', [VehicleActivityFormController::class, 'index'])->name('timesheet.index');
Route::get('/mobilisasi', [VehicleActivityFormController::class, 'index'])->name('mobilisasi.index');
// 7. Modul Profil Saya (Seluruh Pengguna Terautentikasi)
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index'); Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update'); Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
}); });
+21 -8
View File
@@ -140,30 +140,43 @@ class AuthenticationTest extends TestCase
} }
/** /**
* Memastikan Admin HSE dapat mengedit data karyawan & SIMPER. * Memastikan Admin HSE hanya mengelola status driver & SIMPER tanpa mengubah master profil karyawan.
*/ */
public function test_admin_hse_can_edit_employee_simper_data(): void public function test_admin_hse_can_edit_employee_simper_data(): void
{ {
$hseUser = User::where('username', '1185')->first(); $hseUser = User::where('username', '1185')->first();
$employee = \App\Models\Employee::first(); $employee = \App\Models\Employee::first();
$originalName = $employee->name;
$originalPosition = $employee->position;
$response = $this->actingAs($hseUser)->post("/hse/employees/{$employee->id}", [ $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', 'is_operator' => '1',
'simper_expired_at' => '2028-12-31', 'simper_expired_at' => '2028-12-31',
]); ]);
$response->assertSessionHas('success'); $response->assertSessionHas('success');
$employee->refresh(); $employee->refresh();
$this->assertEquals('Nama Karyawan Diperbarui', $employee->name); $this->assertEquals($originalName, $employee->name);
$this->assertEquals('Senior Technician', $employee->position); $this->assertEquals($originalPosition, $employee->position);
$this->assertTrue((bool) $employee->is_operator);
$this->assertEquals('2028-12-31', $employee->simper_expired_at->format('Y-m-d')); $this->assertEquals('2028-12-31', $employee->simper_expired_at->format('Y-m-d'));
} }
/**
* Memastikan Admin HSE tidak dapat menambahkan master karyawan baru (dialihkan ke Super Admin).
*/
public function test_admin_hse_cannot_create_master_employee(): void
{
$hseUser = User::where('username', '1185')->first();
$response = $this->actingAs($hseUser)->post('/hse/employees', [
'nik' => '9999',
'name' => 'Karyawan Baru',
]);
$response->assertSessionHas('error');
}
/** /**
* Memastikan jika bukan driver maka tanggal SIMPER otomatis bernilai null. * Memastikan jika bukan driver maka tanggal SIMPER otomatis bernilai null.
*/ */
+696
View File
@@ -0,0 +1,696 @@
<?php
namespace Tests\Feature;
use App\Models\Employee;
use App\Models\P2hRecord;
use App\Models\P2hTemplate;
use App\Models\User;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class P2hInspectionTest extends TestCase
{
use RefreshDatabase;
protected User $qmaAdmin;
protected User $operatorUser;
protected Employee $operatorEmp;
protected Vehicle $supportVehicle;
protected P2hTemplate $template;
protected function setUp(): void
{
parent::setUp();
// 1. Akun Admin QMA
$this->qmaAdmin = User::firstOrCreate(
['username' => '1171'],
[
'name' => 'Pinto Yuliandra',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'qma_admin',
]
);
// 2. Akun Operator Karyawan dengan SIMPER Aktif
$this->operatorUser = User::firstOrCreate(
['username' => 'OPR-001'],
[
'name' => 'Bambang Operator',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'employee',
]
);
$this->operatorEmp = Employee::firstOrCreate(
['nik' => 'OPR-001'],
[
'user_id' => $this->operatorUser->id,
'name' => 'Bambang Operator',
'unit_kerja' => 'Pembangkit',
'division' => 'Operasional',
'position' => 'Operator Excavator',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(6),
]
);
// 3. Template & Unit Support
$this->template = P2hTemplate::firstOrCreate(
['code' => 'EXD4RP'],
[
'name' => 'Excavator',
'file_name' => 'P2H_Excavator_EXD4RP.md',
'is_active' => true,
]
);
$this->supportVehicle = Vehicle::firstOrCreate(
['code' => 'EX99'],
[
'category' => 'unit_support',
'p2h_template_id' => $this->template->id,
'brand_type' => 'KOMATSU PC200 TEST',
'unit_category' => 'Excavator',
'status' => 'Operation',
'current_km' => 1500.0,
]
);
}
public function test_guest_cannot_access_p2h_catalog(): void
{
$response = $this->get(route('p2h.index'));
$response->assertRedirect(route('login'));
}
public function test_authenticated_operator_can_view_p2h_catalog(): void
{
$response = $this->actingAs($this->operatorUser)->get(route('p2h.index'));
$response->assertStatus(200);
$response->assertSee('Katalog Pemeriksaan Pra-Harian (P2H)');
$response->assertSee($this->supportVehicle->code);
}
public function test_all_28_p2h_categories_are_seeded_and_displayed(): void
{
$this->seed(\Database\Seeders\P2hTemplateSeeder::class);
$this->assertEquals(28, P2hTemplate::count());
$this->assertGreaterThanOrEqual(28, Vehicle::where('category', 'unit_support')->count());
$response = $this->actingAs($this->operatorUser)->get(route('p2h.index'));
$response->assertStatus(200);
$response->assertSee('Boomlift');
$response->assertSee('Excavator');
$response->assertSee('Dump Truck');
$response->assertSee('Wheel Loader');
$response->assertSee('Water Truck');
$response->assertSee('Vibro');
}
public function test_operator_can_open_p2h_form(): void
{
$response = $this->actingAs($this->operatorUser)->get(route('p2h.form', ['code' => $this->supportVehicle->code]));
$response->assertStatus(200);
$response->assertSee('Pemeriksaan Pra-Harian (P2H) Unit Support');
$response->assertSee($this->supportVehicle->code);
$response->assertSee('Bambang Operator');
$response->assertSee('SIMPER Aktif');
$response->assertDontSee('<aside', false);
$response->assertDontSee('userProfileDropdownBtn');
$response->assertDontSee('openDrawerBtn');
// Pastikan saat admin (seperti admin QMA) membuka form, sidebar dan topbar juga disembunyikan
$admin = User::where('role', 'qma_admin')->first();
$resAdmin = $this->actingAs($admin)->get(route('p2h.form', ['code' => $this->supportVehicle->code]));
$resAdmin->assertStatus(200);
$resAdmin->assertSee('Admin QMA (Validator / Verifikator)');
$resAdmin->assertSee('Buka Verifikasi');
$resAdmin->assertDontSee('<aside', false);
$resAdmin->assertDontSee('userProfileDropdownBtn');
$resAdmin->assertDontSee('openDrawerBtn');
}
public function test_qma_admin_cannot_submit_p2h(): void
{
$admin = User::where('role', 'qma_admin')->first();
$response = $this->actingAs($admin)->post(route('p2h.store', ['code' => $this->supportVehicle->code]), [
'template_id' => $this->template->id,
'start_hm' => 1500,
'items' => [],
]);
$response->assertSessionHas('error');
}
public function test_operator_can_submit_p2h_with_pending_status_for_qma(): void
{
// Pastikan ada beberapa item template
$item1 = $this->template->items()->create([
'section' => 'Sebelum Mesin Hidup',
'title' => 'Periksa Level & Kondisi Oli Engine',
'question_type' => 'choice',
'sequence' => 1,
]);
$item2 = $this->template->items()->create([
'section' => 'Sebelum Mesin Hidup',
'title' => 'Periksa Level Air Radiator',
'question_type' => 'choice',
'sequence' => 2,
]);
$payload = [
'template_id' => $this->template->id,
'shift' => 'Shift 1 (Siang)',
'start_hm' => 1520.5,
'general_notes' => 'Unit bersih siap bekerja di disposal.',
'items' => [
$item1->id => [
'condition' => 'baik',
],
$item2->id => [
'condition' => 'rusak',
'notes' => 'Air radiator sedikit bocor di sambungan klem',
],
],
];
$response = $this->actingAs($this->operatorUser)->post(
route('p2h.store', ['code' => $this->supportVehicle->code]),
$payload
);
$response->assertRedirect(route('p2h.form', ['code' => $this->supportVehicle->code]));
$response->assertSessionHas('success');
// Cek record P2H tersimpan dengan status 'pending'
$this->assertDatabaseHas('p2h_records', [
'vehicle_id' => $this->supportVehicle->id,
'employee_id' => $this->operatorEmp->id,
'shift' => 'Shift 1 (Siang)',
'start_hm' => 1520.5,
'summary_condition' => 'has_defect',
'defect_count' => 1,
'validation_status' => 'pending',
]);
// Cek HM kendaraan ter-update
$this->supportVehicle->refresh();
$this->assertEquals(1520.5, (float)$this->supportVehicle->current_km);
}
public function test_qma_admin_can_view_and_approve_p2h_record(): void
{
$record = P2hRecord::create([
'transaction_no' => 'P2H-TEST-001',
'vehicle_id' => $this->supportVehicle->id,
'employee_id' => $this->operatorEmp->id,
'template_id' => $this->template->id,
'shift' => 'Shift 1 (Siang)',
'start_hm' => 1530.0,
'summary_condition' => 'good',
'defect_count' => 0,
'validation_status' => 'pending',
'inspected_at' => Carbon::now(),
]);
// QMA melihat index
$resIndex = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.index'));
$resIndex->assertStatus(200);
$resIndex->assertSee('P2H-TEST-001');
// QMA melihat detail
$resShow = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.show', $record->id));
$resShow->assertStatus(200);
$resShow->assertSee('P2H-TEST-001');
// QMA menyetujui (Approve)
$resApprove = $this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.approve', $record->id),
['validation_notes' => 'P2H disetujui, unit laik operasi.']
);
$resApprove->assertSessionHas('success');
$record->refresh();
$this->assertEquals('approved', $record->validation_status);
$this->assertEquals($this->qmaAdmin->id, $record->validated_by);
}
public function test_qma_admin_can_reject_p2h_record(): void
{
$record = P2hRecord::create([
'transaction_no' => 'P2H-TEST-002',
'vehicle_id' => $this->supportVehicle->id,
'employee_id' => $this->operatorEmp->id,
'template_id' => $this->template->id,
'shift' => 'Shift 2 (Malam)',
'start_hm' => 1540.0,
'summary_condition' => 'has_defect',
'defect_count' => 2,
'validation_status' => 'pending',
'inspected_at' => Carbon::now(),
]);
// QMA menolak (Reject)
$resReject = $this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.reject', $record->id),
['validation_notes' => 'Unit dilarang beroperasi sebelum rem hidrolik diperbaiki mekanik.']
);
$resReject->assertSessionHas('success');
$record->refresh();
$this->assertEquals('rejected', $record->validation_status);
$this->assertEquals($this->qmaAdmin->id, $record->validated_by);
// Status unit otomatis menjadi Breakdown
$this->supportVehicle->refresh();
$this->assertEquals('Breakdown', $this->supportVehicle->status);
}
public function test_qma_admin_can_view_p2h_templates(): void
{
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates'));
$response->assertStatus(200);
$response->assertSee('Master Template P2H Unit Support');
$response->assertSee('Excavator');
$response->assertSee('EXD4RP');
}
public function test_adding_unit_support_category_automatically_creates_empty_p2h_template(): void
{
// 1. Admin QMA menambah kategori aset Unit Support baru
$storeResponse = $this->actingAs($this->qmaAdmin)->post('/qma/vehicles', [
'code' => 'TH01',
'category' => 'unit_support',
'brand_type' => 'Manitou MT-X 733',
'unit_category' => 'Telehandler',
'status' => 'Operation',
'current_km' => 0,
]);
$storeResponse->assertSessionHas('success');
// 2. Pastikan Kategori Aset terbuat dan terhubung ke template
$category = Vehicle::where('code', 'TH01')->first();
$this->assertNotNull($category);
$this->assertNotNull($category->p2h_template_id);
// 3. Pastikan Master Template P2H otomatis terbuat dengan default kosong (0 butir pertanyaan)
$template = P2hTemplate::where('code', 'TH01')->first();
$this->assertNotNull($template);
$this->assertEquals('Telehandler', $template->name);
$this->assertEquals(0, $template->items()->count());
$this->assertEquals($category->p2h_template_id, $template->id);
// 4. Halaman Master Template P2H menampilkan card template baru tersebut
$listResponse = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates'));
$listResponse->assertStatus(200);
$listResponse->assertSee('TH01');
$listResponse->assertSee('Telehandler');
$listResponse->assertSee('Template Baru (Kosong)');
$listResponse->assertSee('Kelola & Isi Pertanyaan');
// 5. Update kategori menyinkronkan kode template P2H
$updateResponse = $this->actingAs($this->qmaAdmin)->post('/qma/vehicles/' . $category->id, [
'code' => 'TH99',
'category' => 'unit_support',
'brand_type' => 'Manitou MT-X 733 Heavy Duty',
'unit_category' => 'Telehandler HD',
'status' => 'Operation',
'current_km' => 10,
]);
$updateResponse->assertSessionHas('success');
$this->assertDatabaseHas('p2h_templates', [
'id' => $template->id,
'code' => 'TH99',
'name' => 'Telehandler HD',
]);
// 6. Hapus kategori aset juga menghapus master template yang belum ada transaksi
$deleteResponse = $this->actingAs($this->qmaAdmin)->delete('/qma/vehicles/' . $category->id);
$deleteResponse->assertSessionHas('success');
$this->assertDatabaseMissing('p2h_templates', ['id' => $template->id]);
}
public function test_qma_admin_can_edit_p2h_template_question(): void
{
$item = \App\Models\P2hTemplateItem::create([
'template_id' => $this->template->id,
'section' => 'Pemeriksaan Keliling',
'title' => 'Level Oli Hidrolik',
'question_type' => 'condition',
'sequence' => 1,
]);
// Akses halaman detail template
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates.show', $this->template->id));
$response->assertStatus(200);
$response->assertSee('Edit');
$response->assertSee('Tambah Pertanyaan');
$response->assertSee($item->title);
// Edit butir pertanyaan
$editResponse = $this->actingAs($this->qmaAdmin)->put(
route('qma.p2h.templates.items.update', ['templateId' => $this->template->id, 'itemId' => $item->id]),
[
'title' => 'Level Oli Hidrolik dan Kebocoran Selang (Diperbarui)',
'section' => 'Sistem Hidrolik',
'question_type' => 'Multiple choice: only one answer',
'sequence' => 1,
]
);
$editResponse->assertRedirect(route('qma.p2h.templates.show', $this->template->id));
$editResponse->assertSessionHas('success');
$this->assertDatabaseHas('p2h_template_items', [
'id' => $item->id,
'title' => 'Level Oli Hidrolik dan Kebocoran Selang (Diperbarui)',
'section' => 'Sistem Hidrolik',
'question_type' => 'Multiple choice: only one answer',
]);
}
public function test_qma_admin_can_view_two_column_section_layout_for_p2h_template_questions(): void
{
$this->template->items()->delete();
$this->template->items()->createMany([
[
'section' => 'START',
'title' => 'Start Engine',
'question_type' => 'Datetime',
'sequence' => 1,
],
[
'section' => 'START',
'title' => 'Shift Operator',
'question_type' => 'Multiple choice: only one answer',
'sequence' => 2,
],
[
'section' => 'ATTACHMENT',
'title' => 'Basket / Keranjang (enginee)',
'question_type' => 'Multiple choice: only one answer',
'sequence' => 3,
],
]);
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates.show', $this->template->id));
$response->assertStatus(200);
$response->assertSee('sectionsContainer');
$response->assertSee('section-card');
$response->assertSee('section-content');
$response->assertSee('START');
$response->assertSee('ATTACHMENT');
$response->assertSee('2 Pertanyaan');
$response->assertSee('1 Pertanyaan');
$response->assertSee('Basket / Keranjang (enginee)');
$response->assertSee('addItemSectionContainer');
$response->assertSee('addItemSectionBadge');
}
public function test_authenticated_operator_can_view_dashboard_p2h_and_timesheet_menus(): void
{
// Pastikan ada kendaraan ringan
Vehicle::firstOrCreate(
['code' => 'LV99'],
[
'brand_type' => 'Toyota Hilux Double Cabin',
'license_plate' => 'BH 9999 KM',
'category' => 'light_vehicle',
'current_km' => 5400,
'ownership' => 'Operasional Site',
'status' => 'Operation',
]
);
// 1. Login redirect ke dashboard karyawan
$resLogin = $this->post('/login', [
'username' => 'OPR-001',
'password' => 'password',
]);
$resLogin->assertRedirect(route('employee.dashboard'));
// 2. Halaman Dashboard Karyawan menampilkan 2 card fitur utama
$resDashboard = $this->actingAs($this->operatorUser)->get(route('employee.dashboard'));
$resDashboard->assertStatus(200);
$resDashboard->assertSee('Dashboard Karyawan');
$resDashboard->assertSee('Buka Modul Pemeriksaan P2H');
$resDashboard->assertSee('Buka Modul Timesheet LV');
$resDashboard->assertSee('Pemeriksaan P2H');
$resDashboard->assertSee('Timesheet');
// 3. Sidebar di halaman P2H memuat menu Dashboard, Pemeriksaan P2H, dan Timesheet
$resCatalog = $this->actingAs($this->operatorUser)->get(route('p2h.index'));
$resCatalog->assertStatus(200);
$resCatalog->assertSee('Dashboard');
$resCatalog->assertSee('Pemeriksaan P2H');
$resCatalog->assertSee('Timesheet');
$resCatalog->assertSee(route('employee.dashboard'));
$resCatalog->assertSee(route('p2h.index'));
$resCatalog->assertSee(route('timesheet.index'));
// 4. Akses langsung halaman Timesheet
$resTimesheet = $this->actingAs($this->operatorUser)->get(route('timesheet.index'));
$resTimesheet->assertStatus(200);
$resTimesheet->assertSee('Timesheet Kendaraan Ringan');
$resTimesheet->assertSee('LV99');
$resTimesheet->assertSee('BH 9999 KM');
$resTimesheet->assertSee('Isi Form Mobilisasi LV');
}
public function test_qma_admin_can_add_section_with_multiple_questions_and_types_attached(): void
{
$response = $this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.items.store', $this->template->id),
[
'section' => 'Pemeriksaan Ruang Kemudi (Cabin)',
'questions' => [
[
'title' => 'Kondisi kaca spion kanan & kiri',
'question_type' => 'Multiple choice: only one answer',
],
[
'title' => 'Catatan kelainan instrumen dashboard',
'question_type' => 'Multiple Lines Text Box',
],
[
'title' => 'Jumlah sabuk pengaman yang terpasang baik',
'question_type' => 'Numerical Value',
],
],
]
);
$response->assertRedirect(route('qma.p2h.templates.show', $this->template->id));
$response->assertSessionHas('success');
$this->assertDatabaseHas('p2h_template_items', [
'template_id' => $this->template->id,
'section' => 'Pemeriksaan Ruang Kemudi (Cabin)',
'title' => 'Kondisi kaca spion kanan & kiri',
'question_type' => 'Multiple choice: only one answer',
'sequence' => 1,
]);
$this->assertDatabaseHas('p2h_template_items', [
'template_id' => $this->template->id,
'section' => 'Pemeriksaan Ruang Kemudi (Cabin)',
'title' => 'Catatan kelainan instrumen dashboard',
'question_type' => 'Multiple Lines Text Box',
'sequence' => 2,
]);
$this->assertDatabaseHas('p2h_template_items', [
'template_id' => $this->template->id,
'section' => 'Pemeriksaan Ruang Kemudi (Cabin)',
'title' => 'Jumlah sabuk pengaman yang terpasang baik',
'question_type' => 'Numerical Value',
'sequence' => 3,
]);
}
public function test_qma_admin_template_detail_renders_add_section_modal(): void
{
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates.show', $this->template->id));
$response->assertStatus(200);
$response->assertSee('id="addSectionModal"', false);
$response->assertSee('id="sectionQuestionsList"', false);
$response->assertSee('openAddSectionModal', false);
$response->assertSee('closeAddSectionModal', false);
$response->assertSee('addQuestionToSection', false);
$response->assertSee('removeQuestionFromSection', false);
}
public function test_qma_admin_can_add_section_before_target_section(): void
{
// 1. Buat Section A (sequence 1, 2) dan Section C (sequence 3, 4)
$this->template->items()->createMany([
['section' => 'Section A', 'title' => 'Pertanyaan A1', 'question_type' => 'choice', 'sequence' => 1],
['section' => 'Section A', 'title' => 'Pertanyaan A2', 'question_type' => 'choice', 'sequence' => 2],
['section' => 'Section C', 'title' => 'Pertanyaan C1', 'question_type' => 'choice', 'sequence' => 3],
['section' => 'Section C', 'title' => 'Pertanyaan C2', 'question_type' => 'choice', 'sequence' => 4],
]);
// 2. Tambah Section B dengan posisi 'before' Section C
$response = $this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.items.store', $this->template->id),
[
'section' => 'Section B',
'position_type' => 'before',
'target_section' => 'Section C',
'questions' => [
[
'title' => 'Pertanyaan B1',
'question_type' => 'choice',
],
],
]
);
$response->assertRedirect(route('qma.p2h.templates.show', $this->template->id));
$response->assertSessionHas('success');
// Sequence Section B harus berada sebelum Section C
$itemB = $this->template->items()->where('section', 'Section B')->first();
$itemC1 = $this->template->items()->where('title', 'Pertanyaan C1')->first();
$this->assertNotNull($itemB);
$this->assertLessThan($itemC1->sequence, $itemB->sequence);
$this->assertEquals(3, $itemB->sequence);
// Dan sequence C1 tergeser menjadi 4
$this->assertEquals(4, $itemC1->sequence);
}
public function test_qma_admin_can_reorder_sections(): void
{
// 1. Buat 3 Section: Section 1 (seq 1,2), Section 2 (seq 3,4), Section 3 (seq 5,6)
$this->template->items()->createMany([
['section' => 'Section 1', 'title' => 'Pertanyaan 1A', 'question_type' => 'choice', 'sequence' => 1],
['section' => 'Section 1', 'title' => 'Pertanyaan 1B', 'question_type' => 'choice', 'sequence' => 2],
['section' => 'Section 2', 'title' => 'Pertanyaan 2A', 'question_type' => 'choice', 'sequence' => 3],
['section' => 'Section 2', 'title' => 'Pertanyaan 2B', 'question_type' => 'choice', 'sequence' => 4],
['section' => 'Section 3', 'title' => 'Pertanyaan 3A', 'question_type' => 'choice', 'sequence' => 5],
['section' => 'Section 3', 'title' => 'Pertanyaan 3B', 'question_type' => 'choice', 'sequence' => 6],
]);
// 2. Reorder menjadi: Section 3, Section 1, Section 2
$response = $this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.sections.reorder', $this->template->id),
[
'sections' => ['Section 3', 'Section 1', 'Section 2'],
]
);
$response->assertRedirect();
$response->assertSessionHas('success');
// Refresh template items urut sequence
$items = $this->template->items()->orderBy('sequence')->get();
// 2 item pertama harus Section 3
$this->assertEquals('Section 3', $items[0]->section);
$this->assertEquals(1, $items[0]->sequence);
$this->assertEquals('Section 3', $items[1]->section);
$this->assertEquals(2, $items[1]->sequence);
// 2 item berikutnya harus Section 1
$this->assertEquals('Section 1', $items[2]->section);
$this->assertEquals(3, $items[2]->sequence);
$this->assertEquals('Section 1', $items[3]->section);
$this->assertEquals(4, $items[3]->sequence);
// 2 item terakhir harus Section 2
$this->assertEquals('Section 2', $items[4]->section);
$this->assertEquals(5, $items[4]->sequence);
$this->assertEquals('Section 2', $items[5]->section);
$this->assertEquals(6, $items[5]->sequence);
}
public function test_qma_admin_template_detail_renders_reorder_sections_modal_and_controls(): void
{
$this->template->items()->createMany([
['section' => 'Section A', 'title' => 'Tanya A', 'question_type' => 'choice', 'sequence' => 1],
['section' => 'Section B', 'title' => 'Tanya B', 'question_type' => 'choice', 'sequence' => 2],
]);
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.p2h.templates.show', $this->template->id));
$response->assertStatus(200);
$response->assertSee('id="reorderSectionsModal"', false);
$response->assertSee('openReorderSectionsModal', false);
$response->assertSee('closeReorderSectionsModal', false);
$response->assertSee('moveSectionItemUp', false);
$response->assertSee('moveSectionItemDown', false);
$response->assertSee('Atur Urutan Section');
}
public function test_questions_are_automatically_and_contiguously_numbered_across_all_sections(): void
{
// 1. Buat Bagian Satu (2 pertanyaan) dan Bagian Dua (2 pertanyaan)
$this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.items.store', $this->template->id),
[
'section' => 'Bagian Satu',
'questions' => [
['title' => 'Pertanyaan 1.1', 'question_type' => 'choice'],
['title' => 'Pertanyaan 1.2', 'question_type' => 'choice'],
],
]
);
$this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.items.store', $this->template->id),
[
'section' => 'Bagian Dua',
'questions' => [
['title' => 'Pertanyaan 2.1', 'question_type' => 'choice'],
['title' => 'Pertanyaan 2.2', 'question_type' => 'choice'],
],
]
);
// Pertanyaan harus berurutan 1, 2 di Bagian Satu, dan 3, 4 di Bagian Dua
$items = $this->template->items()->orderBy('sequence')->get();
$this->assertCount(4, $items);
$this->assertEquals(['Pertanyaan 1.1', 'Pertanyaan 1.2', 'Pertanyaan 2.1', 'Pertanyaan 2.2'], $items->pluck('title')->all());
$this->assertEquals([1, 2, 3, 4], $items->pluck('sequence')->all());
// 2. Tambah satu pertanyaan baru ke Bagian Satu melalui form butir tunggal
$this->actingAs($this->qmaAdmin)->post(
route('qma.p2h.templates.items.store', $this->template->id),
[
'section' => 'Bagian Satu',
'title' => 'Pertanyaan 1.3 Baru',
'question_type' => 'choice',
]
);
// Pertanyaan baru harus berada di akhir Bagian Satu (nomor 3), dan Bagian Dua bergeser menjadi 4, 5
$itemsAfter = $this->template->items()->orderBy('sequence')->get();
$this->assertCount(5, $itemsAfter);
$this->assertEquals(['Pertanyaan 1.1', 'Pertanyaan 1.2', 'Pertanyaan 1.3 Baru', 'Pertanyaan 2.1', 'Pertanyaan 2.2'], $itemsAfter->pluck('title')->all());
$this->assertEquals([1, 2, 3, 4, 5], $itemsAfter->pluck('sequence')->all());
// 3. Hapus item kedua (Pertanyaan 1.2)
$itemToDelete = $itemsAfter->firstWhere('title', 'Pertanyaan 1.2');
$this->actingAs($this->qmaAdmin)->delete(
route('qma.p2h.templates.items.destroy', ['templateId' => $this->template->id, 'itemId' => $itemToDelete->id])
);
// Seluruh pertanyaan otomatis ternormalisasi kembali tanpa celah: 1, 2, 3, 4
$itemsAfterDelete = $this->template->items()->orderBy('sequence')->get();
$this->assertCount(4, $itemsAfterDelete);
$this->assertEquals([1, 2, 3, 4], $itemsAfterDelete->pluck('sequence')->all());
}
}
+362
View File
@@ -0,0 +1,362 @@
<?php
namespace Tests\Feature;
use App\Models\Gate;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class SuperAdminTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed();
}
/**
* Memastikan Super Admin dapat login dan diarahkan langsung ke dashboard Super Admin.
*/
public function test_super_admin_can_login_and_redirects_to_superadmin_dashboard(): void
{
$response = $this->post('/login', [
'username' => 'superadmin',
'password' => 'password',
]);
$response->assertRedirect('/superadmin/dashboard');
$this->assertAuthenticated();
$user = auth()->user();
$this->assertEquals('superadmin', $user->username);
$this->assertEquals('super_admin', $user->role);
$this->assertTrue($user->isSuperAdmin());
}
/**
* Memastikan user non-super-admin ditolak saat mengakses rute /superadmin.
*/
public function test_non_super_admin_cannot_access_superadmin_dashboard(): void
{
$hseUser = User::where('role', 'hse_admin')->first();
$response = $this->actingAs($hseUser)->get('/superadmin');
$response->assertStatus(403);
}
/**
* Memastikan Super Admin dapat melihat halaman dashboard admin kosong (placeholder awal).
*/
public function test_super_admin_can_view_admin_dashboard(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$response = $this->actingAs($superAdmin)->get('/superadmin/dashboard');
$response->assertStatus(200);
$response->assertSee('Dashboard Admin');
$response->assertSee('Halaman Dashboard Sedang Disiapkan');
$response->assertSee('Buka Manajemen Role');
}
/**
* Memastikan Super Admin dapat melihat halaman manajemen role & hak akses.
*/
public function test_super_admin_can_view_role_management_page(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$response = $this->actingAs($superAdmin)->get('/superadmin/roles');
$response->assertStatus(200);
$response->assertSee('Manajemen Role');
$response->assertSee('Hak Akses');
$response->assertSee('Tambah Akun Baru');
$response->assertSee('openDetailUserModal');
$response->assertSee('detailUserModal');
$response->assertSee('Detail Akun');
$response->assertDontSee('HIRARKI TERTINGGI SISTEM');
$response->assertDontSee('Pintasan Modul Langsung');
}
/**
* Memastikan Super Admin dapat mengakses seluruh modul departemen (HSE, QMA, PG, Gate).
*/
public function test_super_admin_has_full_access_to_all_modules(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
// 1. Modul HSE
$this->actingAs($superAdmin)->get('/hse/dashboard')->assertStatus(200);
$this->actingAs($superAdmin)->get('/hse/employees')->assertStatus(200);
// 2. Modul QMA
$this->actingAs($superAdmin)->get('/qma/dashboard')->assertStatus(200);
$this->actingAs($superAdmin)->get('/qma/vehicles/light-vehicle')->assertStatus(200);
$this->actingAs($superAdmin)->get('/qma/activity-log')->assertStatus(200);
// 3. Modul PG
$this->actingAs($superAdmin)->get('/pg/dashboard')->assertStatus(200);
$this->actingAs($superAdmin)->get('/pg/guards')->assertStatus(200);
$this->actingAs($superAdmin)->get('/pg/verification-logs')->assertStatus(200);
// 4. Modul Pos Gerbang
$this->actingAs($superAdmin)->get('/pg/gate-inspection')->assertStatus(200);
}
/**
* Memastikan Super Admin dapat membuat akun pengguna baru.
*/
public function test_super_admin_can_create_new_user(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$response = $this->actingAs($superAdmin)->post('/superadmin/users', [
'name' => 'Admin Baru HSE',
'username' => 'hse.baru',
'email' => '[email protected]',
'password' => 'secret123',
'role' => 'hse_admin',
]);
$response->assertRedirect('/superadmin/roles');
$response->assertSessionHas('success');
$this->assertDatabaseHas('users', [
'username' => 'hse.baru',
'email' => '[email protected]',
'role' => 'hse_admin',
]);
// Verifikasi ketika password tidak dikirim, otomatis memakai default 'password'
$respDefault = $this->actingAs($superAdmin)->post('/superadmin/users', [
'name' => 'Admin Baru QMA',
'username' => 'qma.baru',
'email' => '[email protected]',
'role' => 'qma_admin',
]);
$respDefault->assertRedirect('/superadmin/roles');
$newUser = User::where('username', 'qma.baru')->first();
$this->assertNotNull($newUser);
$this->assertTrue(Hash::check('password', $newUser->password));
}
/**
* Memastikan Super Admin dapat memperbarui akun pengguna.
*/
public function test_super_admin_can_update_user(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$targetUser = User::where('username', '1185')->first();
$response = $this->actingAs($superAdmin)->put("/superadmin/users/{$targetUser->id}", [
'name' => 'Ibu Mima Updated',
'username' => '1185',
'email' => '[email protected]',
'role' => 'hse_admin',
]);
$response->assertRedirect('/superadmin/roles');
$response->assertSessionHas('success');
$this->assertDatabaseHas('users', [
'id' => $targetUser->id,
'name' => 'Ibu Mima Updated',
'email' => '[email protected]',
]);
}
/**
* Memastikan Super Admin tidak dapat menghapus akunnya sendiri.
*/
public function test_super_admin_cannot_delete_own_account(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$response = $this->actingAs($superAdmin)->delete("/superadmin/users/{$superAdmin->id}");
$response->assertSessionHas('error');
$this->assertDatabaseHas('users', [
'id' => $superAdmin->id,
]);
}
/**
* Memastikan Super Admin dapat menghapus akun pengguna lain.
*/
public function test_super_admin_can_delete_other_user(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$dummyUser = User::create([
'name' => 'User Dihapus',
'username' => 'user.hapus',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
]);
$response = $this->actingAs($superAdmin)->delete("/superadmin/users/{$dummyUser->id}");
$response->assertRedirect('/superadmin/roles');
$response->assertSessionHas('success');
$this->assertDatabaseMissing('users', [
'id' => $dummyUser->id,
]);
}
/**
* Memastikan ketika akun Karyawan dihapus, record di tabel Employee juga terhapus (sinkron).
*/
public function test_deleting_employee_user_also_deletes_employee_record(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$employeeUser = User::create([
'name' => 'Karyawan Uji Hapus',
'username' => 'NIK-HAPUS-01',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'employee',
]);
$employee = \App\Models\Employee::create([
'user_id' => $employeeUser->id,
'nik' => 'NIK-HAPUS-01',
'name' => 'Karyawan Uji Hapus',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Teknisi',
'is_operator' => false,
]);
$response = $this->actingAs($superAdmin)->delete("/superadmin/users/{$employeeUser->id}");
$response->assertSessionHas('success');
$this->assertDatabaseMissing('users', ['id' => $employeeUser->id]);
$this->assertDatabaseMissing('employees', ['id' => $employee->id]);
}
/**
* Memastikan akun Karyawan yang memiliki rekam jejak aktivitas operasional TIDAK DAPAT dihapus.
*/
public function test_cannot_delete_employee_user_with_activity_history(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$gate = \App\Models\Gate::first();
$vehicle = \App\Models\Vehicle::first();
$employeeUser = User::create([
'name' => 'Driver Audit Trail',
'username' => 'NIK-AUDIT-01',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'employee',
]);
$employee = \App\Models\Employee::create([
'user_id' => $employeeUser->id,
'nik' => 'NIK-AUDIT-01',
'name' => 'Driver Audit Trail',
'unit_kerja' => 'Pembangkit',
'division' => 'Operasional',
'position' => 'Driver',
'is_operator' => true,
]);
\App\Models\VehicleActivity::create([
'transaction_no' => 'KMH-ACT-TEST-001',
'vehicle_id' => $vehicle->id,
'driver_id' => $employee->id,
'gate_id' => $gate->id,
'direction' => 'out',
'previous_km' => 100,
'current_km' => 150,
'distance' => 50,
'purpose' => 'Uji Coba Audit Trail',
'recorded_at' => now(),
'validation_status' => 'approved',
]);
$response = $this->actingAs($superAdmin)->delete("/superadmin/users/{$employeeUser->id}");
$response->assertSessionHas('error');
$this->assertDatabaseHas('users', ['id' => $employeeUser->id]);
$this->assertDatabaseHas('employees', ['id' => $employee->id]);
$this->assertDatabaseHas('vehicle_activities', ['transaction_no' => 'KMH-ACT-TEST-001']);
}
/**
* Memastikan Super Admin dapat mereset password akun pengguna ke default "password".
*/
public function test_super_admin_can_reset_user_password_to_default(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
$user = User::create([
'name' => 'Akun Uji Reset',
'username' => 'uji.reset',
'email' => '[email protected]',
'password' => Hash::make('customPassword123!'),
'role' => 'gate_officer',
]);
$this->assertTrue(Hash::check('customPassword123!', $user->password));
$response = $this->actingAs($superAdmin)->post("/superadmin/users/{$user->id}/reset-password");
$response->assertRedirect('/superadmin/roles');
$response->assertSessionHas('success');
$user->refresh();
$this->assertTrue(Hash::check('password', $user->password));
}
/**
* Memastikan Super Admin dapat melihat, memfilter, dan membuat akun role Karyawan (employee).
*/
public function test_super_admin_can_manage_employee_role(): void
{
$superAdmin = User::where('role', 'super_admin')->first();
// 1. Filter role employee
$response = $this->actingAs($superAdmin)->get('/superadmin/roles?role=employee');
$response->assertOk();
$response->assertSee('Karyawan');
// 2. Tambah akun role employee
$storeResponse = $this->actingAs($superAdmin)->post('/superadmin/users', [
'name' => 'Karyawan Baru Test',
'username' => 'KMH-TEST-999',
'email' => '[email protected]',
'password' => 'password',
'role' => 'employee',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Teknisi Turbin',
]);
$storeResponse->assertRedirect('/superadmin/roles');
$storeResponse->assertSessionHas('success');
$this->assertDatabaseHas('users', [
'username' => 'KMH-TEST-999',
'email' => '[email protected]',
'role' => 'employee',
]);
$this->assertDatabaseHas('employees', [
'nik' => 'KMH-TEST-999',
'name' => 'Karyawan Baru Test',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Teknisi Turbin',
]);
}
}
@@ -0,0 +1,274 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Models\Vehicle;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class UnitSupportBusinessProcessTest extends TestCase
{
use RefreshDatabase;
protected User $qmaAdmin;
protected function setUp(): void
{
parent::setUp();
$this->qmaAdmin = User::firstOrCreate(
['username' => 'qma_test_admin'],
[
'name' => 'QMA Tester',
'email' => '[email protected]',
'role' => 'qma_admin',
'password' => bcrypt('password'),
]
);
}
/**
* Pastikan halaman daftar kategori unit support menampilkan kategori dengan units_count.
*/
public function test_qma_admin_can_view_support_categories(): void
{
$category = Vehicle::firstOrCreate(
['code' => 'TEST-CAT'],
[
'category' => 'unit_support',
'brand_type' => 'Test Excavator X',
'unit_category' => 'Excavator',
'status' => 'Operation',
'current_km' => 100,
]
);
$response = $this->actingAs($this->qmaAdmin)
->get(route('qma.vehicles.support'));
$response->assertStatus(200);
$response->assertSee('TEST-CAT');
$response->assertSee('Tambah Kategori Unit');
}
/**
* Admin dapat melihat halaman daftar unit fisik di bawah kategori tertentu.
*/
public function test_qma_admin_can_view_physical_units_page(): void
{
$category = Vehicle::firstOrCreate(
['code' => 'TEST-BL'],
[
'category' => 'unit_support',
'brand_type' => 'Test Boomlift',
'unit_category' => 'Boomlift',
'status' => 'Operation',
'current_km' => 50,
]
);
$response = $this->actingAs($this->qmaAdmin)
->get(route('qma.vehicles.support.units', $category->id));
$response->assertStatus(200);
$response->assertSee('Tambah Unit Baru');
$response->assertSee('TEST-BL');
}
/**
* Pencarian unit fisik menampilkan hasil cocok atau pesan seragam jika tidak ditemukan.
*/
public function test_qma_admin_can_search_physical_units_and_renders_empty_state_when_not_found(): void
{
$category = Vehicle::firstOrCreate(
['code' => 'TEST-SEARCH'],
[
'category' => 'unit_support',
'brand_type' => 'Test Forklift',
'unit_category' => 'Forklift',
'status' => 'Operation',
'current_km' => 50,
]
);
$category->units()->create([
'code' => 'TEST-SEARCH-001',
'category' => 'unit_support',
'brand_type' => 'Test Forklift',
'status' => 'Operation',
'current_km' => 120,
'location' => 'Workshop Central',
'silo_document' => 'SILO-FL-2026',
]);
// 1. Pencarian dengan kata kunci yang cocok
$resFound = $this->actingAs($this->qmaAdmin)
->get(route('qma.vehicles.support.units', ['id' => $category->id, 'search' => 'Workshop']));
$resFound->assertStatus(200);
$resFound->assertSee('TEST-SEARCH-001');
$resFound->assertSee('Workshop Central');
$resFound->assertSee('unitSearchInput');
$resFound->assertSee('name="search"', false);
$resFound->assertSee('value="Workshop"', false);
// 2. Pencarian dengan kata kunci yang tidak ditemukan
$resNotFound = $this->actingAs($this->qmaAdmin)
->get(route('qma.vehicles.support.units', ['id' => $category->id, 'search' => 'nonexistentkeyword']));
$resNotFound->assertStatus(200);
$resNotFound->assertDontSee('TEST-SEARCH-001');
$resNotFound->assertSee('Data "<span class="text-rose-600 font-bold">nonexistentkeyword</span>" tidak ditemukan di tabel', false);
$resNotFound->assertSee('Pastikan kata kunci yang dicari sudah benar.');
$resNotFound->assertSee('Hapus Pencarian');
}
/**
* Admin dapat menambahkan unit fisik baru dan kode digenerate format 3-digit.
*/
public function test_qma_admin_can_create_physical_units_with_sequential_code(): void
{
$category = Vehicle::firstOrCreate(
['code' => 'TEST-CR'],
[
'category' => 'unit_support',
'brand_type' => 'Test Crane',
'unit_category' => 'Crane',
'status' => 'Operation',
'current_km' => 0,
]
);
// Tambah unit fisik pertama
$response1 = $this->actingAs($this->qmaAdmin)
->post(route('qma.vehicles.support.units.store', $category->id), [
'unit_number' => '001',
'serial_number' => 'SN-CRANE-9988',
'license_plate' => 'BH 5544 XX',
'production_year' => 2022,
'status' => 'Operation',
'current_km' => 10,
'location' => 'Inlet Dam',
]);
$response1->assertRedirect();
$this->assertDatabaseHas('vehicles', [
'code' => 'TEST-CR-001',
'parent_id' => $category->id,
'category' => 'unit_support',
'serial_number' => 'SN-CRANE-9988',
'license_plate' => 'BH 5544 XX',
'production_year' => 2022,
]);
// Tambah unit fisik kedua dengan auto-number
$response2 = $this->actingAs($this->qmaAdmin)
->post(route('qma.vehicles.support.units.store', $category->id), [
'unit_number' => '',
'status' => 'Standby',
'current_km' => 0,
]);
$response2->assertRedirect();
$this->assertDatabaseHas('vehicles', [
'code' => 'TEST-CR-002',
'parent_id' => $category->id,
'category' => 'unit_support',
]);
}
/**
* Ketika kode kategori diubah, kode unit fisik di bawahnya otomatis tersinkronisasi.
*/
public function test_updating_category_code_cascades_to_physical_units(): void
{
$category = Vehicle::firstOrCreate(
['code' => 'OLD01'],
[
'category' => 'unit_support',
'brand_type' => 'Old Category',
'unit_category' => 'Bulldozer',
'status' => 'Operation',
'current_km' => 0,
]
);
// Buat unit fisik
$unit1 = Vehicle::firstOrCreate(
['code' => 'OLD01-001'],
[
'parent_id' => $category->id,
'category' => 'unit_support',
'brand_type' => 'Old Category',
'status' => 'Operation',
'current_km' => 0,
]
);
$unit2 = Vehicle::firstOrCreate(
['code' => 'OLD01-002'],
[
'parent_id' => $category->id,
'category' => 'unit_support',
'brand_type' => 'Old Category',
'status' => 'Operation',
'current_km' => 0,
]
);
// Update kategori dari OLD01 menjadi NEW01
$response = $this->actingAs($this->qmaAdmin)
->post(route('qma.vehicles.update', $category->id), [
'code' => 'NEW01',
'category' => 'unit_support',
'brand_type' => 'Old Category Renamed',
'status' => 'Operation',
'current_km' => 0,
]);
$response->assertRedirect();
// Kategori terupdate
$this->assertDatabaseHas('vehicles', [
'id' => $category->id,
'code' => 'NEW01',
]);
// Seluruh anak fisik otomatis tersinkronisasi
$this->assertDatabaseHas('vehicles', [
'id' => $unit1->id,
'code' => 'NEW01-001',
]);
$this->assertDatabaseHas('vehicles', [
'id' => $unit2->id,
'code' => 'NEW01-002',
]);
// Kode lama tidak boleh ada lagi
$this->assertDatabaseMissing('vehicles', ['code' => 'OLD01-001']);
$this->assertDatabaseMissing('vehicles', ['code' => 'OLD01-002']);
}
/**
* Pastikan modul Light Vehicle (LV) tidak terpengaruh sama sekali.
*/
public function test_light_vehicle_module_remains_unaffected(): void
{
$lv = Vehicle::firstOrCreate(
['code' => 'LV-TEST-99'],
[
'category' => 'light_vehicle',
'brand_type' => 'Toyota Hilux Test',
'license_plate' => 'BH 9999 XX',
'status' => 'Operation',
'current_km' => 12000,
]
);
$response = $this->actingAs($this->qmaAdmin)
->get(route('qma.vehicles.lv'));
$response->assertStatus(200);
$response->assertSee('LV-TEST-99');
$this->assertNull($lv->parent_id);
}
}