@extends('layouts.app') @section('content') @php // query พก agency_id ไปกับลิงก์ทุกตัว $qs = []; if (!empty($selectedAgencyId)) { $qs['agency_id'] = $selectedAgencyId; } @endphp

{{ __('รายการผลิตภัณฑ์') }}

{{-- ผู้ใช้ทั่วไป: โชว์บริษัทเดียวของตัวเอง --}} @if(Auth::user()->Agency_ID && strtolower(Auth::user()->Level) !== 'consult')

{{ __('บริษัท: ') . (optional(Auth::user()->agency)->Agency_Name ?? '-') }}

{{-- consult: เลือกบริษัทได้จาก dropdown --}} @elseif(strtolower(Auth::user()->Level) === 'consult')
@endif
{{ __('ย้อนกลับ') }} {{-- ปุ่มตัวกรองรายการ --}} @if(Auth::user()->Agency_ID || strtolower(Auth::user()->Level) === 'consult') @endif {{-- ปุ่มเพิ่มผลิตภัณฑ์ ต้องพก agency_id สำหรับ consult --}} {{ __('เพิ่มผลิตภัณฑ์') }}
{{-- Flash messages --}} @if(session('success')) @elseif(session('error') && !session('success')) @php session()->forget('error'); @endphp @endif {{-- Empty state --}} @if($products->isEmpty())

{{ __('ไม่มีผลิตภัณฑ์') }}

@if(Auth::user()->Agency_ID) {{ __('บริษัทของคุณยังไม่มีผลิตภัณฑ์') }} @else {{ __('คุณยังไม่มีผลิตภัณฑ์') }} @endif

{{ __('เพิ่มผลิตภัณฑ์แรก') }}
@else
@foreach($products as $index => $product) @endforeach
ลำดับ ชื่อผลิตภัณฑ์ โมเดล/รุ่น วิธีรับข้อมูล ประเภทผลิตภัณฑ์ สถานะการประเมิน วันที่สร้าง การดำเนินการ
{{ $index + 1 }} {{ $product->name }} @if($product->description)
{{ \Illuminate\Support\Str::limit($product->description, 50) }} @endif
{{ $product->model ?? 'ไม่ระบุ' }} @switch($product->log_receive_method) @case('syslog_udp') syslog UDP @break @case('syslog_tcp') syslog TCP @break @case('syslog_both') syslog UDP & TCP @break @default {{ $product->log_receive_method }} @endswitch @if($product->product_type == 'hw_sw_log_server') Hardware + Software @else Software Only @endif @php $latestAssessment = $product->assessments()->latest()->first(); @endphp @if($latestAssessment) @if($latestAssessment->status == 'draft') ฉบับร่าง @elseif($latestAssessment->status == 'submitted') ส่งแล้ว @else {{ $latestAssessment->status }} @endif @else ยังไม่ประเมิน @endif {{ optional($product->DtmIns)->format('d/m/Y') }}
{{-- ทำต่อ (draft) ควรพก agency_id สำหรับ consult --}} @if($latestAssessment && $latestAssessment->status == 'draft') ทำต่อ @endif รายงาน {{-- สิทธิ์ลบ --}} @php $user = Auth::user(); $canDelete = false; if($user->Customer_ID === $product->Customer_ID) $canDelete = true; elseif(in_array(strtolower($user->Level), ['admin','superadmin'])) $canDelete = true; elseif($user->Agency_ID && $product->user && $product->user->Agency_ID && $user->Agency_ID === $product->user->Agency_ID) $canDelete = true; @endphp @if($canDelete)
@csrf @method('DELETE')
@endif
@endif
@endsection