@extends('layouts.app') @section('content')
{{ __('บริษัท: ') . (Auth::user()->agency?->Agency_Name ?? '-') }}
@elseif(strtolower((string)Auth::user()->Level) === 'consult')@if(Auth::user()->Agency_ID) {{ __('บริษัทของคุณยังไม่มีผลิตภัณฑ์') }} @else {{ __('คุณยังไม่มีผลิตภัณฑ์') }} @endif
{{ __('เพิ่มผลิตภัณฑ์แรก') }}| ลำดับ | ชื่อผลิตภัณฑ์ | โมเดล/รุ่น | วิธีรับข้อมูล | ประเภทผลิตภัณฑ์ | สถานะการประเมิน | วันที่สร้าง | การดำเนินการ |
|---|---|---|---|---|---|---|---|
| {{ $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 | {{-- ✅ กัน DtmIns ไม่ใช่ Carbon --}}@php $dt = $product->DtmIns ?? null; $formattedDate = '-'; if ($dt instanceof \Carbon\CarbonInterface) { $formattedDate = $dt->format('d/m/Y'); } elseif (!empty($dt)) { try { $formattedDate = \Carbon\Carbon::parse($dt)->format('d/m/Y'); } catch (\Exception $e) { $formattedDate = '-'; } } @endphp {{ $formattedDate }} |
@if($latestAssessment && $latestAssessment->status == 'draft')
@if(strtolower((string)Auth::user()->Level) === 'consult' && !empty($selectedAgencyId))
@else
@endif
ทำต่อ
@endif
รายงาน
@php
$user = Auth::user();
$hasDeleteAccess = false;
// ✅ FIX: เจ้าของผลิตภัณฑ์ใช้ Customer_ID
if ((int)$user->Customer_ID === (int)$product->Customer_ID) {
$hasDeleteAccess = true;
}
// Admin หรือ SuperAdmin
elseif (in_array(strtolower((string)$user->Level), ['admin', 'superadmin'], true)) {
$hasDeleteAccess = true;
}
// ✅ FIX: คนในบริษัทเดียวกัน ใช้ Agency_ID จาก product โดยตรง (ไม่พึ่ง $product->user)
elseif (!empty($user->Agency_ID) && !empty($product->Agency_ID) && (string)$user->Agency_ID === (string)$product->Agency_ID) {
$hasDeleteAccess = true;
}
@endphp
@if($hasDeleteAccess)
@endif
|