@foreach ($layout as $node) @php $nodeType = $node['type'] ?? ''; @endphp @if ($nodeType === 'row') @php $rows = []; $currentRow = []; $currentWidth = 0; foreach ($node['columns'] ?? [] as $column) { $width = (int) ($column['width'] ?? 12); if ($width < 1 || $width > 12) { $width = 12; } if ($currentWidth + $width > 12 && $currentRow) { $rows[] = $currentRow; $currentRow = []; $currentWidth = 0; } $currentRow[] = ['width' => $width, 'items' => $column['items'] ?? []]; $currentWidth += $width; } if ($currentRow) { $rows[] = $currentRow; } @endphp @foreach ($rows as $columns)
@foreach ($columns as $column) @php $colClass = $column['width'] < 12 ? 'col-12 col-lg-' . $column['width'] : 'col-12'; @endphp
@include('admin.forms.partials.form-layout-readonly-print', [ 'layout' => $column['items'] ?? [], 'values' => $values ?? [], ])
@endforeach
@endforeach @elseif ($nodeType === 'table') @php $nodeCellWidth = (int) ($node['cellWidth'] ?? 0); $nodeCellHeight = (int) ($node['cellHeight'] ?? 0); @endphp @foreach ($node['rows'] ?? [] as $row) @foreach ($row as $cell) @php $cellWidth = (int) ($cell['width'] ?? 12); if ($cellWidth < 1 || $cellWidth > 12) { $cellWidth = 12; } $cellWidthPx = (int) ($cell['cellWidth'] ?? 0); $cellHeightPx = (int) ($cell['cellHeight'] ?? 0); $cellStyleParts = []; if ($cellWidth < 12) { $cellStyleParts[] = 'width: ' . round(($cellWidth / 12) * 100, 2) . '%;'; } if ($cellWidthPx > 0) { $cellStyleParts[] = 'min-width: ' . $cellWidthPx . 'px;'; } elseif ($nodeCellWidth > 0) { $cellStyleParts[] = 'min-width: ' . $nodeCellWidth . 'px;'; } if ($cellHeightPx > 0) { $cellStyleParts[] = 'height: ' . $cellHeightPx . 'px;'; } elseif ($nodeCellHeight > 0) { $cellStyleParts[] = 'height: ' . $nodeCellHeight . 'px;'; } $cellStyle = implode(' ', $cellStyleParts); @endphp @endforeach @endforeach
@include('admin.forms.partials.form-layout-readonly-print', [ 'layout' => $cell['items'] ?? [], 'values' => $values ?? [], ])
@elseif ($nodeType === 'section') @elseif ($nodeType === 'content')
{!! $node['html'] ?? '' !!}
@elseif ($nodeType === 'field') @php $field = $node['field'] ?? []; $fieldKey = $field['key'] ?? ''; $fieldLabel = $field['label'] ?? $fieldKey; $fieldType = $field['type'] ?? 'text'; $fieldOptions = $field['options'] ?? []; $value = $fieldKey !== '' ? ($values[$fieldKey] ?? null) : null; $labelPosition = strtolower(trim((string) ($field['labelPosition'] ?? 'left'))); if ($labelPosition === '') { $labelPosition = 'left'; } $labelWidth = (int) ($field['labelWidth'] ?? 0); $labelMargin = (int) ($field['labelMargin'] ?? 0); $labelAlign = strtolower(trim((string) ($field['labelAlign'] ?? ''))); $inputAlign = strtolower(trim((string) ($field['inputAlign'] ?? ''))); $hideLabel = !empty($field['hideLabel']) || $labelPosition === 'hidden'; $prefix = trim((string) ($field['prefix'] ?? '')); $suffix = trim((string) ($field['suffix'] ?? '')); $description = trim((string) ($field['description'] ?? '')); $tooltip = trim((string) ($field['tooltip'] ?? '')); $surveyQuestions = $field['questions'] ?? []; $surveyValues = $field['surveyValues'] ?? []; $labelAfter = in_array($labelPosition, ['right', 'bottom'], true); $rowClasses = ['form-layout-row']; if (in_array($labelPosition, ['top', 'bottom'], true)) { $rowClasses[] = 'form-layout-row-vertical'; } if ($labelPosition === 'right') { $rowClasses[] = 'form-layout-row-right'; } if ($hideLabel) { $rowClasses[] = 'form-layout-row-no-label'; } $rowStyle = ''; if ($labelWidth > 0) { $rowStyle .= '--label-width:' . $labelWidth . 'px;'; } if ($labelMargin > 0) { $rowStyle .= '--label-gap:' . $labelMargin . 'px;'; } if ($inputAlign !== '') { $rowStyle .= '--input-align:' . $inputAlign . ';'; } $inputWidth = (int) ($field['inputWidth'] ?? $field['input_width'] ?? 0); $inputHeight = (int) ($field['inputHeight'] ?? $field['input_height'] ?? 0); if ($inputWidth < 0) { $inputWidth = 0; } if ($inputHeight < 0) { $inputHeight = 0; } $controlStyle = ''; if ($inputWidth > 0) { $controlStyle .= 'width:' . $inputWidth . 'px;max-width:100%;'; } if ($inputHeight > 0) { $controlStyle .= 'min-height:' . $inputHeight . 'px;'; } $displayValue = '-'; $linkPath = null; $displayHtml = null; if ($fieldType === 'survey' && is_array($value)) { $questionLabels = []; foreach ($surveyQuestions as $question) { $qKey = (string) ($question['value'] ?? $question['label'] ?? ''); if ($qKey === '') { continue; } $questionLabels[$qKey] = (string) ($question['label'] ?? $qKey); } $valueLabels = []; foreach ($surveyValues as $opt) { $optValue = (string) ($opt['value'] ?? ''); $valueLabels[$optValue] = (string) ($opt['label'] ?? $optValue); } $lines = []; foreach ($value as $qKey => $answer) { if ($answer === '' || $answer === null) { continue; } $qLabel = $questionLabels[$qKey] ?? (string) $qKey; $aLabel = $valueLabels[(string) $answer] ?? (string) $answer; $lines[] = e($qLabel) . ': ' . e($aLabel); } if ($lines) { $displayHtml = '
' . implode('
', $lines) . '
'; $displayValue = ''; } } elseif ($fieldType === 'address' && is_array($value)) { $parts = array_filter(array_map('trim', $value)); if ($parts) { $displayHtml = '
' . implode('
', array_map('e', $parts)) . '
'; $displayValue = ''; } } elseif (is_array($value)) { if (isset($value['name'])) { $displayValue = (string) $value['name']; if (!empty($value['path'])) { $linkPath = asset($value['path']); } } elseif ($value) { $displayValue = implode(', ', array_map('strval', $value)); } } elseif (is_bool($value)) { $displayValue = $value ? 'Evet' : 'Hayir'; } elseif ($value !== null && $value !== '') { $displayValue = (string) $value; } if (in_array($fieldType, ['select', 'radio'], true) && $fieldOptions && $value !== null && $value !== '') { foreach ($fieldOptions as $option) { if ((string) ($option['value'] ?? '') === (string) $value) { $displayValue = (string) ($option['label'] ?? $displayValue); break; } } } if ($fieldType === 'selectboxes' && is_array($value)) { $selected = []; if (array_is_list($value)) { $selected = $value; } else { foreach ($value as $key => $checked) { if ($checked) { $selected[] = $key; } } } if ($fieldOptions && $selected) { $labels = []; foreach ($fieldOptions as $option) { if (in_array((string) ($option['value'] ?? ''), array_map('strval', $selected), true)) { $labels[] = (string) ($option['label'] ?? $option['value']); } } if ($labels) { $displayValue = implode(', ', $labels); } } elseif ($selected) { $displayValue = implode(', ', array_map('strval', $selected)); } } if ($fieldType === 'checkbox') { $displayValue = !empty($value) ? 'Evet' : 'Hayir'; } if (($prefix !== '' || $suffix !== '') && $displayValue !== '-' && $displayValue !== '') { $displayValue = $prefix . $displayValue . $suffix; } if ($fieldType === 'signature' && is_string($value) && str_starts_with($value, 'data:image')) { $displayHtml = 'Imza'; } @endphp @if ($fieldKey !== '')
@if (!$labelAfter) @endif
@if ($displayHtml) {!! $displayHtml !!} @elseif ($linkPath) {{ $displayValue }} @else {{ $displayValue }} @endif
@if ($description !== '')
{{ $description }}
@endif @if ($labelAfter) @endif
@endif @endif @endforeach