Commit a7a48477 authored by Mahmoud Aglan's avatar Mahmoud Aglan

test

parent 6bfad320
...@@ -35,39 +35,65 @@ ...@@ -35,39 +35,65 @@
<h3 style="margin:0;color:#1A1A2E;font-size:15px;">مخطط الحالات</h3> <h3 style="margin:0;color:#1A1A2E;font-size:15px;">مخطط الحالات</h3>
</div> </div>
<div style="padding:30px;overflow-x:auto;"> <div style="padding:30px;overflow-x:auto;">
<div style="display:flex;flex-wrap:wrap;gap:16px;justify-content:center;align-items:center;min-height:200px;"> <?php
<?php foreach ($states as $key => $state): ?> // Sort states in logical flow order using BFS from initial state
$orderedKeys = [];
$visited = [];
$initialKey = null;
foreach ($states as $key => $s) {
if (($s['type'] ?? '') === 'initial') { $initialKey = $key; break; }
}
if ($initialKey) {
$queue = [$initialKey];
$visited[$initialKey] = true;
while (!empty($queue)) {
$current = array_shift($queue);
$orderedKeys[] = $current;
foreach ($transitions as $t) {
if ($t['from'] === $current && !isset($visited[$t['to']])) {
$visited[$t['to']] = true;
$queue[] = $t['to'];
}
}
}
// Append any unreachable states at end
foreach ($states as $key => $s) {
if (!isset($visited[$key])) { $orderedKeys[] = $key; }
}
} else {
$orderedKeys = array_keys($states);
}
?>
<div style="display:flex;align-items:center;gap:0;justify-content:center;min-height:120px;flex-wrap:wrap;">
<?php foreach ($orderedKeys as $idx => $key): ?>
<?php <?php
$state = $states[$key];
$type = $state['type'] ?? 'intermediate'; $type = $state['type'] ?? 'intermediate';
$bgColor = match($type) { $bgColor = match($type) {
'initial' => '#EFF6FF', 'initial' => '#EFF6FF',
'terminal' => '#FEF2F2', 'terminal' => '#FEF2F2',
'intermediate' => '#FFFFFF', default => '#FFFFFF',
default => '#F9FAFB',
}; };
$borderColor = match($type) { $borderColor = match($type) {
'initial' => '#0284C7',
'terminal' => '#DC2626',
'intermediate' => '#0D7377',
default => '#E5E7EB',
};
$iconColor = match($type) {
'initial' => '#0284C7', 'initial' => '#0284C7',
'terminal' => '#DC2626', 'terminal' => '#DC2626',
default => '#0D7377', default => '#0D7377',
}; };
$borderRadius = ($type === 'initial') ? '50%' : (($type === 'terminal') ? '8px' : '12px'); $typeLabel = match($type) {
$borderWidth = ($type === 'terminal') ? '3px' : '2px'; 'initial' => '&#9654;',
$size = ($type === 'initial') ? 'width:130px;height:130px;' : 'min-width:140px;padding:18px 22px;'; 'terminal' => '&#9632;',
default => '',
};
?> ?>
<div style="background:<?= $bgColor ?>;border:<?= $borderWidth ?> solid <?= $borderColor ?>;border-radius:<?= $borderRadius ?>;<?= $size ?>text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 2px 8px rgba(0,0,0,0.04);transition:transform 0.2s,box-shadow 0.2s;"> <?php if ($idx > 0): ?>
<div style="font-weight:700;color:#1A1A2E;font-size:14px;margin-bottom:4px;"><?= e($state['label_ar'] ?? $key) ?></div> <div style="display:flex;align-items:center;padding:0 6px;color:#9CA3AF;font-size:18px;">&#8592;</div>
<div style="font-size:10px;color:#9CA3AF;font-family:monospace;"><?= e($key) ?></div> <?php endif; ?>
<?php if ($type === 'initial'): ?> <div style="background:<?= $bgColor ?>;border:2px solid <?= $borderColor ?>;border-radius:10px;padding:14px 20px;text-align:center;min-width:110px;box-shadow:0 1px 4px rgba(0,0,0,0.05);">
<div style="font-size:10px;color:<?= $iconColor ?>;margin-top:4px;font-weight:600;">&#9654; بداية</div> <?php if ($typeLabel): ?>
<?php elseif ($type === 'terminal'): ?> <div style="font-size:10px;color:<?= $borderColor ?>;margin-bottom:4px;"><?= $typeLabel ?></div>
<div style="font-size:10px;color:<?= $iconColor ?>;margin-top:4px;font-weight:600;">&#9632; نهاية</div>
<?php endif; ?> <?php endif; ?>
<div style="font-weight:700;color:#1A1A2E;font-size:13px;margin-bottom:3px;"><?= e($state['label_ar'] ?? $key) ?></div>
<div style="font-size:10px;color:#9CA3AF;font-family:monospace;"><?= e($key) ?></div>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment