feat: resolve audit items (multi-simper hse dashboard & export, soft-delete conflict handling, p2h blank initial state, qma breakdown recovery, and exclude lv from transporter)
This commit is contained in:
@@ -74,8 +74,8 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'username' => ['required', 'string', 'max:50', 'unique:users,username'],
|
'username' => ['required', 'string', 'max:50', Rule::unique('users', 'username')->whereNull('deleted_at')],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
|
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users', 'email')->whereNull('deleted_at')],
|
||||||
'password' => ['required', 'string', 'min:6'],
|
'password' => ['required', 'string', 'min:6'],
|
||||||
'role' => ['required', 'string', 'exists:roles,name'],
|
'role' => ['required', 'string', 'exists:roles,name'],
|
||||||
'gate_id' => ['nullable', 'exists:gates,id'],
|
'gate_id' => ['nullable', 'exists:gates,id'],
|
||||||
@@ -102,6 +102,28 @@ class UserController extends Controller
|
|||||||
$photoPath = ImageCompressionService::uploadAndCompress($request->file('photo'), 'employees', 500, 500, 80);
|
$photoPath = ImageCompressionService::uploadAndCompress($request->file('photo'), 'employees', 500, 500, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = User::withTrashed()
|
||||||
|
->where('username', $validated['username'])
|
||||||
|
->orWhere('email', $validated['email'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
if ($user->trashed()) {
|
||||||
|
$user->restore();
|
||||||
|
}
|
||||||
|
$userData = [
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
'role' => $validated['role'],
|
||||||
|
'gate_id' => $validated['gate_id'] ?? null,
|
||||||
|
];
|
||||||
|
if ($photoPath) {
|
||||||
|
$userData['photo_path'] = $photoPath;
|
||||||
|
}
|
||||||
|
$user->update($userData);
|
||||||
|
} else {
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
'username' => $validated['username'],
|
'username' => $validated['username'],
|
||||||
@@ -111,6 +133,7 @@ class UserController extends Controller
|
|||||||
'gate_id' => $validated['gate_id'] ?? null,
|
'gate_id' => $validated['gate_id'] ?? null,
|
||||||
'photo_path' => $photoPath,
|
'photo_path' => $photoPath,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Assign Spatie Role
|
// Assign Spatie Role
|
||||||
$user->assignRole($validated['role']);
|
$user->assignRole($validated['role']);
|
||||||
@@ -141,7 +164,7 @@ class UserController extends Controller
|
|||||||
$defaultDivision = ($isGateOfficer || $isPgAdmin) ? 'Private Guard' : '-';
|
$defaultDivision = ($isGateOfficer || $isPgAdmin) ? 'Private Guard' : '-';
|
||||||
$defaultPosition = $isGateOfficer ? 'Anggota' : ($isPgAdmin ? 'Admin PG' : ($isEmployeeRole ? 'Driver Operasional' : '-'));
|
$defaultPosition = $isGateOfficer ? 'Anggota' : ($isPgAdmin ? 'Admin PG' : ($isEmployeeRole ? 'Driver Operasional' : '-'));
|
||||||
|
|
||||||
$emp = Employee::where('user_id', $user->id)->orWhere('nik', $user->username)->first();
|
$emp = Employee::withTrashed()->where('user_id', $user->id)->orWhere('nik', $user->username)->first();
|
||||||
$empData = [
|
$empData = [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'nik' => $user->username,
|
'nik' => $user->username,
|
||||||
@@ -154,6 +177,9 @@ class UserController extends Controller
|
|||||||
'photo_path' => $photoPath ?: $emp?->photo_path,
|
'photo_path' => $photoPath ?: $emp?->photo_path,
|
||||||
];
|
];
|
||||||
if ($emp) {
|
if ($emp) {
|
||||||
|
if ($emp->trashed()) {
|
||||||
|
$emp->restore();
|
||||||
|
}
|
||||||
$emp->update($empData);
|
$emp->update($empData);
|
||||||
} else {
|
} else {
|
||||||
Employee::create($empData);
|
Employee::create($empData);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class EmployeeController extends Controller
|
class EmployeeController extends Controller
|
||||||
@@ -42,9 +43,10 @@ class EmployeeController extends Controller
|
|||||||
->take(5)
|
->take(5)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
// 2. Monitoring Status & Masa Berlaku SIMPER (Prioritas Kedaluwarsa & Segera Habis)
|
// 2. Monitoring Status & Masa Berlaku SIMPER (Prioritas Kedaluwarsa & Segera Habis dengan Dukungan Multi-SIMPER)
|
||||||
$today = now()->toDateString();
|
$today = now()->toDateString();
|
||||||
$simperLogs = Employee::where('is_operator', true)
|
$simperLogs = Employee::where('is_operator', true)
|
||||||
|
->with(['simpers.simperType'])
|
||||||
->orderByRaw("CASE
|
->orderByRaw("CASE
|
||||||
WHEN simper_expired_at IS NULL THEN 1
|
WHEN simper_expired_at IS NULL THEN 1
|
||||||
WHEN simper_expired_at < ? THEN 0
|
WHEN simper_expired_at < ? THEN 0
|
||||||
@@ -209,6 +211,7 @@ class EmployeeController extends Controller
|
|||||||
'Unit Kerja' => 20,
|
'Unit Kerja' => 20,
|
||||||
'Divisi' => 20,
|
'Divisi' => 20,
|
||||||
'Status Driver' => 16,
|
'Status Driver' => 16,
|
||||||
|
'Jenis Izin SIMPER' => 24,
|
||||||
'Masa Berlaku SIMPER' => 22,
|
'Masa Berlaku SIMPER' => 22,
|
||||||
'Status SIMPER' => 24,
|
'Status SIMPER' => 24,
|
||||||
];
|
];
|
||||||
@@ -221,6 +224,13 @@ class EmployeeController extends Controller
|
|||||||
$isDriver = $emp->is_operator;
|
$isDriver = $emp->is_operator;
|
||||||
$expDate = $emp->simper_expired_at ? $emp->simper_expired_at->format('d/m/Y') : '-';
|
$expDate = $emp->simper_expired_at ? $emp->simper_expired_at->format('d/m/Y') : '-';
|
||||||
|
|
||||||
|
// Ambil rincian seluruh kode SIMPER yang dipegang
|
||||||
|
$simperList = $emp->simpers->map(function ($s) {
|
||||||
|
$code = $s->simperType?->code ?: 'SIMPER';
|
||||||
|
return str_replace('SIMPER-', '', $code);
|
||||||
|
})->filter()->unique()->values();
|
||||||
|
$simperTypesText = $simperList->isNotEmpty() ? $simperList->join(', ') : ($isDriver ? 'LV (Default)' : '-');
|
||||||
|
|
||||||
if (! $isDriver) {
|
if (! $isDriver) {
|
||||||
$statusText = 'Bukan Driver';
|
$statusText = 'Bukan Driver';
|
||||||
} elseif (! $emp->simper_expired_at) {
|
} elseif (! $emp->simper_expired_at) {
|
||||||
@@ -242,6 +252,7 @@ class EmployeeController extends Controller
|
|||||||
$emp->unit_kerja ?: '-',
|
$emp->unit_kerja ?: '-',
|
||||||
$emp->division ?: '-',
|
$emp->division ?: '-',
|
||||||
$isDriver ? 'Driver' : 'Bukan Driver',
|
$isDriver ? 'Driver' : 'Bukan Driver',
|
||||||
|
$simperTypesText,
|
||||||
$expDate,
|
$expDate,
|
||||||
$statusText,
|
$statusText,
|
||||||
];
|
];
|
||||||
@@ -256,6 +267,7 @@ class EmployeeController extends Controller
|
|||||||
'left', // Unit Kerja
|
'left', // Unit Kerja
|
||||||
'left', // Divisi
|
'left', // Divisi
|
||||||
'center', // Status Driver
|
'center', // Status Driver
|
||||||
|
'center', // Jenis Izin SIMPER
|
||||||
'center', // Masa Berlaku
|
'center', // Masa Berlaku
|
||||||
'center', // Status SIMPER
|
'center', // Status SIMPER
|
||||||
];
|
];
|
||||||
@@ -580,7 +592,7 @@ class EmployeeController extends Controller
|
|||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'nik' => ['required', 'string', 'max:50', 'unique:employees,nik'],
|
'nik' => ['required', 'string', 'max:50', Rule::unique('employees', 'nik')->whereNull('deleted_at')],
|
||||||
'name' => ['required', 'string', 'max:100'],
|
'name' => ['required', 'string', 'max:100'],
|
||||||
'unit_kerja' => ['required', 'string'],
|
'unit_kerja' => ['required', 'string'],
|
||||||
'division' => ['required', 'string'],
|
'division' => ['required', 'string'],
|
||||||
@@ -613,15 +625,24 @@ class EmployeeController extends Controller
|
|||||||
$employeeType = 'Karyawan';
|
$employeeType = 'Karyawan';
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::firstOrCreate(
|
$user = User::withTrashed()->where('username', $validated['nik'])->first();
|
||||||
['username' => $validated['nik']],
|
if ($user) {
|
||||||
[
|
if ($user->trashed()) {
|
||||||
|
$user->restore();
|
||||||
|
}
|
||||||
|
$user->update([
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'role' => $user->role ?: 'employee',
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$user = User::create([
|
||||||
|
'username' => $validated['nik'],
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
'email' => strtolower(str_replace(['-', ' '], '', $validated['nik'])) . '@kmh.co.id',
|
'email' => strtolower(str_replace(['-', ' '], '', $validated['nik'])) . '@kmh.co.id',
|
||||||
'password' => Hash::make(config('auth.default_employee_password', '123456')),
|
'password' => Hash::make(config('auth.default_employee_password', '123456')),
|
||||||
'role' => 'employee',
|
'role' => 'employee',
|
||||||
]
|
]);
|
||||||
);
|
}
|
||||||
|
|
||||||
if (!$user->hasRole('employee')) {
|
if (!$user->hasRole('employee')) {
|
||||||
$user->assignRole('employee');
|
$user->assignRole('employee');
|
||||||
@@ -633,6 +654,23 @@ class EmployeeController extends Controller
|
|||||||
$user->update(['photo_path' => $photoPath]);
|
$user->update(['photo_path' => $photoPath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$employee = Employee::withTrashed()->where('nik', $validated['nik'])->first();
|
||||||
|
if ($employee) {
|
||||||
|
if ($employee->trashed()) {
|
||||||
|
$employee->restore();
|
||||||
|
}
|
||||||
|
$employee->update([
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'employee_type' => $employeeType,
|
||||||
|
'unit_kerja' => $validated['unit_kerja'],
|
||||||
|
'division' => $validated['division'],
|
||||||
|
'position' => $validated['position'],
|
||||||
|
'is_operator' => $isOperator,
|
||||||
|
'simper_expired_at' => $simperExpiredAt,
|
||||||
|
'photo_path' => $photoPath ?? $employee->photo_path,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
$employee = Employee::create([
|
$employee = Employee::create([
|
||||||
'nik' => $validated['nik'],
|
'nik' => $validated['nik'],
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
@@ -645,6 +683,7 @@ class EmployeeController extends Controller
|
|||||||
'photo_path' => $photoPath,
|
'photo_path' => $photoPath,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Sinkronisasi Multi-SIMPER Personil
|
// Sinkronisasi Multi-SIMPER Personil
|
||||||
$this->syncEmployeeSimpers($employee, $request, $isOperator, $simperExpiredAt);
|
$this->syncEmployeeSimpers($employee, $request, $isOperator, $simperExpiredAt);
|
||||||
|
|||||||
@@ -735,8 +735,11 @@ class P2hInspectionController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Jika unit dinyatakan aman dan sebelumnya breakdown karena review, status unit disetujui operasi
|
// Jika unit dinyatakan aman dan sebelumnya breakdown karena review, status unit disetujui operasi
|
||||||
if (!$record->hasDefects() && $record->vehicle->status === 'Breakdown') {
|
if (!$record->hasDefects() && $record->vehicle && $record->vehicle->status === 'Breakdown') {
|
||||||
$record->vehicle->update(['status' => 'Operation']);
|
$record->vehicle->update([
|
||||||
|
'status' => 'Operation',
|
||||||
|
'location_note' => "Status dipulihkan ke Operation pasca persetujuan P2H {$record->transaction_no}",
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return back()->with('success', "Inspeksi P2H [{$record->transaction_no}] untuk unit {$record->vehicle->code} berhasil DISETUJUI.");
|
return back()->with('success', "Inspeksi P2H [{$record->transaction_no}] untuk unit {$record->vehicle->code} berhasil DISETUJUI.");
|
||||||
|
|||||||
@@ -144,8 +144,14 @@ class SupportTimesheetController extends Controller
|
|||||||
$activeUnitsCount = $statsItems->pluck('vehicle_id')->unique()->count();
|
$activeUnitsCount = $statsItems->pluck('vehicle_id')->unique()->count();
|
||||||
$breakdownCount = $statsItems->where('status', 'Breakdown')->count();
|
$breakdownCount = $statsItems->where('status', 'Breakdown')->count();
|
||||||
|
|
||||||
// Data Master untuk Form & Filter
|
// Data Master untuk Form & Filter (Alat Berat / Heavy Equipment - Bebas dari Unit LV)
|
||||||
$unitSupports = Vehicle::unitSupports()
|
$unitSupports = Vehicle::unitSupports()
|
||||||
|
->where('category', '!=', 'light_vehicle')
|
||||||
|
->where(function (Builder $q) {
|
||||||
|
$q->where('code', 'not like', 'LV %')
|
||||||
|
->where('code', 'not like', 'LV-%')
|
||||||
|
->where('code', 'not like', 'LV_%');
|
||||||
|
})
|
||||||
->where(function (Builder $q) {
|
->where(function (Builder $q) {
|
||||||
$q->whereNotNull('parent_id')
|
$q->whereNotNull('parent_id')
|
||||||
->orWhereDoesntHave('units');
|
->orWhereDoesntHave('units');
|
||||||
@@ -425,7 +431,12 @@ class SupportTimesheetController extends Controller
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return back()->with('success', "Timesheet {$timesheetNo} untuk unit {$vehicle->code} berhasil disimpan.");
|
$successMsg = "Timesheet {$timesheetNo} untuk unit {$vehicle->code} berhasil disimpan.";
|
||||||
|
if ($operatingHours !== null && $operatingHours > 24) {
|
||||||
|
$successMsg .= " (Catatan: Total waktu operasi tercatat {$operatingHours} HM/Jam [> 24 jam]. Harap periksa apakah angka Start HM atau End HM sudah sesuai).";
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('success', $successMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -527,7 +538,12 @@ class SupportTimesheetController extends Controller
|
|||||||
'notes' => $validated['notes'] ?? null,
|
'notes' => $validated['notes'] ?? null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return back()->with('success', "Timesheet {$timesheet->timesheet_no} berhasil diperbarui.");
|
$successMsg = "Timesheet {$timesheet->timesheet_no} berhasil diperbarui.";
|
||||||
|
if ($operatingHours !== null && $operatingHours > 24) {
|
||||||
|
$successMsg .= " (Catatan: Total waktu operasi tercatat {$operatingHours} HM/Jam [> 24 jam]. Harap periksa apakah angka Start HM atau End HM sudah sesuai).";
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('success', $successMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,9 +143,18 @@ class UnitTransferController extends Controller
|
|||||||
->map(fn($group) => $group->count())
|
->map(fn($group) => $group->count())
|
||||||
->sortKeys();
|
->sortKeys();
|
||||||
|
|
||||||
// 2. Daftar unit kendaraan kita untuk armada pengangkut (Truk, Flatbed, Lowbed, Towing, LV, dsb.)
|
// 2. Daftar armada pengangkut khusus truk/alat angkut (Truk, Flatbed, Lowbed, Towing, dsb. - Eksklusif Non-LV)
|
||||||
$transporterUnits = Vehicle::trackableUnits()
|
$transporterUnits = Vehicle::where('category', '!=', 'light_vehicle')
|
||||||
->orderBy('category')
|
->where(function (Builder $q) {
|
||||||
|
$q->where('code', 'not like', 'LV %')
|
||||||
|
->where('code', 'not like', 'LV-%')
|
||||||
|
->where('code', 'not like', 'LV/%')
|
||||||
|
->where('code', 'not like', 'LV_%');
|
||||||
|
})
|
||||||
|
->where(function (Builder $q) {
|
||||||
|
$q->whereNotNull('parent_id')
|
||||||
|
->orWhereDoesntHave('units');
|
||||||
|
})
|
||||||
->orderBy('code')
|
->orderBy('code')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -104,14 +104,15 @@ class SimperPdfExporter extends FPDF
|
|||||||
$this->SetFont('Arial', 'B', 7.5);
|
$this->SetFont('Arial', 'B', 7.5);
|
||||||
|
|
||||||
$cols = [
|
$cols = [
|
||||||
['NO', 10, 'C'],
|
['NO', 8, 'C'],
|
||||||
['NIK', 30, 'C'],
|
['NIK', 25, 'C'],
|
||||||
['NAMA KARYAWAN', 62, 'L'],
|
['NAMA KARYAWAN', 52, 'L'],
|
||||||
['JABATAN', 45, 'L'],
|
['JABATAN', 38, 'L'],
|
||||||
['UNIT / DIVISI', 40, 'L'],
|
['UNIT / DIVISI', 34, 'L'],
|
||||||
['STATUS DRIVER', 26, 'C'],
|
['DRIVER', 22, 'C'],
|
||||||
['MASA BERLAKU', 26, 'C'],
|
['JENIS SIMPER', 34, 'C'],
|
||||||
['STATUS SIMPER', 28, 'C'],
|
['MASA BERLAKU', 25, 'C'],
|
||||||
|
['STATUS', 29, 'C'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($cols as $col) {
|
foreach ($cols as $col) {
|
||||||
@@ -180,32 +181,42 @@ class SimperPdfExporter extends FPDF
|
|||||||
|
|
||||||
// Kolom 1: No
|
// Kolom 1: No
|
||||||
$pdf->SetFont('Arial', '', 7.5);
|
$pdf->SetFont('Arial', '', 7.5);
|
||||||
$pdf->Cell(10, 6.5, (string) ($idx + 1), 'B', 0, 'C', $fill);
|
$pdf->Cell(8, 6.5, (string) ($idx + 1), 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
// Kolom 2: NIK (Bold)
|
// Kolom 2: NIK (Bold)
|
||||||
$pdf->SetFont('Arial', 'B', 7.5);
|
$pdf->SetFont('Arial', 'B', 7.5);
|
||||||
$pdf->Cell(30, 6.5, $emp->nik, 'B', 0, 'C', $fill);
|
$pdf->Cell(25, 6.5, $emp->nik, 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
// Kolom 3: Nama Lengkap (Bold, Truncate jika > 36 karakter)
|
// Kolom 3: Nama Lengkap (Bold, Truncate jika > 30 karakter)
|
||||||
$nama = mb_strimwidth($emp->name, 0, 36, '...');
|
$nama = mb_strimwidth($emp->name, 0, 30, '...');
|
||||||
$pdf->Cell(62, 6.5, ' ' . $nama, 'B', 0, 'L', $fill);
|
$pdf->Cell(52, 6.5, ' ' . $nama, 'B', 0, 'L', $fill);
|
||||||
|
|
||||||
// Kolom 4: Jabatan
|
// Kolom 4: Jabatan
|
||||||
$pdf->SetFont('Arial', '', 7.5);
|
$pdf->SetFont('Arial', '', 7.5);
|
||||||
$jabatan = mb_strimwidth($emp->position ?: '-', 0, 26, '...');
|
$jabatan = mb_strimwidth($emp->position ?: '-', 0, 22, '...');
|
||||||
$pdf->Cell(45, 6.5, ' ' . $jabatan, 'B', 0, 'L', $fill);
|
$pdf->Cell(38, 6.5, ' ' . $jabatan, 'B', 0, 'L', $fill);
|
||||||
|
|
||||||
// Kolom 5: Unit / Divisi
|
// Kolom 5: Unit / Divisi
|
||||||
$unit = mb_strimwidth($emp->unit_kerja ?: ($emp->division ?: '-'), 0, 24, '...');
|
$unit = mb_strimwidth($emp->unit_kerja ?: ($emp->division ?: '-'), 0, 20, '...');
|
||||||
$pdf->Cell(40, 6.5, ' ' . $unit, 'B', 0, 'L', $fill);
|
$pdf->Cell(34, 6.5, ' ' . $unit, 'B', 0, 'L', $fill);
|
||||||
|
|
||||||
// Kolom 6: Status Driver
|
// Kolom 6: Status Driver
|
||||||
$pdf->Cell(26, 6.5, $isDriver ? 'Driver' : 'Non-Driver', 'B', 0, 'C', $fill);
|
$pdf->Cell(22, 6.5, $isDriver ? 'Driver' : 'Non-Driver', 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
// Kolom 7: Masa Berlaku
|
// Kolom 7: Rincian Jenis SIMPER
|
||||||
$pdf->Cell(26, 6.5, $expDate, 'B', 0, 'C', $fill);
|
$simperList = $emp->simpers->map(function ($s) {
|
||||||
|
$code = $s->simperType?->code ?: 'SIMPER';
|
||||||
|
return str_replace('SIMPER-', '', $code);
|
||||||
|
})->filter()->unique()->values();
|
||||||
|
$simperTypesText = $simperList->isNotEmpty() ? $simperList->join(', ') : ($isDriver ? 'LV' : '-');
|
||||||
|
$pdf->SetFont('Arial', 'B', 7);
|
||||||
|
$pdf->Cell(34, 6.5, $simperTypesText, 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
// Kolom 8: Status SIMPER (Berwarna)
|
// Kolom 8: Masa Berlaku
|
||||||
|
$pdf->SetFont('Arial', '', 7.5);
|
||||||
|
$pdf->Cell(25, 6.5, $expDate, 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
|
// Kolom 9: Status SIMPER (Berwarna)
|
||||||
if ($statusText === 'Masih Berlaku') {
|
if ($statusText === 'Masih Berlaku') {
|
||||||
$pdf->SetTextColor(4, 120, 87); // #047857 Green
|
$pdf->SetTextColor(4, 120, 87); // #047857 Green
|
||||||
} elseif ($statusText === 'Segera Habis') {
|
} elseif ($statusText === 'Segera Habis') {
|
||||||
@@ -216,7 +227,7 @@ class SimperPdfExporter extends FPDF
|
|||||||
$pdf->SetTextColor(100, 116, 139); // #64748b Slate
|
$pdf->SetTextColor(100, 116, 139); // #64748b Slate
|
||||||
}
|
}
|
||||||
$pdf->SetFont('Arial', 'B', 7.5);
|
$pdf->SetFont('Arial', 'B', 7.5);
|
||||||
$pdf->Cell(28, 6.5, $statusText, 'B', 0, 'C', $fill);
|
$pdf->Cell(29, 6.5, $statusText, 'B', 0, 'C', $fill);
|
||||||
|
|
||||||
$pdf->Ln();
|
$pdf->Ln();
|
||||||
$fill = ! $fill;
|
$fill = ! $fill;
|
||||||
|
|||||||
@@ -197,6 +197,23 @@
|
|||||||
<span>Berlaku s.d. {{ $log->simper_expired_at->locale('id')->translatedFormat('d M Y') }} ({{ $log->simper_expired_at->locale('id')->diffForHumans() }})</span>
|
<span>Berlaku s.d. {{ $log->simper_expired_at->locale('id')->translatedFormat('d M Y') }} ({{ $log->simper_expired_at->locale('id')->diffForHumans() }})</span>
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<!-- Rincian Badge Multi-SIMPER Personil -->
|
||||||
|
@if($log->simpers && $log->simpers->isNotEmpty())
|
||||||
|
<div class="flex items-center gap-1.5 flex-wrap mt-1.5 pt-1.5 border-t border-slate-100">
|
||||||
|
@foreach($log->simpers as $smp)
|
||||||
|
@php
|
||||||
|
$smpValid = $smp->isValid();
|
||||||
|
$smpCode = $smp->simperType?->code ?: 'SIMPER';
|
||||||
|
$shortCode = str_replace('SIMPER-', '', $smpCode);
|
||||||
|
@endphp
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-[9px] font-bold font-mono {{ $smpValid ? 'bg-emerald-50 text-emerald-800 border border-emerald-200' : 'bg-rose-50 text-rose-700 border border-rose-200' }}" title="{{ $smp->simperType?->name }}: s/d {{ $smp->expired_at ? $smp->expired_at->format('d/m/Y') : '-' }}">
|
||||||
|
<i class="fa-solid {{ $smpValid ? 'fa-circle-check text-emerald-600' : 'fa-circle-xmark text-rose-600' }} mr-1 text-[8px]"></i>
|
||||||
|
<span>{{ $shortCode }}: {{ $smp->expired_at ? $smp->expired_at->format('d/m/y') : '-' }}</span>
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Badge Kanan -->
|
<!-- Badge Kanan -->
|
||||||
|
|||||||
@@ -218,13 +218,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(in_array($item->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix']))
|
@if(in_array($item->question_type, ['choice', 'condition', 'Multiple choice: only one answer', 'Matrix']))
|
||||||
<!-- Opsi Jawaban Radio: Baik & Rusak -->
|
<!-- Opsi Jawaban Radio: Baik & Rusak (Kosongan secara Default, Wajib Dipilih Operator) -->
|
||||||
<div class="flex items-center space-x-2 flex-shrink-0">
|
<div class="flex items-center space-x-2 flex-shrink-0">
|
||||||
<label class="cursor-pointer">
|
<label class="cursor-pointer">
|
||||||
<input type="radio"
|
<input type="radio"
|
||||||
name="items[{{ $item->id }}][condition]"
|
name="items[{{ $item->id }}][condition]"
|
||||||
value="baik"
|
value="baik"
|
||||||
checked
|
{{ old("items.{$item->id}.condition") === 'baik' ? 'checked' : '' }}
|
||||||
onchange="handleConditionChange({{ $item->id }}, 'baik')"
|
onchange="handleConditionChange({{ $item->id }}, 'baik')"
|
||||||
class="peer sr-only">
|
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 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">
|
||||||
@@ -236,6 +236,7 @@
|
|||||||
<input type="radio"
|
<input type="radio"
|
||||||
name="items[{{ $item->id }}][condition]"
|
name="items[{{ $item->id }}][condition]"
|
||||||
value="rusak"
|
value="rusak"
|
||||||
|
{{ old("items.{$item->id}.condition") === 'rusak' ? 'checked' : '' }}
|
||||||
onchange="handleConditionChange({{ $item->id }}, 'rusak')"
|
onchange="handleConditionChange({{ $item->id }}, 'rusak')"
|
||||||
class="peer sr-only">
|
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">
|
<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">
|
||||||
@@ -404,6 +405,25 @@
|
|||||||
const panel = document.getElementById('p2h-content-' + secKey);
|
const panel = document.getElementById('p2h-content-' + secKey);
|
||||||
if (!panel) return true;
|
if (!panel) return true;
|
||||||
|
|
||||||
|
// 1. Validasi: Pastikan setiap butir pemeriksaan radio di bagian ini telah dipilih (Baik / Rusak)
|
||||||
|
const radioRows = panel.querySelectorAll('.p2h-item-card');
|
||||||
|
for (const row of radioRows) {
|
||||||
|
const radios = row.querySelectorAll('input[type="radio"]');
|
||||||
|
if (radios.length > 0) {
|
||||||
|
const isSelected = Array.from(radios).some(r => r.checked);
|
||||||
|
if (!isSelected) {
|
||||||
|
row.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
row.classList.add('ring-2', 'ring-rose-500', 'bg-rose-50/50');
|
||||||
|
setTimeout(() => {
|
||||||
|
row.classList.remove('ring-2', 'ring-rose-500', 'bg-rose-50/50');
|
||||||
|
}, 3500);
|
||||||
|
alert('Harap periksa dan tentukan kondisi (Baik atau Rusak) untuk seluruh butir pemeriksaan pada bagian ini.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Validasi: Jika ada yang rusak, wajib diisi catatan penjelasannya
|
||||||
const damagedRadios = panel.querySelectorAll('input[type="radio"][value="rusak"]:checked');
|
const damagedRadios = panel.querySelectorAll('input[type="radio"][value="rusak"]:checked');
|
||||||
for (const radio of damagedRadios) {
|
for (const radio of damagedRadios) {
|
||||||
const match = radio.name.match(/items\[(\d+)\]/);
|
const match = radio.name.match(/items\[(\d+)\]/);
|
||||||
|
|||||||
Reference in New Issue
Block a user