@php $byTable = $byTable ?? []; @endphp
@foreach($computed as $name => $info)
@php
$left = ($info['x'] - $minX + $safe); $top = ($info['y'] - $minY + $safe);
$w = $info['w']; $h = $info['h']; $ss = $info['seatSize'];
@endphp
@php $assigned = $byTable[$name] ?? []; @endphp
@if($info['type'] === 'round')
@php
$diameterPx = $info['diameterPx'];
$radiusTable = $diameterPx / 2;
$radiusSeats = (int) round($radiusTable + ($ss / 1.35));
$container = max($w, $h);
$center = $container / 2;
// Build seat map from assigned as in UI
$seatMap = array_fill(0, max(1, ($tables[$name]['capacity'] ?? 8)), null);
$pending = [];
foreach ($assigned as $it) {
$s = $it['seat'] ?? null;
if ($s !== null && is_numeric($s)) {
$si = (int)$s; if ($si >= 0 && $si < count($seatMap) && $seatMap[$si] === null) { $seatMap[$si] = $it; }
else { $pending[] = $it; }
} else { $pending[] = $it; }
}
for ($fi=0,$pi=0; $fi
{{ $name }}
@for($i=0; $i<$capacity; $i++)
@php
$angle = (2 * M_PI * $i) / max(1,$capacity);
$x = $center + $radiusSeats * cos($angle) - $ss/2;
$y = $center + $radiusSeats * sin($angle) - $ss/2;
$occ = $seatMap[$i] ?? null;
$nameWords = $occ ? preg_split('/\s+/', (string)($occ['label'] ?? ''), -1, PREG_SPLIT_NO_EMPTY) : [];
@endphp
@if($occ)
@else
{{ $i+1 }}
@endif
@if($occ && !empty($nameWords))
@php
$labelLeft = (int) round($x + ($ss / 2));
$labelTop = (int) round($y + $ss + 5);
@endphp
@foreach($nameWords as $w) {{ $w }} @endforeach
@endif
@endfor
@else
@php
$capacity = $tables[$name]['capacity'] ?? 8;
$type = $info['type'];
$rectW = $info['rectW']; $rectH = $info['rectH'];
$angleDeg = (int)($info['angle_deg'] ?? 0);
$edgePad = 20;
$rows = ($type === 'rect-2') ? 2 : 1;
$containerW = $w; $containerH = $h;
$rectX = ($containerW - $rectW) / 2; $rectY = ($containerH - $rectH) / 2;
$originX = (int) round($rectW / 2);
$originY = (int) round($rectH / 2);
$transform = sprintf('translate(%dpx, %dpx) rotate(%ddeg) translate(-%dpx, -%dpx)', $originX, $originY, $angleDeg, $originX, $originY);
// compute seats distribution
if ($type === 'rect-2') {
$topCount = (int) ceil($capacity / 2);
$bottomCount = $capacity - $topCount;
} else { $topCount = $capacity; $bottomCount = 0; }
$computeRowXs = function($n) use($rectW,$ss){
if ($n <= 0) return [];
if ($n === 1) { return [ ($rectW - $ss)/2 ]; }
$gap = ($rectW - $ss) / max(1, ($n-1));
$xs = [];
for ($i=0; $i<$n; $i++) { $xs[] = $i*$gap; }
return $xs;
};
$topXs = $computeRowXs($topCount);
$bottomXs = $computeRowXs($bottomCount);
$topRowYRel = (int) -($ss + 10);
$bottomRowYRel = (int) ($rectH + 10);
// Build seat map for this table
$seatMap = array_fill(0, max(1, $capacity), null); $pending = [];
foreach (($assigned ?? []) as $it){ $s = $it['seat'] ?? null; if ($s!==null && is_numeric($s)){ $si=(int)$s; if ($si>=0 && $si<$capacity && $seatMap[$si]===null) $seatMap[$si]=$it; else $pending[]=$it; } else { $pending[]=$it; } }
for ($fi=0,$pi=0; $fi<$capacity && $pi
= 30 && $a <= 130) || ($a >= 230 && $a <= 315);
@endphp
{{ $name }}
@for($i=0; $i<$topCount; $i++)
@php $x = $topXs[$i] ?? 0; $occ = $seatMap[$i] ?? null; @endphp
@if($occ)
@php $nameWords = preg_split('/\s+/', (string)($occ['label'] ?? ''), -1, PREG_SPLIT_NO_EMPTY); @endphp
@if(!empty($nameWords))
@foreach($nameWords as $w) {{ $w }} @endforeach
@endif
@else
{{ $i+1 }}
@endif
@endfor
@for($j=0; $j<$bottomCount; $j++)
@php $x = $bottomXs[$j] ?? 0; $global = $topCount + $j; $occ = $seatMap[$global] ?? null; @endphp
@if($occ)
@php $nameWords = preg_split('/\s+/', (string)($occ['label'] ?? ''), -1, PREG_SPLIT_NO_EMPTY); @endphp
@if(!empty($nameWords))
@foreach($nameWords as $w) {{ $w }} @endforeach
@endif
@else
{{ $global+1 }}
@endif
@endfor
@endif
@endforeach