@php $role = auth()->user()->currentRole; // 'can_manage_roles' // 'can_manage_ipass' // 'can_manage_users' // 'can_manage_adhoc' // 'can_manage_documents' @endphp
@foreach ($formData as $formLabel => $fields) @if($fields) @php $showSection = false; foreach ($fields as $field) { // For clients, check both visibility and is_visible_to_client if ($isClientView) { if ($field['visibility'] === true && ($field['is_visible_to_client'] ?? false)) { $showSection = true; break; } } else { // For non-clients, just check visibility if ($field['visibility'] === true) { $showSection = true; break; } } } @endphp @endif @endforeach
@if ($sublistView != '1') @php $groupedSublists = []; foreach ($formSublists as $sublist) { $row = $sublist['row']; if (!isset($groupedSublists[$row])) { $groupedSublists[$row] = []; } $groupedSublists[$row][] = $sublist; } @endphp
@foreach ($groupedSublists as $row => $sublists)
@foreach ($sublists as $sublist) @php // Assuming width is given in number of columns $colSpan = $sublist['width']; @endphp {{-- /********************** UPDATE HERE *********************/ --}}

{{ $sublist['label'] }}

@if($sublist['label'] != 'Documents' && $sublist['label'] != 'Gantt' && $sublist['label'] != 'Comments' && $sublist['label'] != 'Forms') @php $canViewTable = true; $tableExistsButRestricted = false; $useReactTable = false; // Flag to determine if we use React Table // Get the sublist record type $sublistRecordType = \Domain\RecordTypes\Models\RecordType::find($sublist['recordtype']); // Check if this should use React Table (e.g., for projecttask) if ($sublistRecordType && in_array($sublistRecordType->recordType, ['projecttask'])) { $useReactTable = true; } if ($isClientView && !empty($sublist['table'])) { $clientRole = auth()->user()->currentRole; // First check if table exists at all $tableExists = \Domain\TableBuilders\Models\TableBuilder::where('id', $sublist['table'])->exists(); if ($tableExists) { // Table exists, check if user has access $tableBuilder = \Domain\TableBuilders\Models\TableBuilder::where('id', $sublist['table']) ->where(function($query) use ($clientRole) { $query->whereDoesntHave('roles') ->orWhereHas('roles', function($roleQuery) use ($clientRole) { $roleQuery->where('role_id', $clientRole->id); }); }) ->first(); if ($tableBuilder === null) { // Table exists but user doesn't have access $canViewTable = false; $tableExistsButRestricted = true; } } // If table doesn't exist, let it fall through - BuildTableData will use fallback } // Build table data for React Table if needed and accessible $sublistTableData = null; if ($useReactTable && ($canViewTable || !$tableExistsButRestricted)) { $sublistTableData = \Domain\TableBuilders\Actions\BuildTableData::execute( $sublistRecordType, $sublist['table'] ?? null, [], false, null, $sublist['filters'] ?? null, true, null, $isClientView ); // Prepare data for JSON encoding if ($sublistTableData && isset($sublistTableData['tableFields'])) { $sublistTableData['tableFields'] = collect($sublistTableData['tableFields'])->map(function ($field) { if (isset($field['listoptions']) && $field['listoptions'] instanceof \Illuminate\Support\Collection) { $field['listoptions'] = $field['listoptions']->toArray(); } return $field; })->toArray(); } if ($sublistTableData && isset($sublistTableData['lists'])) { $sublistTableData['lists'] = collect($sublistTableData['lists'])->map(function ($list) { if (is_string($list)) { return json_decode($list, true); } return $list instanceof \Illuminate\Support\Collection ? $list->toArray() : $list; })->toArray(); } if ($sublistTableData && isset($sublistTableData['filterbuilder'])) { $sublistTableData['filterbuilder'] = collect($sublistTableData['filterbuilder'])->map(function ($filter) { if (isset($filter['options']) && $filter['options'] instanceof \Illuminate\Support\Collection) { $filter['options'] = $filter['options']->toArray(); } return $filter; })->toArray(); } } @endphp @if($canViewTable || !$tableExistsButRestricted) @if($useReactTable && $sublistTableData) {{-- Use React Table Component --}}
@php // Determine feature flags for React table $sublistModelClass = GetModel($sublistRecordType->model_name); $sublistHasSubtasks = $sublistModelClass && method_exists($sublistModelClass, 'subtasks'); $sublistHasComments = $sublistModelClass && in_array(\AliBayat\LaravelCommentable\Commentable::class, class_uses($sublistModelClass)); $sublistHasTimeEntry = $sublistRecordType->recordType === 'projecttask' || $sublistRecordType->recordType === 'assignee'; $sublistHasAssignees = $sublistRecordType->recordType === 'projecttask' && in_array('assignee', activeRecordTypes()); $sublistHasMedia = $sublistModelClass && method_exists($sublistModelClass, 'media'); // Get related record types for route building $sublistSubtaskRecordType = $sublistHasSubtasks ? GetRecordType('Subtask') : null; $sublistTimeEntryRecordType = $sublistHasTimeEntry ? GetRecordType('TimeEntry') : null; $sublistAssigneeRecordType = $sublistHasAssignees ? GetRecordType('Assignee') : null; @endphp
@else {{-- Use Livewire Component --}} @endif @else

This table is not available for client view

@endif @endif @if($sublist['label'] == 'Comments')
@endif @if($sublist['label'] == 'Forms')
@endif @if($sublist['label'] == 'Documents') @php $hasDocs = HasMethod($record, 'documents'); @endphp @endif @if($sublist['label'] == 'Gantt')
{{--
--}} @endif
@endforeach
@endforeach
@else @if ($formSublists || $recordType == '-1') @if($recordType == '-1' && !$formview)
@if($formSublists) @foreach ($formSublists as $index => $sublist)
{{ $sublist['label'] }}
@endforeach @endif
@else @endif @endif @endif
@prepend('dhtmlxgantt') {{-- ✅ VERSIÓN PRO: Archivos locales de DHTMLX Gantt PRO --}} @endprepend