@extends('layouts.app') @section('content')
{{-- หัวข้อ + ตัวเลือกบริษัท + ปุ่มต่าง ๆ --}}

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

{{-- แสดงชื่อบริษัทที่กำลังดู --}} @if(isset($selectedAgency))

{{ __('บริษัท: ') . ($selectedAgency->Agency_Name ?? ('#'.$selectedAgency->Agency_ID)) }}

@elseif(Auth::user()->Agency_ID && optional(Auth::user()->agency)->Agency_Name)

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

@endif
{{-- สำหรับ consult: dropdown เลือกบริษัท --}} @if(isset($userAgencies) && $userAgencies->isNotEmpty())
{{-- preserve filter ถ้ามี --}} @if(request('filter')) @endif
@endif {{-- ปุ่ม filter (พก agency_id ถ้ามี) --}} {{-- เพิ่มผลิตภัณฑ์ (คง context agency_id) --}} {{ __('เพิ่มผลิตภัณฑ์') }} {{-- ปุ่มกลับไป ServTack --}} กลับไป ServTack
{{-- flash message --}} @if(session('success')) @elseif(session('error') && !session('success')) @php session()->forget('error'); @endphp @endif {{-- ตารางรายการ / ว่าง --}} @if($products->isEmpty())

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

@if(isset($selectedAgency)) {{ __('ยังไม่มีผลิตภัณฑ์ในบริษัทนี้') }} @elseif(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') ?? optional($product->created_at)->format('d/m/Y') ?? '-' }}
@if($latestAssessment && $latestAssessment->status === 'draft') ทำต่อ @endif รายงาน {{-- สิทธิ์ลบอย่างง่าย (ฝั่ง server ตรวจซ้ำแล้ว) --}} @php $u = Auth::user(); $canDel = false; if ($u->Customer_ID === $product->user_id) $canDel = true; elseif (strcasecmp($u->Level,'admin')===0 || strcasecmp($u->Level,'superadmin')===0) $canDel = true; elseif ($u->Agency_ID && $product->user && $product->user->Agency_ID && $u->Agency_ID === $product->user->Agency_ID) $canDel = true; @endphp @if($canDel)
@csrf @method('DELETE')
@endif
@endif
@endsection