@php
/** @var \App\Models\Order|\Closure|null $record */
if (isset($getRecord) && is_callable($getRecord)) {
$record = $getRecord();
}
if ($record instanceof \Closure) {
$record = $record();
}
@endphp
@if (! $record)
-
@else
@php
$stages = \App\Models\Order::progressStages();
$currentIndex = $record->progressIndex();
$isDelivered = $record->currentStatusCode() === \App\Enums\OrderStatus::EntregadoAlCliente->value;
$isCanceled = $record->isCanceled();
$isOnHold = $record->isOnHold();
$stepColor = function (int $index) use ($currentIndex, $isCanceled, $isOnHold, $isDelivered, $stages): string {
if ($isCanceled) {
return 'gray';
}
if ($isOnHold) {
return 'warning';
}
if ($isDelivered && $index === (count($stages) - 1)) {
return 'success';
}
if ($currentIndex === null) {
return 'gray';
}
if ($index < $currentIndex) {
return 'primary';
}
if ($index === $currentIndex) {
return $isDelivered ? 'success' : 'primary';
}
return 'gray';
};
$isCompleted = function (int $index) use ($currentIndex): bool {
return $currentIndex !== null && $index < $currentIndex;
};
@endphp
@foreach ($stages as $i => $stage)
{{ $i + 1 }}
@if ($isCompleted($i))
@endif
{{ $stage['label'] }}
{{ $stage['label'] }}
@endforeach
@if ($isCanceled)
Proceso interrumpido (Cancelado).
@elseif ($isOnHold)
En pausa (On Hold).
@endif
@endif