@extends('layouts.app') @section('title', 'Detail Laporan') @section('content') {{-- ── Deteksi user QC dan tipe audit mesin ── --}} @php $qcDept = \App\Models\Department::whereRaw("LOWER(name) LIKE '%quality%'") ->orWhereRaw("LOWER(name) LIKE '%qc%'") ->first(); $isQcUser = auth()->user()->role === 'staff_departemen' && $qcDept && auth()->user()->department_id == $qcDept->id; $isMachineAuditReport = $report->auditType && strtolower($report->auditType->name) === 'mesin'; @endphp
{{ $report->report_number }}
{{ $report->auditor->name }} • {{ $report->submitted_at ? $report->submitted_at->format('d M Y H:i') : 'Belum terkirim' }}
{!! $report->status_badge !!}
{{-- ════ BANNER MESIN — hanya audit mesin dengan machine_name ════ --}} @if($isMachineAuditReport && $report->machine_name)
Mesin yang Dilaporkan
{{ $report->machine_name }}
Audit Mesin
@endif {{-- ════ END BANNER MESIN ════ --}}
{{ $report->auditType->name }}
{{ $report->department->name }}
{{ $report->location }}
{{-- ════ INFO MESIN di Grid — hanya audit mesin ════ --}} @if($isMachineAuditReport)
{{ $report->machine_name ?? '—' }}
@else {{-- Audit non-mesin: tampilkan Jenis Masalah di posisi ini --}}
{{ $report->issue_type }}
@endif {{-- Jenis Masalah — untuk audit mesin tampil di baris sendiri agar menonjol --}} @if($isMachineAuditReport)
{{ $report->issue_type }}
@endif
{{ $report->description }}
@if($report->fixed_at || $report->approved_at)
Timeline
{{ $report->submitted_at->format('d M Y H:i') }}

Laporan Terkirim

@if($report->fixed_at)
{{ $report->fixed_at->format('d M Y H:i') }}

Selesai Diperbaiki

@endif @if($report->approved_at)
{{ $report->approved_at->format('d M Y H:i') }}

Disetujui

@endif
@endif
@php $photos = is_array($report->photos) ? $report->photos : (is_string($report->photos) ? json_decode($report->photos, true) : []); @endphp @if($photos && count($photos) > 0)
Foto Masalah ({{ count($photos) }})
@foreach($photos as $index => $photo)
Foto Masalah {{ $index + 1 }}
@endforeach
@endif @if($report->deadline) @php $deadline = \Carbon\Carbon::parse($report->deadline); $now = \Carbon\Carbon::now(); $diffSeconds = $now->diffInSeconds($deadline, false); $isFixed = in_array($report->status, ['fixed', 'approved', 'final_approved']); $isOverdue = $diffSeconds < 0 && !$isFixed; @endphp
Deadline Perbaikan

{{ $deadline->format('d') }} {{ $deadline->locale('id')->monthName }} {{ $deadline->format('Y') }} pukul {{ $deadline->format('H:i') }} WIB

@if($isFixed) Selesai Tepat Waktu @else
@endif @if($report->deadline_reason)
Keterangan:

{{ $report->deadline_reason }}

@endif
@endif @if(in_array($report->status, ['rejected', 'rejected_by_auditor', 'in_progress']) && $report->rejection_reason)
Alasan Penolakan Auditor

{{ $report->rejection_reason }}

@endif @if(in_array($report->status, ['rejected_by_qc']) && $report->qc_rejection_reason)
Alasan Penolakan QC

{{ $report->qc_rejection_reason }}

@endif @if($report->responses && $report->responses->count() > 0)
Respons Perbaikan ({{ $report->responses->count() }})
@foreach($report->responses as $response)
{{ substr($response->user->name, 0, 1) }}
{{ $response->user->name }}
{{ $response->created_at->format('d M Y H:i') }}

{{ $response->description }}

@php $responsePhotos = is_array($response->photos) ? $response->photos : (is_string($response->photos) ? json_decode($response->photos, true) : []); @endphp @if($responsePhotos && count($responsePhotos) > 0)
Foto Perbaikan ({{ count($responsePhotos) }})
@foreach($responsePhotos as $index => $photo)
Foto Perbaikan {{ $index + 1 }}
@endforeach
@endif
@endforeach
@endif
@endsection @push('styles') @endpush @push('scripts') @endpush